From 85465ed3e6c582d25f0c8fafe21f7a2c182c2f67 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 30 Jan 2015 07:26:33 -0700 Subject: Always perform validations on nested attribute associations Collection associations would have already been validated, but singular associations were not. Fixes #18735. --- activerecord/test/cases/nested_attributes_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index a9e93ad1b6..198cd6f341 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -1047,4 +1047,11 @@ class TestHasManyAutosaveAssociationWhichItselfHasAutosaveAssociations < ActiveR ship.save! end end + + test "nested singular associations are validated" do + part = ShipPart.new(name: "Stern", ship_attributes: { name: nil }) + + assert_not part.valid? + assert_equal ["Ship name can't be blank"], part.errors.full_messages + end end -- cgit v1.2.3