Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
2 parents 8c3a6f8 + 0a558b3 commit b68ef73344003949e302d784ff3cca6a95192ce0 @miloops miloops committed Aug 11, 2009
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
View
18 activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -199,6 +199,24 @@ def test_associate_with_create_bang_and_valid_options
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) }

0 comments on commit b68ef73

Please sign in to comment.