diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-02 13:37:26 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-02 13:37:26 -0300 |
commit | a908e01ac0cfd5b1d9cda57699037df8aa32df25 (patch) | |
tree | b2064b0448d01f1a8f306b17b77868390f33cec8 /activerecord/test | |
parent | 78dab2a8569408658542e462a957ea5a35aa4679 (diff) | |
parent | 3628025c0dea3e08ea386700ec5eea27a26ce5d6 (diff) | |
download | rails-a908e01ac0cfd5b1d9cda57699037df8aa32df25.tar.gz rails-a908e01ac0cfd5b1d9cda57699037df8aa32df25.tar.bz2 rails-a908e01ac0cfd5b1d9cda57699037df8aa32df25.zip |
Merge pull request #18228 from kamipo/correctly_dump_primary_key
Improve a dump of the primary key support.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index 2dfc53f132..751eccc015 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'support/schema_dumping_helper' require 'models/topic' require 'models/reply' require 'models/subscriber' @@ -196,6 +197,8 @@ class PrimaryKeyWithNoConnectionTest < ActiveRecord::TestCase end class PrimaryKeyAnyTypeTest < ActiveRecord::TestCase + include SchemaDumpingHelper + self.use_transactional_fixtures = false class Barcode < ActiveRecord::Base @@ -217,6 +220,11 @@ class PrimaryKeyAnyTypeTest < ActiveRecord::TestCase assert_equal :string, column_type.type assert_equal 42, column_type.limit end + + test "schema dump primary key includes type and options" do + schema = dump_table_schema "barcodes" + assert_match %r{create_table "barcodes", primary_key: "code", id: :string, limit: 42}, schema + end end if current_adapter?(:MysqlAdapter, :Mysql2Adapter) @@ -235,6 +243,8 @@ end if current_adapter?(:PostgreSQLAdapter, :MysqlAdapter, :Mysql2Adapter) class PrimaryKeyBigSerialTest < ActiveRecord::TestCase + include SchemaDumpingHelper + self.use_transactional_fixtures = false class Widget < ActiveRecord::Base @@ -263,5 +273,14 @@ if current_adapter?(:PostgreSQLAdapter, :MysqlAdapter, :Mysql2Adapter) widget = Widget.create! assert_not_nil widget.id end + + test "schema dump primary key with bigserial" do + schema = dump_table_schema "widgets" + if current_adapter?(:PostgreSQLAdapter) + assert_match %r{create_table "widgets", id: :bigserial}, schema + else + assert_match %r{create_table "widgets", id: :bigint}, schema + end + end end end |