aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-12-05 14:23:04 -0500
committerGitHub <noreply@github.com>2016-12-05 14:23:04 -0500
commit575212a1ba2e4d170985531402c6e3d27af5a0ea (patch)
treed1fc129e79b9d4bb16e5fcf7ded9a0bd643e1d09 /activerecord/test
parentfd87169eb11fc4cfd9082dabe0a85f3bfa385c29 (diff)
parent000bd6229d92aec2cd46f6bac3d6a7fafb83c5b4 (diff)
downloadrails-575212a1ba2e4d170985531402c6e3d27af5a0ea.tar.gz
rails-575212a1ba2e4d170985531402c6e3d27af5a0ea.tar.bz2
rails-575212a1ba2e4d170985531402c6e3d27af5a0ea.zip
Merge pull request #27272 from kamipo/make_auto_increment_to_internal_primary_key_option
Make `:auto_increment` to internal primary key option
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/primary_keys_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index eaaf50d14f..7599434f4f 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -216,6 +216,33 @@ class PrimaryKeyWithNoConnectionTest < ActiveRecord::TestCase
end
end
+class PrimaryKeyWithAutoIncrementTest < ActiveRecord::TestCase
+ self.use_transactional_tests = false
+
+ class AutoIncrement < ActiveRecord::Base
+ end
+
+ def setup
+ @connection = ActiveRecord::Base.connection
+ @connection.create_table(:auto_increments, id: :integer, auto_increment: true, force: true)
+ end
+
+ def teardown
+ @connection.drop_table(:auto_increments, if_exists: true)
+ end
+
+ def test_primary_key_with_auto_increment
+ record1 = AutoIncrement.create!
+ assert_not_nil record1.id
+
+ record1.destroy
+
+ record2 = AutoIncrement.create!
+ assert_not_nil record2.id
+ assert_operator record2.id, :>, record1.id
+ end
+end
+
class PrimaryKeyAnyTypeTest < ActiveRecord::TestCase
include SchemaDumpingHelper