diff --git a/app/models/account/seedeable.rb b/app/models/account/seedeable.rb index df33c2bab..cd8bea1fe 100644 --- a/app/models/account/seedeable.rb +++ b/app/models/account/seedeable.rb @@ -2,6 +2,6 @@ module Account::Seedeable extend ActiveSupport::Concern def setup_customer_template - Account::Seeder.new(self, users.active.order(created_at: :asc).first).seed + Account::Seeder.new(self, users.active.first).seed end end diff --git a/app/models/account/seeder.rb b/app/models/account/seeder.rb index 467d610cf..28835041c 100644 --- a/app/models/account/seeder.rb +++ b/app/models/account/seeder.rb @@ -21,7 +21,7 @@ class Account::Seeder private def session - creator.identity.sessions.order(created_at: :desc).first + creator.identity.sessions.last end def populate diff --git a/app/models/concerns/uuid_primary_key.rb b/app/models/concerns/uuid_primary_key.rb index b990a63cd..6f5ddf9a9 100644 --- a/app/models/concerns/uuid_primary_key.rb +++ b/app/models/concerns/uuid_primary_key.rb @@ -13,7 +13,9 @@ module UuidPrimaryKey def self.generate_fixture_uuid(label) # Generate deterministic UUIDv7 for fixtures that sorts by fixture ID # This allows .first/.last to work as expected in tests - fixture_int = Digest::MD5.hexdigest("fixtures#{label}").hex % (2**31) + # Use the same CRC32 algorithm as Rails' default fixture ID generation + # so that UUIDs sort in the same order as integer IDs + fixture_int = Zlib.crc32("fixtures/#{label}") % (2**30 - 1) # Use fixture_int as second offset from a fixed base time (1 year before 2025-01-01) # This ensures all fixtures are in the past, and new test records are newest diff --git a/test/fixtures/sessions.yml b/test/fixtures/sessions.yml index 7cb1e8415..a062f53fd 100644 --- a/test/fixtures/sessions.yml +++ b/test/fixtures/sessions.yml @@ -3,3 +3,9 @@ david: kevin: identity: kevin + +jz: + identity: jz + +jason: + identity: jason