Skip to content

Commit

Permalink
Fix up test altering global state that was causing me grief
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Dec 1, 2011
1 parent 3a40d38 commit 47b97a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions activerecord/test/cases/locking_test.rb
Expand Up @@ -320,6 +320,8 @@ def test_destroy_dependents
assert_equal true, p1.frozen?
assert_raises(ActiveRecord::RecordNotFound) { Person.find(p1.id) }
assert_raises(ActiveRecord::RecordNotFound) { LegacyThing.find(t.id) }
ensure
remove_counter_column_from(Person, 'legacy_things_count')
end

private
Expand All @@ -331,8 +333,8 @@ def add_counter_column_to(model, col='test_count')
model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter)
end

def remove_counter_column_from(model)
model.connection.remove_column model.table_name, :test_count
def remove_counter_column_from(model, col = :test_count)
model.connection.remove_column model.table_name, col
model.reset_column_information
end

Expand Down

0 comments on commit 47b97a7

Please sign in to comment.