test/undo_test.rb in mongoid-undo-0.7.0 vs test/undo_test.rb in mongoid-undo-0.8.0
- old
+ new
@@ -12,10 +12,18 @@
include Mongoid::Undo
field :language, localize: true, type: String
end
+class Timestamped
+ include Mongoid::Document
+ include Mongoid::Undo
+ include Mongoid::Timestamps
+
+ field :name, type: String
+end
+
class UndoTest < Minitest::Test
def test_create
document = Document.create(name: 'foo')
assert_equal :create, document.action
assert_equal 1, document.version
@@ -84,7 +92,22 @@
document.undo
assert_equal 'English', document.language
document.redo
assert_equal 'English Updated', document.language
+ end
+
+
+ def test_updated_at_timestamp
+ document = Timestamped.create(name: 'foo')
+ updated_at = document.updated_at
+
+ document.update_attributes(name: 'bar')
+ assert_not_equal updated_at, document.updated_at
+
+ document.undo
+ assert_not_equal updated_at, document.updated_at
+
+ document.redo
+ assert_not_equal updated_at, document.updated_at
end
end