提交 2c613f9d 编写于 作者: A Akira Matsuda

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
上级 59e2630c
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册