mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
adding a test for create! with invalid associations
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user