Skip to content
Browse files

Reset table_name_{prefix,suffix}, and table_name after each test

because some tests were not resetting them, and thus the tests were order dependent
  • Loading branch information...
1 parent 59e2630 commit 2c613f9d370d5de9eef22d57ba0e6a796579df3f @amatsuda amatsuda committed Jan 9, 2013
Showing with 4 additions and 11 deletions.
  1. +4 −11 activerecord/test/cases/migration_test.rb
View
15 activerecord/test/cases/migration_test.rb
@@ -33,6 +33,9 @@ def setup
end
def teardown
+ ActiveRecord::Base.table_name_prefix = ""
+ ActiveRecord::Base.table_name_suffix = ""
+
ActiveRecord::Base.connection.initialize_schema_migrations_table
ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}"
@@ -44,6 +47,7 @@ def teardown
%w(reminders people_reminders prefix_reminders_suffix).each do |table|
Reminder.connection.drop_table(table) rescue nil
end
+ Reminder.reset_table_name
Reminder.reset_column_information
%w(last_name key bio age height wealth birthday favorite_day
@@ -257,9 +261,6 @@ def test_schema_migrations_table_name
ActiveRecord::Base.table_name_suffix = ""
Reminder.reset_table_name
assert_equal "schema_migrations", ActiveRecord::Migrator.schema_migrations_table_name
- ensure
- ActiveRecord::Base.table_name_prefix = ""
- ActiveRecord::Base.table_name_suffix = ""
end
def test_proper_table_name
@@ -286,9 +287,6 @@ def test_proper_table_name
Reminder.reset_table_name
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name('table')
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name(:table)
- ActiveRecord::Base.table_name_prefix = ""
- ActiveRecord::Base.table_name_suffix = ""
- Reminder.reset_table_name
end
def test_rename_table_with_prefix_and_suffix
@@ -307,8 +305,6 @@ def test_rename_table_with_prefix_and_suffix
assert_equal "hello world", Thing.first.content
ensure
- ActiveRecord::Base.table_name_prefix = ''
- ActiveRecord::Base.table_name_suffix = ''
Thing.reset_table_name
Thing.reset_sequence_name
end
@@ -326,9 +322,6 @@ def test_add_drop_table_with_prefix_and_suffix
WeNeedReminders.down
assert_raise(ActiveRecord::StatementInvalid) { Reminder.first }
ensure
- ActiveRecord::Base.table_name_prefix = ''
- ActiveRecord::Base.table_name_suffix = ''
- Reminder.reset_table_name
Reminder.reset_sequence_name
end

0 comments on commit 2c613f9

Please sign in to comment.
Something went wrong with that request. Please try again.