Skip to content
Browse files

adding a test for create! with invalid associations

  • Loading branch information...
1 parent 0df8830 commit 964338777d183fdbf408a09ae6d7426ac8aaf96c @tenderlove tenderlove committed
Showing with 9 additions and 0 deletions.
  1. +9 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
View
9 activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -773,4 +773,13 @@ def test_create_should_not_raise_exception_when_join_record_has_errors
Category.create(:name => 'Fishing', :authors => [Author.first])
end
end
+
+ def test_create_bang_should_raise_exception_when_join_record_has_errors
+ repair_validations(Categorization) do
+ Categorization.validate { |r| r.errors[:base] << 'Invalid Categorization' }
+ assert_raises(ActiveRecord::RecordInvalid) do
+ Category.create!(:name => 'Fishing', :authors => [Author.first])
+ end
+ end
+ end
end

0 comments on commit 9643387

Please sign in to comment.
Something went wrong with that request. Please try again.