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
|
|
|
|
2013-12-02 10:05:19 -05:00
|
|
|
test 'Version Number' do
|
|
|
|
assert PaperTrail.const_defined?(:VERSION)
|
|
|
|
end
|
2015-05-26 15:39:09 -04:00
|
|
|
|
|
|
|
test 'enabled is thread-safe' do
|
|
|
|
Thread.new do
|
|
|
|
PaperTrail.enabled = false
|
|
|
|
end.join
|
|
|
|
assert PaperTrail.enabled?
|
|
|
|
end
|
2013-12-02 10:05:19 -05:00
|
|
|
|
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
|