Rename Entropy::Configuration to just Entropy

This commit is contained in:
David Heinemeier Hansson
2025-11-02 13:11:41 +01:00
parent d29e4dcdcf
commit b3474ec97d
29 changed files with 148 additions and 148 deletions
@@ -0,0 +1,15 @@
require "test_helper"
class Account::EntropiesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "update" do
put account_entropy_path, params: { entropy: { auto_postpone_period: 1.day } }
assert_equal 1.day, entropies("37s_account").auto_postpone_period
assert_redirected_to account_settings_path
end
end
@@ -1,15 +0,0 @@
require "test_helper"
class Account::EntropyConfigurationsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "update" do
put account_entropy_configuration_path, params: { entropy_configuration: { auto_postpone_period: 1.day } }
assert_equal 1.day, entropy_configurations("37s_account").auto_postpone_period
assert_redirected_to account_settings_path
end
end
@@ -0,0 +1,16 @@
require "test_helper"
class Collections::EntropiesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
@collection = collections(:writebook)
end
test "update" do
put collection_entropy_path(@collection), params: { collection: { auto_postpone_period: 1.day } }
assert_equal 1.day, @collection.entropy.reload.auto_postpone_period
assert_turbo_stream action: :replace, target: dom_id(@collection, :entropy)
end
end
@@ -1,16 +0,0 @@
require "test_helper"
class Collections::EntropyConfigurationsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
@collection = collections(:writebook)
end
test "update" do
put collection_entropy_configuration_path(@collection), params: { collection: { auto_postpone_period: 1.day } }
assert_equal 1.day, @collection.entropy_configuration.reload.auto_postpone_period
assert_turbo_stream action: :replace, target: dom_id(@collection, :entropy_configuration)
end
end
@@ -44,7 +44,7 @@ class CollectionsControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to edit_collection_path(collections(:writebook))
assert_equal "Writebook bugs", collections(:writebook).reload.name
assert_equal users(:kevin, :jz).sort, collections(:writebook).users.sort
assert_equal 1.day, entropy_configurations(:writebook_collection).auto_postpone_period
assert_equal 1.day, entropies(:writebook_collection).auto_postpone_period
assert_not collections(:writebook).all_access?
end
+12 -12
View File
@@ -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)
+1 -1
View File
@@ -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?
-20
View File
@@ -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
+20
View File
@@ -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
+2 -2
View File
@@ -9,7 +9,7 @@ class RouteTest < ActionDispatch::IntegrationTest
assert_recognizes({ controller: "account/settings", action: "show" }, "/account/settings")
end
test "account/entropy_configuration" do
assert_recognizes({ controller: "account/entropy_configurations", action: "show" }, "/account/entropy_configuration")
test "account/entropy" do
assert_recognizes({ controller: "account/entropies", action: "show" }, "/account/entropy")
end
end