No need to delegate auto_closing? anymore

Related to #568
This commit is contained in:
Mike Dalessio
2025-06-02 12:26:45 -04:00
parent c0cd5e1967
commit 3a5ce1ca4c
3 changed files with 11 additions and 13 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ module Card::Entropy
scope :stagnated, -> { doing.where(last_active_at: ..AUTO_RECONSIDER_PERIOD.ago) }
scope :due_to_be_closed, -> { considering.in_auto_closing_collection.where("last_active_at <= DATETIME('now', '-' || auto_close_period || ' seconds')") }
delegate :auto_closing?, :auto_close_period, to: :collection
delegate :auto_close_period, to: :collection
end
class_methods do
-8
View File
@@ -18,12 +18,4 @@ class Card::CloseableTest < ActiveSupport::TestCase
assert cards(:logo).closed?
assert_equal users(:kevin), cards(:logo).closed_by
end
test "autoclose_at infers the period from the collection" do
freeze_time
collections(:writebook).update! auto_close_period: 123.days
cards(:logo).update! last_active_at: 2.day.ago
assert_equal (123-2).days.from_now, cards(:logo).auto_close_at
end
end
+10 -4
View File
@@ -5,6 +5,14 @@ class Card::EntropyTest < ActiveSupport::TestCase
Current.session = sessions(:david)
end
test "auto_close_at infers the period from the collection" do
freeze_time
collections(:writebook).update! auto_close_period: 123.days
cards(:layout).update! last_active_at: 2.day.ago
assert_equal (123-2).days.from_now, cards(:layout).auto_close_at
end
test "auto close all due" do
cards(:logo, :shipping).each(&:reconsider)
@@ -49,11 +57,9 @@ class Card::EntropyTest < ActiveSupport::TestCase
end
test "entropy_cleaned_at returns when the entropy will be cleaned" do
cards(:logo).reconsider
assert_equal cards(:logo).auto_close_at, cards(:logo).entropy_cleaned_at
assert_not_nil cards(:logo).entropy_cleaned_at
assert_equal cards(:layout).auto_close_at, cards(:layout).entropy_cleaned_at
assert_not_nil cards(:layout).entropy_cleaned_at
cards(:logo).engage
assert_equal cards(:logo).auto_reconsider_at, cards(:logo).entropy_cleaned_at
assert_not_nil cards(:logo).entropy_cleaned_at
end