Tidy up code a bit

This commit is contained in:
Jorge Manrubia
2025-09-16 13:18:13 +02:00
parent 6fe28c53e7
commit b5a2c4a25e
2 changed files with 12 additions and 13 deletions
+11 -12
View File
@@ -41,23 +41,13 @@ module Card::Engageable
def engage
unless doing?
transaction do
reopen
create_engagement!(status: "doing")
end
reengage(status: "doing")
end
end
def move_to_on_deck
unless on_deck?
transaction do
reopen
if engagement.present?
engagement.update!(status: "on_deck")
else
create_engagement!(status: "on_deck")
end
end
reengage(status: "on_deck")
end
end
@@ -69,4 +59,13 @@ module Card::Engageable
touch_last_active_at
end
end
private
def reengage(status:)
transaction do
reopen
engagement&.destroy
create_engagement!(status:)
end
end
end
+1 -1
View File
@@ -98,7 +98,7 @@ class Card::EntropicTest < ActiveSupport::TestCase
assert_equal Time.current, cards(:logo).last_active_at
end
test "auto_reconsider_all_stagnated" do
test "auto_reconsider_all_stagnated includes cards in doing and on_deck" do
travel_to Time.current
cards(:logo, :shipping).each(&:engage)