diff options
author | Tim Breitkreutz <tim@generalthings.com> | 2015-11-11 16:18:42 -0800 |
---|---|---|
committer | Tim Breitkreutz <tim@generalthings.com> | 2015-11-13 08:25:07 -0800 |
commit | 4a0347368d002f81a55f02fdee9d5e39166ad63c (patch) | |
tree | 2a45486fc2830ddfc11d0f8d7baeac970ab84215 | |
parent | c83d1e5508b27d810e37f11cec036a69697d26b8 (diff) | |
download | rails-4a0347368d002f81a55f02fdee9d5e39166ad63c.tar.gz rails-4a0347368d002f81a55f02fdee9d5e39166ad63c.tar.bz2 rails-4a0347368d002f81a55f02fdee9d5e39166ad63c.zip |
TWB 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..677b5dbdf3 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 + + class CreateCatMigration < ActiveRecord::Migration + def change + create_table("cats") do |t| + end + create_table("fu_cats") do |t| + end + end + end + + def test_schema_dump_with_table_name_prefix_and_ignoring_tables + original, $stdout = $stdout, StringIO.new + + original_table_name_prefix = ActiveRecord::Base.table_name_prefix + original_schema_dumper_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables + ActiveRecord::Base.table_name_prefix = 'fu_' + ActiveRecord::SchemaDumper.ignore_tables = ["cats"] + migration = CreateCatMigration.new + migration.migrate(:up) + + stream = StringIO.new + output = ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream).string + + assert_match %r{create_table "fu_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 |