From d612a71b39c36b8b6696f0c95e36ad85015e6379 Mon Sep 17 00:00:00 2001 From: klar Date: Sun, 21 Jun 2026 13:26:04 +0200 Subject: [PATCH 1/3] Update last_active_at when steps are created, edited, toggled, or deleted --- app/models/step.rb | 5 +++- .../cards/steps_controller_test.rb | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/models/step.rb b/app/models/step.rb index 27d580de1e..819f9efb36 100644 --- a/app/models/step.rb +++ b/app/models/step.rb @@ -1,6 +1,9 @@ class Step < ApplicationRecord belongs_to :account, default: -> { card.account } - belongs_to :card, touch: true + belongs_to :card + + after_save -> { card.touch_last_active_at } + after_destroy -> { card.touch_last_active_at } scope :completed, -> { where(completed: true) } diff --git a/test/controllers/cards/steps_controller_test.rb b/test/controllers/cards/steps_controller_test.rb index 011b688125..19cc9c2c63 100644 --- a/test/controllers/cards/steps_controller_test.rb +++ b/test/controllers/cards/steps_controller_test.rb @@ -9,8 +9,10 @@ class Cards::StepsControllerTest < ActionDispatch::IntegrationTest card = cards(:logo) assert_difference -> { card.steps.count }, +1 do - post card_steps_path(card), params: { step: { content: "Research alternatives" } }, as: :turbo_stream - assert_turbo_stream action: :before, target: dom_id(card, :new_step) + assert_changes -> { card.reload.last_active_at } do + post card_steps_path(card), params: { step: { content: "Research alternatives" } }, as: :turbo_stream + assert_turbo_stream action: :before, target: dom_id(card, :new_step) + end end assert_equal "Research alternatives", card.steps.last.content @@ -21,8 +23,10 @@ class Cards::StepsControllerTest < ActionDispatch::IntegrationTest step = card.steps.create!(content: "Original content") assert_changes -> { step.reload.content }, from: "Original content", to: "Updated content" do - put card_step_path(card, step), params: { step: { content: "Updated content" } }, as: :turbo_stream - assert_turbo_stream action: :replace, target: dom_id(step) + assert_changes -> { card.reload.last_active_at } do + put card_step_path(card, step), params: { step: { content: "Updated content" } }, as: :turbo_stream + assert_turbo_stream action: :replace, target: dom_id(step) + end end end @@ -31,8 +35,10 @@ class Cards::StepsControllerTest < ActionDispatch::IntegrationTest step = card.steps.create!(content: "Step to delete") assert_difference -> { card.steps.count }, -1 do - delete card_step_path(card, step), as: :turbo_stream - assert_turbo_stream action: :remove, target: dom_id(step) + assert_changes -> { card.reload.last_active_at } do + delete card_step_path(card, step), as: :turbo_stream + assert_turbo_stream action: :remove, target: dom_id(step) + end end end @@ -42,8 +48,10 @@ class Cards::StepsControllerTest < ActionDispatch::IntegrationTest # Toggle to completed assert_changes -> { step.reload.completed? }, from: false, to: true do - put card_step_path(card, step), params: { step: { completed: "1" } }, as: :turbo_stream - assert_turbo_stream action: :replace, target: dom_id(step) + assert_changes -> { card.reload.last_active_at } do + put card_step_path(card, step), params: { step: { completed: "1" } }, as: :turbo_stream + assert_turbo_stream action: :replace, target: dom_id(step) + end end # Toggle back to incomplete From a624c2efb73d80974b435fe372bc4ca1417c5c6d Mon Sep 17 00:00:00 2001 From: klar Date: Sun, 21 Jun 2026 13:54:28 +0200 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- app/models/step.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/step.rb b/app/models/step.rb index 819f9efb36..8d96c73480 100644 --- a/app/models/step.rb +++ b/app/models/step.rb @@ -2,8 +2,8 @@ class Step < ApplicationRecord belongs_to :account, default: -> { card.account } belongs_to :card - after_save -> { card.touch_last_active_at } - after_destroy -> { card.touch_last_active_at } +after_save -> { card.touch_last_active_at } +after_destroy -> { card.touch_last_active_at unless destroyed_by_association } scope :completed, -> { where(completed: true) } From aeb232cbba52e9507dba098253603f9c55743b6b Mon Sep 17 00:00:00 2001 From: klar Date: Sun, 21 Jun 2026 16:08:10 +0200 Subject: [PATCH 3/3] Potential fix for pull request finding 2-space indentation style Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- app/models/step.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/step.rb b/app/models/step.rb index 8d96c73480..707f776c53 100644 --- a/app/models/step.rb +++ b/app/models/step.rb @@ -2,8 +2,8 @@ class Step < ApplicationRecord belongs_to :account, default: -> { card.account } belongs_to :card -after_save -> { card.touch_last_active_at } -after_destroy -> { card.touch_last_active_at unless destroyed_by_association } + after_save -> { card.touch_last_active_at } + after_destroy -> { card.touch_last_active_at unless destroyed_by_association } scope :completed, -> { where(completed: true) }