Fix a state leak in `autosave_association_test`

The test added in 85465ed3e6 was passing
when the file was run on its own, but failing when the entire suite was
run since this test modifies the class and doesn't clean up.
This commit is contained in:
Sean Griffin 2015-01-30 09:26:03 -07:00
parent 77f6b10906
commit a078cbd959
1 changed files with 5 additions and 0 deletions

View File

@ -1044,11 +1044,16 @@ class TestAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCase
end
def test_should_not_ignore_different_error_messages_on_the_same_attribute
old_validators = Ship._validators.deep_dup
old_callbacks = Ship._validate_callbacks.deep_dup
Ship.validates_format_of :name, :with => /\w/
@pirate.ship.name = ""
@pirate.catchphrase = nil
assert @pirate.invalid?
assert_equal ["can't be blank", "is invalid"], @pirate.errors[:"ship.name"]
ensure
Ship._validators = old_validators if old_validators
Ship._validate_callbacks = old_callbacks if old_callbacks
end
def test_should_still_allow_to_bypass_validations_on_the_associated_model