1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/test/paper_trail_test.rb

40 lines
1 KiB
Ruby
Raw Normal View History

require "test_helper"
2011-02-08 12:16:35 -05:00
class PaperTrailTest < ActiveSupport::TestCase
test "Sanity test" do
assert_kind_of Module, PaperTrail::Version
2011-02-08 12:16:35 -05:00
end
test "Version Number" do
assert PaperTrail.const_defined?(:VERSION)
end
context "setting enabled" do
should "affect all threads" do
Thread.new { PaperTrail.enabled = false }.join
assert_equal false, PaperTrail.enabled?
end
teardown { PaperTrail.enabled = true }
end
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
versions_for_widget = PaperTrail::Version.with_item_keys("Widget", widget.id)
assert_equal 2, versions_for_widget.length
end
2011-02-08 12:16:35 -05:00
end