aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/autosave_association_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-30 09:26:03 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-30 09:34:40 -0700
commitdedb946bfb940ece65064175f09ed55815768ec6 (patch)
tree79615c81f68075a148eea1c1b01e705550f10055 /activerecord/test/cases/autosave_association_test.rb
parent85465ed3e6c582d25f0c8fafe21f7a2c182c2f67 (diff)
downloadrails-dedb946bfb940ece65064175f09ed55815768ec6.tar.gz
rails-dedb946bfb940ece65064175f09ed55815768ec6.tar.bz2
rails-dedb946bfb940ece65064175f09ed55815768ec6.zip
Fix a state leak in `autosave_association_test`
The test added in 85465ed3e6c582d25f0c8fafe21f7a2c182c2f67 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.
Diffstat (limited to 'activerecord/test/cases/autosave_association_test.rb')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 52765881d0..859afc4553 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -1061,11 +1061,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