Permalink
Browse files

create! no longer blows up when no attributes are passed and a :creat…

…e scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.)

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 0cd883e commit c50113bc6110624bd411466e7c36bdde23226959 @jeremy jeremy committed May 19, 2006
View
@@ -1,5 +1,7 @@
*SVN*
+* create! no longer blows up when no attributes are passed and a :create scope is in effect (e.g. foo.bars.create! failed whereas foo.bars.create!({}) didn't.) [Jeremy Kemper]
+
* Call Inflector#demodulize on the class name when eagerly including an STI model. Closes #5077 [info@loobmedia.com]
* Preserve MySQL boolean column defaults when changing a column in a migration. Closes #5015. [pdcawley@bofh.org.uk]
@@ -712,6 +712,7 @@ def create!(attributes = nil)
if attributes.is_a?(Array)
attributes.collect { |attr| create!(attr) }
else
+ attributes ||= {}
attributes.reverse_merge!(scope(:create)) if scoped?(:create)
object = new(attributes)
@@ -88,6 +88,12 @@ def test_invalid_record_exception
end
end
+ def test_scoped_create_without_attributes
+ Reply.with_scope(:create => {}) do
+ assert_raises(ActiveRecord::RecordInvalid) { Reply.create! }
+ end
+ end
+
def test_single_error_per_attr_iteration
r = Reply.new
r.save

0 comments on commit c50113b

Please sign in to comment.