Sha256: 8e265065d266254ef23e1b4dcb7b49ef6c270e14f27f632e192a40f8cc94024a

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require "test_helper"

class PaperTrailTest < ActiveSupport::TestCase
  test "Sanity test" do
    assert_kind_of Module, PaperTrail::Version
  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
paper_trail-5.2.0 test/paper_trail_test.rb
paper_trail-5.1.1 test/paper_trail_test.rb
paper_trail-5.1.0 test/paper_trail_test.rb
paper_trail-5.0.1 test/paper_trail_test.rb
paper_trail-5.0.0 test/paper_trail_test.rb