diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2014-12-11 22:57:28 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2014-12-29 09:19:21 +0900 |
commit | 3628025c0dea3e08ea386700ec5eea27a26ce5d6 (patch) | |
tree | 933654027988dc4ec799597ad47eb1925487e237 /activerecord/test/cases | |
parent | 73fe108d700cc2fa85bc7775c5a2ca9ca529849a (diff) | |
download | rails-3628025c0dea3e08ea386700ec5eea27a26ce5d6.tar.gz rails-3628025c0dea3e08ea386700ec5eea27a26ce5d6.tar.bz2 rails-3628025c0dea3e08ea386700ec5eea27a26ce5d6.zip |
Improve a dump of the primary key support.
If it is not a default primary key, correctly dump the type and options.
Diffstat (limited to 'activerecord/test/cases')
-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 |