2011-02-08 17:16:35 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class PaperTrailTest < ActiveSupport::TestCase
|
|
|
|
test 'Sanity test' do
|
2013-05-29 21:19:05 +00:00
|
|
|
assert_kind_of Module, PaperTrail::Version
|
2011-02-08 17:16:35 +00:00
|
|
|
end
|
2011-04-07 00:21:57 +00:00
|
|
|
|
|
|
|
test 'create with plain model class' do
|
|
|
|
widget = Widget.create
|
|
|
|
assert_equal 1, widget.versions.length
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'update with plain model class' do
|
|
|
|
widget = Widget.create
|
|
|
|
assert_equal 1, widget.versions.length
|
|
|
|
widget.update_attributes(:name => 'Bugle')
|
|
|
|
assert_equal 2, widget.versions.length
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'destroy with plain model class' do
|
|
|
|
widget = Widget.create
|
|
|
|
assert_equal 1, widget.versions.length
|
|
|
|
widget.destroy
|
2013-05-29 21:19:05 +00:00
|
|
|
versions_for_widget = PaperTrail::Version.with_item_keys('Widget', widget.id)
|
2011-04-07 00:21:57 +00:00
|
|
|
assert_equal 2, versions_for_widget.length
|
|
|
|
end
|
2011-02-08 17:16:35 +00:00
|
|
|
end
|