diff options
author | Alex Kitchens <alexcameron98@gmail.com> | 2017-05-30 09:04:36 -0500 |
---|---|---|
committer | Alex Kitchens <akitchens@financialpayments.com> | 2017-05-31 10:21:00 -0500 |
commit | dcd3b940e9e163ff87cf3dfa7748a5f18220b58d (patch) | |
tree | 9a29f45d9d04217d2f207994c6a72e448cb2c26c | |
parent | 612b54b96a8c401d186c1b0e2931b47df6eb2abc (diff) | |
download | rails-dcd3b940e9e163ff87cf3dfa7748a5f18220b58d.tar.gz rails-dcd3b940e9e163ff87cf3dfa7748a5f18220b58d.tar.bz2 rails-dcd3b940e9e163ff87cf3dfa7748a5f18220b58d.zip |
Reset primary key sequence in FixturesResetPkSequenceTests
The primary key sequence for each test in FixturesResetPkSequenceTest is
reset.
The state in some of the FixturesResetPkSequenceTest tests are leaking,
causing failurse in others. Using a seed of `48104`, the
`FixturesResetPkSequenceTest#test_resets_to_min_pk_with_specified_pk_and_sequence`
runs before the `DatabaseStatementsTest` tests, and
the tests fail with duplicate primary key errors:
```
Run options: --seed 48104 -n
"/^(?:FixturesResetPkSequenceTest#(?:test_resets_to_min_pk_with_specified_pk_and_sequence)|DatabaseStatementsTest#(?:test_create_should_return_the_inserted_id|test_exec_insert|test_insert_should_return_the_inserted_id))$/"
.EEE
1) Error:
DatabaseStatementsTest#test_exec_insert:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate
key value violates unique constraint "accounts_pkey"
DETAIL: Key (id)=(2) already exists.
2) Error:
DatabaseStatementsTest#test_create_should_return_the_inserted_id:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate
key value violates unique constraint "accounts_pkey"
DETAIL: Key (id)=(3) already exists.
3) Error:
DatabaseStatementsTest#test_insert_should_return_the_inserted_id:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate
key value violates unique constraint "accounts_pkey"
DETAIL: Key (id)=(4) already exists.
```
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index a0a6d3c7ef..718bbfdb74 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -365,6 +365,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!) class FixturesResetPkSequenceTest < ActiveRecord::TestCase fixtures :accounts fixtures :companies + self.use_transactional_tests = false def setup @instances = [Account.new(credit_limit: 50), Company.new(name: "RoR Consulting"), Course.new(name: "Test")] |