From dedb946bfb940ece65064175f09ed55815768ec6 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 30 Jan 2015 09:26:03 -0700 Subject: 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. --- activerecord/test/cases/autosave_association_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord') 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 -- cgit v1.2.3