File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -319,6 +319,27 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
319319 assert_equal [ tag . title ] , @response . parsed_body [ "tags" ]
320320 end
321321
322+ test "update as JSON with description and tag_ids busts the card cache key" do
323+ card = cards ( :logo )
324+ original_cache_key = card . cache_key_with_version
325+ tag = tags ( :mobile )
326+
327+ travel 1 . minute do
328+ put card_path ( card , format : :json ) , params : {
329+ card : {
330+ description : "Updated description" ,
331+ tag_ids : [ tag . id ]
332+ }
333+ }
334+ end
335+
336+ assert_response :success
337+ assert_not_equal original_cache_key , card . reload . cache_key_with_version
338+ assert_equal "Updated description" , card . description . to_plain_text . strip
339+ assert_equal [ tag ] , card . tags
340+ assert_equal [ tag . title ] , @response . parsed_body [ "tags" ]
341+ end
342+
322343 test "delete as JSON" do
323344 card = cards ( :logo )
324345
Original file line number Diff line number Diff line change @@ -25,4 +25,17 @@ class Card::TaggableTest < ActiveSupport::TestCase
2525
2626 assert_not_equal cards ( :logo ) . tags . last , cards ( :paycheck ) . tags . last
2727 end
28+
29+ test "updating just tag_ids touches the card and board" do
30+ board = @card . board
31+ card_updated_at = @card . updated_at
32+ board_updated_at = board . updated_at
33+
34+ travel 1 . minute do
35+ @card . update! ( tag_ids : [ tags ( :web ) . id , tags ( :mobile ) . id ] )
36+ end
37+
38+ assert @card . reload . updated_at > card_updated_at
39+ assert board . reload . updated_at > board_updated_at
40+ end
2841end
You can’t perform that action at this time.
0 commit comments