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.)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
0cd883e1e1
commit
c50113bc61
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user