提交 47b97a73 编写于 作者: J Jon Leighton

Fix up test altering global state that was causing me grief

上级 3a40d386
...@@ -320,6 +320,8 @@ def test_destroy_dependents ...@@ -320,6 +320,8 @@ def test_destroy_dependents
assert_equal true, p1.frozen? assert_equal true, p1.frozen?
assert_raises(ActiveRecord::RecordNotFound) { Person.find(p1.id) } assert_raises(ActiveRecord::RecordNotFound) { Person.find(p1.id) }
assert_raises(ActiveRecord::RecordNotFound) { LegacyThing.find(t.id) } assert_raises(ActiveRecord::RecordNotFound) { LegacyThing.find(t.id) }
ensure
remove_counter_column_from(Person, 'legacy_things_count')
end end
private private
...@@ -331,8 +333,8 @@ def add_counter_column_to(model, col='test_count') ...@@ -331,8 +333,8 @@ def add_counter_column_to(model, col='test_count')
model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter) model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter)
end end
def remove_counter_column_from(model) def remove_counter_column_from(model, col = :test_count)
model.connection.remove_column model.table_name, :test_count model.connection.remove_column model.table_name, col
model.reset_column_information model.reset_column_information
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册