From 000bd6229d92aec2cd46f6bac3d6a7fafb83c5b4 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 6 Dec 2016 03:35:30 +0900 Subject: Make `:auto_increment` to internal primary key option Using `:auto_increment` option for abstracting the DB-specific auto incremental types. It is worth to ease to implement the compatibility layer. --- activerecord/test/cases/primary_keys_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'activerecord/test/cases') 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 -- cgit v1.2.3