diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-07-17 09:58:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 09:58:42 +0200 |
commit | 05731f11d6239b1129c73a79433923c9d1448d3e (patch) | |
tree | 63a7c303b2f838f2630d87595a6c312883aed772 /activerecord | |
parent | d87fbf75abd368fef33f1f01024623f32881b2d2 (diff) | |
parent | 1701709e7f87520a07eed87dec1570be13584f72 (diff) | |
download | rails-05731f11d6239b1129c73a79433923c9d1448d3e.tar.gz rails-05731f11d6239b1129c73a79433923c9d1448d3e.tar.bz2 rails-05731f11d6239b1129c73a79433923c9d1448d3e.zip |
Merge pull request #29823 from y-yagi/fix_record_not_unique_error
Move `reset_pk_sequence!` test to `AdapterTestWithoutTransaction`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 827bcba121..eccd250d19 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -156,26 +156,6 @@ module ActiveRecord end end - # test resetting sequences in odd tables in PostgreSQL - if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!) - require "models/movie" - require "models/subscriber" - - def test_reset_empty_table_with_custom_pk - Movie.delete_all - Movie.connection.reset_pk_sequence! "movies" - assert_equal 1, Movie.create(name: "fight club").id - end - - def test_reset_table_with_non_integer_pk - Subscriber.delete_all - Subscriber.connection.reset_pk_sequence! "subscribers" - sub = Subscriber.new(name: "robert drake") - sub.id = "bob drake" - assert_nothing_raised { sub.save! } - end - end - def test_uniqueness_violations_are_translated_to_specific_exception @connection.execute "INSERT INTO subscribers(nick) VALUES('me')" error = assert_raises(ActiveRecord::RecordNotUnique) do @@ -368,5 +348,25 @@ module ActiveRecord assert !@connection.transaction_open? end end + + # test resetting sequences in odd tables in PostgreSQL + if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!) + require "models/movie" + require "models/subscriber" + + def test_reset_empty_table_with_custom_pk + Movie.delete_all + Movie.connection.reset_pk_sequence! "movies" + assert_equal 1, Movie.create(name: "fight club").id + end + + def test_reset_table_with_non_integer_pk + Subscriber.delete_all + Subscriber.connection.reset_pk_sequence! "subscribers" + sub = Subscriber.new(name: "robert drake") + sub.id = "bob drake" + assert_nothing_raised { sub.save! } + end + end end end |