diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-16 17:00:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-16 17:00:14 -0400 |
commit | 7c839024458b1d3d912f1eee3f38691d710ebf1e (patch) | |
tree | 58c7b27738338960e946268a4d08770822ef0abd /activerecord/test/cases/schema_dumper_test.rb | |
parent | 02c25c3cd419e93fc3882155611a4f8aa757ff3a (diff) | |
parent | b49c6dcecd08941e0baa2edea922f838f099780d (diff) | |
download | rails-7c839024458b1d3d912f1eee3f38691d710ebf1e.tar.gz rails-7c839024458b1d3d912f1eee3f38691d710ebf1e.tar.bz2 rails-7c839024458b1d3d912f1eee3f38691d710ebf1e.zip |
Merge pull request #30048 from yahonda/regexp_aware_schema_dumper_prefix_suffix
Allow `table_name_prefix` and `table_name_suffix` have `$`
Diffstat (limited to 'activerecord/test/cases/schema_dumper_test.rb')
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 01ec3e06ad..eb9b257da9 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -400,6 +400,31 @@ class SchemaDumperTest < ActiveRecord::TestCase $stdout = original end + def test_schema_dump_with_table_name_prefix_and_suffix_regexp_escape + original, $stdout = $stdout, StringIO.new + ActiveRecord::Base.table_name_prefix = "foo$" + ActiveRecord::Base.table_name_suffix = "$bar" + + migration = CreateDogMigration.new + migration.migrate(:up) + + output = perform_schema_dump + assert_no_match %r{create_table "foo\$.+\$bar"}, output + assert_no_match %r{add_index "foo\$.+\$bar"}, output + assert_no_match %r{create_table "schema_migrations"}, output + assert_no_match %r{create_table "ar_internal_metadata"}, output + + if ActiveRecord::Base.connection.supports_foreign_keys? + assert_no_match %r{add_foreign_key "foo\$.+\$bar"}, output + assert_no_match %r{add_foreign_key "[^"]+", "foo\$.+\$bar"}, output + end + ensure + migration.migrate(:down) + + 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 |