diff options
author | Konstantin Shabanov <etehtsea@gmail.com> | 2012-09-07 22:27:08 +0400 |
---|---|---|
committer | Konstantin Shabanov <etehtsea@gmail.com> | 2012-09-08 11:09:49 +0400 |
commit | b485b8a06626be3a1b8a2037092a9dda1b28e8a4 (patch) | |
tree | 139444ad3ba8d37f2b28c3c8e66f5a97261cd0ef /activerecord/test/cases/schema_dumper_test.rb | |
parent | f415475621c79cbc2d93e1ecf10805a4100a5d43 (diff) | |
download | rails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.tar.gz rails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.tar.bz2 rails-b485b8a06626be3a1b8a2037092a9dda1b28e8a4.zip |
Dump schema using new style hash
Diffstat (limited to 'activerecord/test/cases/schema_dumper_test.rb')
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 68e88372f3..80d2670f94 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -96,7 +96,7 @@ class SchemaDumperTest < ActiveRecord::TestCase ActiveRecord::SchemaDumper.ignore_tables = [/^[^r]/] ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) output = stream.string - assert_match %r{:null => false}, output + assert_match %r{null: false}, output end def test_schema_dump_includes_limit_constraint_for_integer_columns @@ -107,46 +107,46 @@ class SchemaDumperTest < ActiveRecord::TestCase output = stream.string if current_adapter?(:PostgreSQLAdapter) - assert_match %r{c_int_1.*:limit => 2}, output - assert_match %r{c_int_2.*:limit => 2}, output + assert_match %r{c_int_1.*limit: 2}, output + assert_match %r{c_int_2.*limit: 2}, output # int 3 is 4 bytes in postgresql assert_match %r{c_int_3.*}, output - assert_no_match %r{c_int_3.*:limit}, output + assert_no_match %r{c_int_3.*limit:}, output assert_match %r{c_int_4.*}, output - assert_no_match %r{c_int_4.*:limit}, output + assert_no_match %r{c_int_4.*limit:}, output elsif current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output + assert_match %r{c_int_1.*limit: 1}, output + assert_match %r{c_int_2.*limit: 2}, output + assert_match %r{c_int_3.*limit: 3}, output assert_match %r{c_int_4.*}, output assert_no_match %r{c_int_4.*:limit}, output elsif current_adapter?(:SQLite3Adapter) - assert_match %r{c_int_1.*:limit => 1}, output - assert_match %r{c_int_2.*:limit => 2}, output - assert_match %r{c_int_3.*:limit => 3}, output - assert_match %r{c_int_4.*:limit => 4}, output + assert_match %r{c_int_1.*limit: 1}, output + assert_match %r{c_int_2.*limit: 2}, output + assert_match %r{c_int_3.*limit: 3}, output + assert_match %r{c_int_4.*limit: 4}, output end assert_match %r{c_int_without_limit.*}, output - assert_no_match %r{c_int_without_limit.*:limit}, output + assert_no_match %r{c_int_without_limit.*limit:}, output if current_adapter?(:SQLite3Adapter) - assert_match %r{c_int_5.*:limit => 5}, output - assert_match %r{c_int_6.*:limit => 6}, output - assert_match %r{c_int_7.*:limit => 7}, output - assert_match %r{c_int_8.*:limit => 8}, output + assert_match %r{c_int_5.*limit: 5}, output + assert_match %r{c_int_6.*limit: 6}, output + assert_match %r{c_int_7.*limit: 7}, output + assert_match %r{c_int_8.*limit: 8}, output elsif current_adapter?(:OracleAdapter) - assert_match %r{c_int_5.*:limit => 5}, output - assert_match %r{c_int_6.*:limit => 6}, output - assert_match %r{c_int_7.*:limit => 7}, output - assert_match %r{c_int_8.*:limit => 8}, output + assert_match %r{c_int_5.*limit: 5}, output + assert_match %r{c_int_6.*limit: 6}, output + assert_match %r{c_int_7.*limit: 7}, output + assert_match %r{c_int_8.*limit: 8}, output else - assert_match %r{c_int_5.*:limit => 8}, output - assert_match %r{c_int_6.*:limit => 8}, output - assert_match %r{c_int_7.*:limit => 8}, output - assert_match %r{c_int_8.*:limit => 8}, output + assert_match %r{c_int_5.*limit: 8}, output + assert_match %r{c_int_6.*limit: 8}, output + assert_match %r{c_int_7.*limit: 8}, output + assert_match %r{c_int_8.*limit: 8}, output end end @@ -182,15 +182,15 @@ class SchemaDumperTest < ActiveRecord::TestCase def test_schema_dumps_index_columns_in_right_order index_definition = standard_dump.split(/\n/).grep(/add_index.*companies/).first.strip - assert_equal 'add_index "companies", ["firm_id", "type", "rating"], :name => "company_index"', index_definition + assert_equal 'add_index "companies", ["firm_id", "type", "rating"], name: "company_index"', index_definition end def test_schema_dumps_partial_indices index_definition = standard_dump.split(/\n/).grep(/add_index.*company_partial_index/).first.strip if current_adapter?(:PostgreSQLAdapter) - assert_equal 'add_index "companies", ["firm_id", "type"], :name => "company_partial_index", :where => "(rating > 10)"', index_definition + assert_equal 'add_index "companies", ["firm_id", "type"], name: "company_partial_index", where: "(rating > 10)"', index_definition else - assert_equal 'add_index "companies", ["firm_id", "type"], :name => "company_partial_index"', index_definition + assert_equal 'add_index "companies", ["firm_id", "type"], name: "company_partial_index"', index_definition end end @@ -198,25 +198,25 @@ class SchemaDumperTest < ActiveRecord::TestCase output = standard_dump match = output.match(%r{create_table "movies"(.*)do}) assert_not_nil(match, "nonstandardpk table not found") - assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" + assert_match %r(primary_key: "movieid"), match[1], "non-standard primary key not preserved" end if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter) def test_schema_dump_should_not_add_default_value_for_mysql_text_field output = standard_dump - assert_match %r{t.text\s+"body",\s+:null => false$}, output + assert_match %r{t.text\s+"body",\s+null: false$}, output end def test_schema_dump_includes_length_for_mysql_blob_and_text_fields output = standard_dump - assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output + assert_match %r{t.binary\s+"tiny_blob",\s+limit: 255$}, output assert_match %r{t.binary\s+"normal_blob"$}, output - assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output - assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output - assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output + assert_match %r{t.binary\s+"medium_blob",\s+limit: 16777215$}, output + assert_match %r{t.binary\s+"long_blob",\s+limit: 2147483647$}, output + assert_match %r{t.text\s+"tiny_text",\s+limit: 255$}, output assert_match %r{t.text\s+"normal_text"$}, output - assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output - assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output + assert_match %r{t.text\s+"medium_text",\s+limit: 16777215$}, output + assert_match %r{t.text\s+"long_text",\s+limit: 2147483647$}, output end end @@ -225,7 +225,7 @@ class SchemaDumperTest < ActiveRecord::TestCase ActiveRecord::SchemaDumper.ignore_tables = [/^[^n]/] ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) output = stream.string - assert_match %r{:precision => 3,[[:space:]]+:scale => 2,[[:space:]]+:default => 2.78}, output + assert_match %r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default: 2.78}, output end if current_adapter?(:PostgreSQLAdapter) @@ -239,7 +239,7 @@ class SchemaDumperTest < ActiveRecord::TestCase def test_schema_dump_includes_json_shorthand_definition output = standard_dump if %r{create_table "postgresql_json_data_type"} =~ output - assert_match %r|t.json "json_data", :default => {}|, output + assert_match %r|t.json "json_data", default: {}|, output end end @@ -274,7 +274,7 @@ class SchemaDumperTest < ActiveRecord::TestCase def test_schema_dump_includes_hstores_shorthand_definition output = standard_dump if %r{create_table "postgresql_hstores"} =~ output - assert_match %r[t.hstore "hash_store", :default => {}], output + assert_match %r[t.hstore "hash_store", default: {}], output end end @@ -290,9 +290,9 @@ class SchemaDumperTest < ActiveRecord::TestCase output = standard_dump # Oracle supports precision up to 38 and it identifies decimals with scale 0 as integers if current_adapter?(:OracleAdapter) - assert_match %r{t.integer\s+"atoms_in_universe",\s+:precision => 38,\s+:scale => 0}, output + assert_match %r{t.integer\s+"atoms_in_universe",\s+precision: 38,\s+scale: 0}, output else - assert_match %r{t.decimal\s+"atoms_in_universe",\s+:precision => 55,\s+:scale => 0}, output + assert_match %r{t.decimal\s+"atoms_in_universe",\s+precision: 55,\s+scale: 0}, output end end @@ -300,13 +300,13 @@ class SchemaDumperTest < ActiveRecord::TestCase output = standard_dump match = output.match(%r{create_table "goofy_string_id"(.*)do.*\n(.*)\n}) assert_not_nil(match, "goofy_string_id table not found") - assert_match %r(:id => false), match[1], "no table id not preserved" - assert_match %r{t.string[[:space:]]+"id",[[:space:]]+:null => false$}, match[2], "non-primary key id column not preserved" + assert_match %r(id: false), match[1], "no table id not preserved" + assert_match %r{t.string[[:space:]]+"id",[[:space:]]+null: false$}, match[2], "non-primary key id column not preserved" end def test_schema_dump_keeps_id_false_when_id_is_false_and_unique_not_null_column_added output = standard_dump - assert_match %r{create_table "subscribers", :id => false}, output + assert_match %r{create_table "subscribers", id: false}, output end class CreateDogMigration < ActiveRecord::Migration |