提交 de03c297 编写于 作者: M Matthew Draper

After find-via-reload, the record is not new

上级 a8e1538b
* After a successful `reload`, `new_record?` is always false.
Fixes #12101.
*Matthew Draper*
* PostgreSQL renaming table doesn't attempt to rename non existent sequences.
*Abdelkader Boudih*
......
......@@ -396,6 +396,7 @@ def reload(options = nil)
end
@attributes = fresh_object.instance_variable_get('@attributes')
@new_record = false
self
end
......
......@@ -865,4 +865,16 @@ def test_reload_removes_custom_selects
assert_equal 1, post[:wibble]
assert_nil post.reload[:wibble]
end
def test_find_via_reload
post = Post.new
assert post.new_record?
post.id = 1
post.reload
assert_equal "Welcome to the weblog", post.title
assert_not post.new_record?
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册