1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix test EncryptableFixtureTest that fails intermittently

Reference:

https://buildkite.com/rails/rails/builds/76506#f42a5ab3-1923-4a9f-b843-56c4098b6bef
https://buildkite.com/rails/rails/builds/76590#04721d73-9505-4c29-82bf-0a1be1f41649
https://buildkite.com/rails/rails/builds/76556#aa284ad0-0eab-48e9-a50b-60e3b5c7ccac

Apparently when loading different fixtures that reference the same
table, the files that are loaded last run a `DELETE FROM` statement
that removes previous data.

Reproduction command using `minitest_bisect`:

```
activerecord $ bin/test -a mysql2 --seed 22031 -n "/^(?:ActiveRecord::Encryption::EncryptableRecordTest#(?:test_when_downcase:_true_it_creates_content_downcased)|ActiveRecord::Encryption::EncryptableFixtureTest#(?:test_fixtures_get_encrypted_automatically))$/"
```
This commit is contained in:
Ricardo Díaz 2021-04-16 13:01:45 -05:00
parent 0d91d4aa07
commit edc481a66d
2 changed files with 3 additions and 1 deletions

View file

@ -242,7 +242,7 @@ class ActiveRecord::Encryption::EncryptableRecordTest < ActiveRecord::Encryption
# Only run for adapters that add a default string limit when not provided (MySQL, 255) # Only run for adapters that add a default string limit when not provided (MySQL, 255)
if EncryptedAuthor.columns_hash["name"].limit if EncryptedAuthor.columns_hash["name"].limit
# No column limits in SQLLite # No column limits in SQLite
test "validate column sizes" do test "validate column sizes" do
assert EncryptedAuthor.new(name: "jorge").valid? assert EncryptedAuthor.new(name: "jorge").valid?
assert_not EncryptedAuthor.new(name: "a" * 256).valid? assert_not EncryptedAuthor.new(name: "a" * 256).valid?

View file

@ -4,6 +4,8 @@ require "cases/encryption/helper"
require "models/book_encrypted" require "models/book_encrypted"
class ActiveRecord::Encryption::EncryptableFixtureTest < ActiveRecord::EncryptionTestCase class ActiveRecord::Encryption::EncryptableFixtureTest < ActiveRecord::EncryptionTestCase
self.use_transactional_tests = false
fixtures :encrypted_books, :encrypted_book_that_ignores_cases fixtures :encrypted_books, :encrypted_book_that_ignores_cases
test "fixtures get encrypted automatically" do test "fixtures get encrypted automatically" do