1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/book_encrypted.rb
Ricardo Díaz 434fb39d47
Add new "encrypted_books" table to the schema
Reusing the "books" one could cause interferences when fixtures are
loaded in a very specific order such as:

https://buildkite.com/rails/rails/builds/76217#ee4ce591-e6c1-4a0d-a7db-1f83647d141e

Reproduction script:

```
activerecord $ bin/test -v --seed 23607 -n "/^(?:EagerAssociationTest#(?:test_preloading_a_regular_association_with_a_typo_through_a_polymorphic_association_still_raises)|ActiveRecord::Encryption::EncryptableFixtureTest#(?:test_fixtures_get_encrypted_automatically)|ViewWithoutPrimaryKeyTest#(?:test_attributes|test_reading))$/"
```
2021-04-03 08:00:01 -04:00

24 lines
587 B
Ruby

# frozen_string_literal: true
class UnencryptedBook < ActiveRecord::Base
self.table_name = "encrypted_books"
end
class EncryptedBook < ActiveRecord::Base
self.table_name = "encrypted_books"
encrypts :name, deterministic: true
end
class EncryptedBookWithDowncaseName < ActiveRecord::Base
self.table_name = "encrypted_books"
validates :name, uniqueness: true
encrypts :name, deterministic: true, downcase: true
end
class EncryptedBookThatIgnoresCase < ActiveRecord::Base
self.table_name = "encrypted_books"
encrypts :name, deterministic: true, ignore_case: true
end