提交 526f1e5f 编写于 作者: J James Le Cuirot 提交者: José Valim

Don't remove scheduled destroys when loading an association.

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 f8f4872f
......@@ -352,7 +352,12 @@ def load_target
@target = find_target.map do |f|
i = @target.index(f)
t = @target.delete_at(i) if i
(t && t.changed?) ? t : f
if t && t.changed?
t
else
f.mark_for_destruction if t && t.marked_for_destruction?
f
end
end + @target
else
@target = find_target
......
......@@ -488,6 +488,12 @@ def test_should_refresh_saved_records_when_not_overwriting_unsaved_updates
assert_equal 'Polly', @pirate.send(@association_name).send(:load_target).last.name
end
def test_should_not_remove_scheduled_destroys_when_loading_association
@pirate.reload
@pirate.send(association_setter, [{ :id => @child_1.id, :_destroy => '1' }])
assert @pirate.send(@association_name).send(:load_target).find { |r| r.id == @child_1.id }.marked_for_destruction?
end
def test_should_take_a_hash_with_composite_id_keys_and_assign_the_attributes_to_the_associated_models
@child_1.stubs(:id).returns('ABC1X')
@child_2.stubs(:id).returns('ABC2X')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册