Permalink
Browse files

Merge pull request #7460 from frodsan/fix_nested_attributes_test

ensures that the test repairs the validation setup
  • Loading branch information...
2 parents 930dbbb + 206d9a7 commit 1ec1eb2ff2ad5de70db7a632b93641a06a623a42 @rafaelfranca rafaelfranca committed Aug 27, 2012
Showing with 9 additions and 7 deletions.
  1. +9 −7 activerecord/test/cases/nested_attributes_test.rb
@@ -771,9 +771,9 @@ def test_validate_presence_of_parent_fails_without_inverse_of
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 @@ def test_can_use_symbols_as_object_identifier
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

0 comments on commit 1ec1eb2

Please sign in to comment.