2011-02-08 12:16:35 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class PaperTrailTest < ActiveSupport::TestCase
|
|
|
|
test 'Sanity test' do
|
2013-05-29 17:19:05 -04:00
|
|
|
assert_kind_of Module, PaperTrail::Version
|
2011-02-08 12:16:35 -05:00
|
|
|
end
|
2011-04-06 20:21:57 -04: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 17:19:05 -04:00
|
|
|
versions_for_widget = PaperTrail::Version.with_item_keys('Widget', widget.id)
|
2011-04-06 20:21:57 -04:00
|
|
|
assert_equal 2, versions_for_widget.length
|
|
|
|
end
|
2011-02-08 12:16:35 -05:00
|
|
|
end
|