diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-11-17 12:17:22 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-11-17 12:20:46 +0100 |
commit | 35ca78a07c8b09ed81f09fe227e37c59cf13bb6f (patch) | |
tree | 22e013dc32c69bf952977608a9376a76ab4a0ed0 | |
parent | 5e36c5057adf838368ab9268a1436bb9d5e41b88 (diff) | |
parent | 4a0347368d002f81a55f02fdee9d5e39166ad63c (diff) | |
download | rails-35ca78a07c8b09ed81f09fe227e37c59cf13bb6f.tar.gz rails-35ca78a07c8b09ed81f09fe227e37c59cf13bb6f.tar.bz2 rails-35ca78a07c8b09ed81f09fe227e37c59cf13bb6f.zip |
Merge pull request #22271 from timbreitkreutz/twb-9015-schema-dumper-test-for-prefix-and-ignore
Test case for Issue #9015 - ignore_table and table_prefix at same time
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 2a2c2bc8d0..43f133b12d 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -353,6 +353,38 @@ class SchemaDumperTest < ActiveRecord::TestCase ActiveRecord::Base.table_name_suffix = ActiveRecord::Base.table_name_prefix = '' $stdout = original end + + def test_schema_dump_with_table_name_prefix_and_ignoring_tables + original, $stdout = $stdout, StringIO.new + + create_cat_migration = Class.new(ActiveRecord::Migration) do + def change + create_table("cats") do |t| + end + create_table("omg_cats") do |t| + end + end + end + + original_table_name_prefix = ActiveRecord::Base.table_name_prefix + original_schema_dumper_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables + ActiveRecord::Base.table_name_prefix = 'omg_' + ActiveRecord::SchemaDumper.ignore_tables = ["cats"] + migration = create_cat_migration.new + migration.migrate(:up) + + stream = StringIO.new + output = ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream).string + + assert_match %r{create_table "omg_cats"}, output + refute_match %r{create_table "cats"}, output + ensure + migration.migrate(:down) + ActiveRecord::Base.table_name_prefix = original_table_name_prefix + ActiveRecord::SchemaDumper.ignore_tables = original_schema_dumper_ignore_tables + + $stdout = original + end end class SchemaDumperDefaultsTest < ActiveRecord::TestCase |