提交 47f39d26 编写于 作者: F Franck Verrot 提交者: Aaron Patterson

Testing that dup is resetting the timestamps

上级 8624065b
......@@ -51,7 +51,12 @@ def test_dup_with_changes
topic.attributes = dbtopic.attributes
#duped has no timestamp values
duped = dbtopic.dup
#clear topic timestamp values
topic.send(:clear_timestamp_attributes)
assert_equal topic.changes, duped.changes
end
......@@ -75,5 +80,24 @@ def test_dup_attributes_are_independent
assert_equal 'Aaron', topic.author_name
assert_equal 'meow', duped.author_name
end
def test_dup_timestamps_are_cleared
topic = Topic.first
assert_not_nil topic.updated_at
assert_not_nil topic.created_at
# temporary change to the topic object
topic.updated_at -= 3.days
#dup should not preserve the timestamps if present
new_topic = topic.dup
assert_nil new_topic.updated_at
assert_nil new_topic.created_at
new_topic.save
assert_not_nil new_topic.updated_at
assert_not_nil new_topic.created_at
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册