Skip to content

Commit

Permalink
adding a test for create! with invalid associations
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 24, 2011
1 parent 0df8830 commit 9643387
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.