Rename Entropy::Configuration to just Entropy
This commit is contained in:
@@ -8,8 +8,8 @@ class Card::EntropicTest < ActiveSupport::TestCase
|
||||
test "auto_postpone_at uses the period defined in the account by default" do
|
||||
freeze_time
|
||||
|
||||
entropy_configurations(:writebook_collection).destroy
|
||||
entropy_configurations("37s_account").reload.update! auto_postpone_period: 456.days
|
||||
entropies(:writebook_collection).destroy
|
||||
entropies("37s_account").reload.update! auto_postpone_period: 456.days
|
||||
cards(:layout).update! last_active_at: 2.day.ago
|
||||
assert_equal (456 - 2).days.from_now, cards(:layout).entropy.auto_clean_at
|
||||
end
|
||||
@@ -17,16 +17,16 @@ class Card::EntropicTest < ActiveSupport::TestCase
|
||||
test "auto_postpone_at infers the period from the collection when present" do
|
||||
freeze_time
|
||||
|
||||
entropy_configurations(:writebook_collection).update! auto_postpone_period: 123.days
|
||||
entropies(:writebook_collection).update! auto_postpone_period: 123.days
|
||||
cards(:layout).update! last_active_at: 2.day.ago
|
||||
assert_equal (123 - 2).days.from_now, cards(:layout).entropy.auto_clean_at
|
||||
end
|
||||
|
||||
test "auto postpone all due using the default account entropy configuration" do
|
||||
entropy_configurations(:writebook_collection).destroy
|
||||
test "auto postpone all due using the default account entropy" do
|
||||
entropies(:writebook_collection).destroy
|
||||
|
||||
cards(:logo).update!(last_active_at: 1.day.ago - entropy_configurations("37s_account").auto_postpone_period)
|
||||
cards(:shipping).update!(last_active_at: 1.day.from_now - entropy_configurations("37s_account").auto_postpone_period)
|
||||
cards(:logo).update!(last_active_at: 1.day.ago - entropies("37s_account").auto_postpone_period)
|
||||
cards(:shipping).update!(last_active_at: 1.day.from_now - entropies("37s_account").auto_postpone_period)
|
||||
|
||||
assert_difference -> { Card.postponed.count }, +1 do
|
||||
Card.auto_postpone_all_due
|
||||
@@ -37,9 +37,9 @@ class Card::EntropicTest < ActiveSupport::TestCase
|
||||
assert_not cards(:shipping).reload.postponed?
|
||||
end
|
||||
|
||||
test "auto postpone all due using entropy configuration defined at the collection level" do
|
||||
cards(:logo).update!(last_active_at: 1.day.ago - entropy_configurations(:writebook_collection).auto_postpone_period)
|
||||
cards(:shipping).update!(last_active_at: 1.day.from_now - entropy_configurations(:writebook_collection).auto_postpone_period)
|
||||
test "auto postpone all due using entropy defined at the collection level" do
|
||||
cards(:logo).update!(last_active_at: 1.day.ago - entropies(:writebook_collection).auto_postpone_period)
|
||||
cards(:shipping).update!(last_active_at: 1.day.from_now - entropies(:writebook_collection).auto_postpone_period)
|
||||
|
||||
assert_difference -> { Card.postponed.count }, +1 do
|
||||
Card.auto_postpone_all_due
|
||||
@@ -52,8 +52,8 @@ class Card::EntropicTest < ActiveSupport::TestCase
|
||||
test "postponing soon scope" do
|
||||
cards(:logo, :shipping).each(&:published!)
|
||||
|
||||
cards(:logo).update!(last_active_at: entropy_configurations(:writebook_collection).auto_postpone_period.seconds.ago + 2.days)
|
||||
cards(:shipping).update!(last_active_at: entropy_configurations(:writebook_collection).auto_postpone_period.seconds.ago - 2.days)
|
||||
cards(:logo).update!(last_active_at: entropies(:writebook_collection).auto_postpone_period.seconds.ago + 2.days)
|
||||
cards(:shipping).update!(last_active_at: entropies(:writebook_collection).auto_postpone_period.seconds.ago - 2.days)
|
||||
|
||||
assert_includes Card.postponing_soon, cards(:logo)
|
||||
assert_not_includes Card.postponing_soon, cards(:shipping)
|
||||
|
||||
@@ -28,7 +28,7 @@ class Card::StallableTest < ActiveSupport::TestCase
|
||||
|
||||
test "a card with an old activity spike is not stalled after being postponed" do
|
||||
card = cards(:logo)
|
||||
card.update!(last_active_at: 1.day.ago - card.collection.entropy_configuration.auto_postpone_period)
|
||||
card.update!(last_active_at: 1.day.ago - card.collection.entropy.auto_postpone_period)
|
||||
card.create_activity_spike!(updated_at: 3.months.ago)
|
||||
|
||||
assert card.stalled?
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class Entropy::ConfigurationTest < ActiveSupport::TestCase
|
||||
test "touch cards when configuration changes for collection container" do
|
||||
collection = collections(:writebook)
|
||||
config = collection.entropy_configuration || collection.create_entropy_configuration!(auto_postpone_period: 30.days)
|
||||
|
||||
assert_enqueued_with(job: Card::TouchAllJob, args: [ collection ]) do
|
||||
config.update!(auto_postpone_period: 15.days)
|
||||
end
|
||||
end
|
||||
|
||||
test "touch cards when configuration changes for account container" do
|
||||
account = Account.sole
|
||||
|
||||
assert_enqueued_with(job: Card::TouchAllJob, args: [ account ]) do
|
||||
account.default_entropy_configuration.update!(auto_postpone_period: 45.days)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
require "test_helper"
|
||||
|
||||
class Entropy::Test < ActiveSupport::TestCase
|
||||
test "touch cards when entropy changes for collection container" do
|
||||
collection = collections(:writebook)
|
||||
config = collection.entropy || collection.create_entropy!(auto_postpone_period: 30.days)
|
||||
|
||||
assert_enqueued_with(job: Card::TouchAllJob, args: [ collection ]) do
|
||||
config.update!(auto_postpone_period: 15.days)
|
||||
end
|
||||
end
|
||||
|
||||
test "touch cards when entropy changes for account container" do
|
||||
account = Account.sole
|
||||
|
||||
assert_enqueued_with(job: Card::TouchAllJob, args: [ account ]) do
|
||||
account.default_entropy.update!(auto_postpone_period: 45.days)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user