diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-11 12:41:49 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-11 12:41:49 -0300 |
commit | b68ef73344003949e302d784ff3cca6a95192ce0 (patch) | |
tree | de0a3f85eff416e1a5dd5d801af936d4ba25ed55 /activerecord/test/cases/associations | |
parent | 8c3a6f871eeaff1327c27b16c6d3955aaea4e555 (diff) | |
parent | 0a558b36eb3858ceeb926ada1388b0bd41da11f7 (diff) | |
download | rails-b68ef73344003949e302d784ff3cca6a95192ce0.tar.gz rails-b68ef73344003949e302d784ff3cca6a95192ce0.tar.bz2 rails-b68ef73344003949e302d784ff3cca6a95192ce0.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index a9d4d88148..5f13b66d11 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -199,6 +199,24 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_difference('firm.developers.count', 1) { firm.developers.create!(:name => 'developer') } end + def test_push_with_invalid_record + firm = companies(:first_firm) + assert_raises(ActiveRecord::RecordInvalid) { firm.developers << Developer.new(:name => '0') } + end + + def test_push_with_invalid_join_record + repair_validations(Contract) do + Contract.validate {|r| r.errors[:base] << 'Invalid Contract' } + + firm = companies(:first_firm) + lifo = Developer.new(:name => 'lifo') + assert_raises(ActiveRecord::RecordInvalid) { firm.developers << lifo } + + lifo = Developer.create!(:name => 'lifo') + assert_raises(ActiveRecord::RecordInvalid) { firm.developers << lifo } + end + end + def test_clear_associations assert_queries(2) { posts(:welcome);posts(:welcome).people(true) } |