aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/nested_attributes_test.rb
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-08-27 16:46:36 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-08-27 16:46:36 -0500
commit206d9a74908fcdd7c85dc05877e6ea2a7a8d8a38 (patch)
tree00d5be491a2970fa2b5a7718d8eb4e5d76b82e6a /activerecord/test/cases/nested_attributes_test.rb
parent930dbbbcff71dfb1818549ea936aabe91cc357a6 (diff)
downloadrails-206d9a74908fcdd7c85dc05877e6ea2a7a8d8a38.tar.gz
rails-206d9a74908fcdd7c85dc05877e6ea2a7a8d8a38.tar.bz2
rails-206d9a74908fcdd7c85dc05877e6ea2a7a8d8a38.zip
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.rb16
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