Skip to content

Commit 803d9cd

Browse files
committed
Add API for postponing cards
1 parent 2a3c529 commit 803d9cd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

app/controllers/cards/not_nows_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ class Cards::NotNowsController < ApplicationController
33

44
def create
55
@card.postpone
6-
render_card_replacement
6+
7+
respond_to do |format|
8+
format.turbo_stream { render_card_replacement }
9+
format.json { head :no_content }
10+
end
711
end
812
end

test/controllers/cards/not_nows_controller_test.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ class Cards::NotNowsControllerTest < ActionDispatch::IntegrationTest
99
card = cards(:logo)
1010

1111
assert_changes -> { card.reload.postponed? }, from: false, to: true do
12-
post card_not_now_path(card)
12+
post card_not_now_path(card), as: :turbo_stream
1313
assert_card_container_rerendered(card)
1414
end
1515
end
16+
17+
test "create as JSON" do
18+
card = cards(:logo)
19+
20+
assert_not card.postponed?
21+
22+
post card_not_now_path(card), as: :json
23+
24+
assert_response :no_content
25+
assert card.reload.postponed?
26+
end
1627
end

0 commit comments

Comments
 (0)