aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/schema_dumper_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-06-20 14:08:23 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-17 10:42:01 -0300
commite23ec4c79c7f402f3d306771616c1d597132e2fa (patch)
tree440ed5f0ef7affb6bbea5d803c7c4d91adf833b7 /activerecord/test/cases/schema_dumper_test.rb
parentb3693bf2f827789a8b1ef5e0a3f653ed58089b1e (diff)
downloadrails-e23ec4c79c7f402f3d306771616c1d597132e2fa.tar.gz
rails-e23ec4c79c7f402f3d306771616c1d597132e2fa.tar.bz2
rails-e23ec4c79c7f402f3d306771616c1d597132e2fa.zip
Merge pull request #4396 from kennyj/fix_4259
Fix GH #4259. When we execute schema dumper, we must remove table_name_prefix and table_name_suffix.
Diffstat (limited to 'activerecord/test/cases/schema_dumper_test.rb')
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb32
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 5c3a78688e..0a9643b7e0 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -243,4 +243,36 @@ class SchemaDumperTest < ActiveRecord::TestCase
output = standard_dump
assert_match %r{create_table "subscribers", :id => false}, output
end
+
+ class CreateDogMigration < ActiveRecord::Migration
+ def up
+ create_table("dogs") do |t|
+ t.column :name, :string
+ end
+ add_index "dogs", [:name]
+ end
+ def down
+ drop_table("dogs")
+ end
+ end
+
+ def test_schema_dump_with_table_name_prefix_and_suffix
+ original, $stdout = $stdout, StringIO.new
+ ActiveRecord::Base.table_name_prefix = 'foo_'
+ ActiveRecord::Base.table_name_suffix = '_bar'
+
+ migration = CreateDogMigration.new
+ migration.migrate(:up)
+
+ output = standard_dump
+ assert_no_match %r{create_table "foo_.+_bar"}, output
+ assert_no_match %r{create_index "foo_.+_bar"}, output
+ assert_no_match %r{create_table "schema_migrations"}, output
+ ensure
+ migration.migrate(:down)
+
+ ActiveRecord::Base.table_name_suffix = ActiveRecord::Base.table_name_prefix = ''
+ $stdout = original
+ end
+
end