Use a dedicated resource for showing cards in draft mode

Mobile team needs this. Also, this lets us get rid from some conditionals for handling
both modes with a single template.

https://3.basecamp.com/2914079/buckets/44843469/messages/9437287330
This commit is contained in:
Jorge Manrubia
2026-01-07 11:29:40 +01:00
parent de47e3d2a8
commit f58a1aeb31
12 changed files with 109 additions and 17 deletions
@@ -0,0 +1,21 @@
require "test_helper"
class Cards::DraftsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "show" do
card = boards(:writebook).cards.create!(creator: users(:kevin), status: :drafted)
get card_draft_path(card)
assert_response :success
end
test "show redirects to card when published" do
card = cards(:logo)
get card_draft_path(card)
assert_redirected_to card
end
end
@@ -28,6 +28,6 @@ class Cards::PublishesControllerTest < ActionDispatch::IntegrationTest
new_card = Card.last
assert new_card.drafted?
assert_redirected_to new_card
assert_redirected_to card_draft_path(new_card)
end
end
+9 -2
View File
@@ -21,7 +21,7 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
end
card = Card.last
assert_redirected_to card
assert_redirected_to card_draft_path(card)
assert card.drafted?
end
@@ -31,10 +31,17 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
assert_no_difference -> { Card.count } do
post board_cards_path(boards(:writebook))
assert_redirected_to draft
assert_redirected_to card_draft_path(draft)
end
end
test "show redirects to draft when card is drafted" do
card = boards(:writebook).cards.create!(creator: users(:kevin), status: :drafted)
get card_path(card)
assert_redirected_to card_draft_path(card)
end
test "show" do
get card_path(cards(:logo))
assert_response :success