Move tests into their controller tests

This commit is contained in:
Stanko K.R.
2025-12-05 13:28:58 +01:00
parent 75f273c6fa
commit ae03f2b283
6 changed files with 92 additions and 56 deletions
+22
View File
@@ -132,4 +132,26 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
get card_path(card)
assert_response :success
end
test "show as JSON" do
get card_path(cards(:logo)), as: :json
assert_response :success
assert_equal cards(:logo).title, @response.parsed_body["title"]
end
test "create as JSON" do
assert_difference -> { Card.count }, +1 do
post board_cards_path(boards(:writebook)),
params: { card: { title: "My new card", description: "Big if true", tag_ids: [ tags(:web).id, tags(:mobile).id ] } },
as: :json
end
assert_response :created
assert_equal card_path(Card.last, format: :json), @response.headers["Location"]
card = Card.last
assert_equal "My new card", card.title
assert_equal "Big if true", card.description.to_plain_text
assert_equal [ tags(:mobile), tags(:web) ].sort, card.tags.sort
end
end