From 4a0347368d002f81a55f02fdee9d5e39166ad63c Mon Sep 17 00:00:00 2001 From: Tim Breitkreutz Date: Wed, 11 Nov 2015 16:18:42 -0800 Subject: TWB Test case for Issue #9015 - ignore_table and table_prefix at same time --- activerecord/test/cases/schema_dumper_test.rb | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'activerecord/test') 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 -- cgit v1.2.3