aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-24 11:06:36 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-24 11:06:36 -0700
commit964338777d183fdbf408a09ae6d7426ac8aaf96c (patch)
tree9b13c7126c7520f8b9f78f8dbf6c2685513e9953
parent0df8830160123542cfcc00185ff7d70a05495894 (diff)
downloadrails-964338777d183fdbf408a09ae6d7426ac8aaf96c.tar.gz
rails-964338777d183fdbf408a09ae6d7426ac8aaf96c.tar.bz2
rails-964338777d183fdbf408a09ae6d7426ac8aaf96c.zip
adding a test for create! with invalid associations
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb9
1 files changed, 9 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 533a492533..a2a25b5b85 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -773,4 +773,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
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