diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-27 14:48:08 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-27 14:48:08 -0700 |
commit | 1ec1eb2ff2ad5de70db7a632b93641a06a623a42 (patch) | |
tree | 00d5be491a2970fa2b5a7718d8eb4e5d76b82e6a /activerecord/test/cases/nested_attributes_test.rb | |
parent | 930dbbbcff71dfb1818549ea936aabe91cc357a6 (diff) | |
parent | 206d9a74908fcdd7c85dc05877e6ea2a7a8d8a38 (diff) | |
download | rails-1ec1eb2ff2ad5de70db7a632b93641a06a623a42.tar.gz rails-1ec1eb2ff2ad5de70db7a632b93641a06a623a42.tar.bz2 rails-1ec1eb2ff2ad5de70db7a632b93641a06a623a42.zip |
Merge pull request #7460 from frodsan/fix_nested_attributes_test
ensures that the test repairs the validation setup
Diffstat (limited to 'activerecord/test/cases/nested_attributes_test.rb')
-rw-r--r-- | activerecord/test/cases/nested_attributes_test.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index 725cff8f01..07862ca4ca 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -771,9 +771,9 @@ module NestedAttributesOnACollectionAssociationTests assert !man.errors[:"interests.man"].empty? end end - # restore :inverse_of + ensure Man.reflect_on_association(:interests).options[:inverse_of] = :man - Interest.reflect_on_association(:man).options[:inverse_of] = :interests + Interest.reflect_on_association(:man).options[:inverse_of] = :interests end def test_can_use_symbols_as_object_identifier @@ -783,12 +783,14 @@ module NestedAttributesOnACollectionAssociationTests def test_numeric_colum_changes_from_zero_to_no_empty_string Man.accepts_nested_attributes_for(:interests) - Interest.validates_numericality_of(:zine_id) - man = Man.create(:name => 'John') - interest = man.interests.create(:topic=>'bar',:zine_id => 0) - assert interest.save - assert !man.update_attributes({:interests_attributes => { :id => interest.id, :zine_id => 'foo' }}) + repair_validations(Interest) do + Interest.validates_numericality_of(:zine_id) + man = Man.create(name: 'John') + interest = man.interests.create(topic: 'bar', zine_id: 0) + assert interest.save + assert !man.update_attributes({interests_attributes: { id: interest.id, zine_id: 'foo' }}) + end end private |