From 7f140bbddaf70abc61570f6cfdcbfba5771ffc78 Mon Sep 17 00:00:00 2001 From: Jan De Poorter Date: Wed, 11 Jun 2008 13:08:35 +0200 Subject: Add :validate option to associations. [#301 state:resolved] Signed-off-by: Pratik Naik --- .../test/cases/associations/has_many_associations_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index dbfa025efb..1f23ff256c 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -342,6 +342,17 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert new_firm.new_record? end + def test_invalid_adding_with_validate_false + firm = Firm.find(:first) + client = Client.new + firm.unvalidated_clients_of_firm << Client.new + + assert firm.valid? + assert !client.valid? + assert firm.save + assert client.new_record? + end + def test_build company = companies(:first_firm) new_client = assert_no_queries { company.clients_of_firm.build("name" => "Another Client") } -- cgit v1.2.3