diff options
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/validations_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index dc8541c574..f3d9e20360 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -850,7 +850,7 @@ module ActiveRecord # so an exception is raised if the record is invalid. def create!(attributes = nil) if attributes.is_a?(Array) - attributes.collect { |attr| create(attr) } + attributes.collect { |attr| create!(attr) } else object = new(attributes) object.save! diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index 19bca29fd8..847e11a747 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -95,6 +95,12 @@ class ValidationsTest < Test::Unit::TestCase end end + def test_exception_on_create_bang_many + assert_raises(ActiveRecord::RecordInvalid) do + Reply.create!([ { "title" => "OK" }, { "title" => "Wrong Create" }]) + end + end + def test_scoped_create_without_attributes Reply.with_scope(:create => {}) do assert_raises(ActiveRecord::RecordInvalid) { Reply.create! } |