@@ -75,6 +75,21 @@ class FlatJsonParamsTest < ActionDispatch::IntegrationTest
7575 assert_equal "Flat description" , card . description . to_plain_text
7676 end
7777
78+ test "create card with flat JSON and tag_ids" do
79+ tag = tags ( :mobile )
80+
81+ assert_difference -> { Card . count } , +1 do
82+ post board_cards_path ( boards ( :writebook ) ) ,
83+ params : { title : "Flat tagged card" , tag_ids : [ tag . id ] } ,
84+ as : :json
85+ end
86+
87+ assert_response :created
88+ card = Card . last
89+ assert_equal [ tag ] , card . reload . tags
90+ assert_equal [ tag . title ] , @response . parsed_body [ "tags" ]
91+ end
92+
7893 test "update card with flat JSON" do
7994 card = cards ( :logo )
8095
@@ -88,6 +103,19 @@ class FlatJsonParamsTest < ActionDispatch::IntegrationTest
88103 assert_equal "Updated flat" , card . description . to_plain_text
89104 end
90105
106+ test "update card with flat JSON and tag_ids" do
107+ card = cards ( :logo )
108+ tag = tags ( :mobile )
109+
110+ put card_path ( card ) ,
111+ params : { tag_ids : [ tag . id ] } ,
112+ as : :json
113+
114+ assert_response :success
115+ assert_equal [ tag ] , card . reload . tags
116+ assert_equal [ tag . title ] , @response . parsed_body [ "tags" ]
117+ end
118+
91119 test "create board with flat JSON" do
92120 assert_difference -> { Board . count } , +1 do
93121 post boards_path , params : { name : "Flat board" } , as : :json
0 commit comments