Fix: allow destroying "not now" state when closing cards

- Update `Card::Closeable` to destroy associated "not now" state during close.
- Add new tests to verify closure behavior for different column types, including "not now".
This commit is contained in:
Dylan
2025-12-23 13:43:03 +08:00
parent 641e67dc2e
commit a005391724
2 changed files with 29 additions and 0 deletions
+1
View File
@@ -31,6 +31,7 @@ module Card::Closeable
def close(user: Current.user)
unless closed?
transaction do
not_now&.destroy
create_closure! user: user
track_event :closed, creator: user
end
+28
View File
@@ -31,4 +31,32 @@ class Card::CloseableTest < ActiveSupport::TestCase
assert cards(:shipping).reload.open?
assert cards(:shipping).events.last.action.card_reopened?
end
test "close card from triage column" do
card = cards(:logo)
assert_equal columns(:writebook_triage), card.column
card.close
assert card.closed?
end
test "close card from active column" do
card = cards(:text)
assert_equal columns(:writebook_in_progress), card.column
card.close
assert card.closed?
end
test "close card from NOT NOW" do
card = cards(:logo)
card.postpone
assert card.postponed?
assert card.not_now.present?
card.close
assert card.closed?
assert_nil card.reload.not_now
end
end