Sha256: 53a01cc38f09aeb7241ea62e92960e62d071bdfa7446c00e13704a40d69d69d3

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require "spec_helper"

module PaperTrail
  ::RSpec.describe Config do
    describe ".instance" do
      it "returns the singleton instance" do
        expect { described_class.instance }.not_to raise_error
      end
    end

    describe ".new" do
      it "raises NoMethodError" do
        expect { described_class.new }.to raise_error(NoMethodError)
      end
    end

    describe "track_associations?" do
      context "@track_associations is nil" do
        after do
          PaperTrail.config.track_associations = true
        end

        it "returns false and prints a deprecation warning" do
          config = described_class.instance
          config.track_associations = nil
          expect {
            expect(config.track_associations?).to eq(false)
          }.to output(/DEPRECATION WARNING/).to_stderr
        end
      end
    end

    describe ".version_limit", versioning: true do
      after { PaperTrail.config.version_limit = nil }

      it "limits the number of versions to 3 (2 plus the created at event)" do
        PaperTrail.config.version_limit = 2
        widget = Widget.create!(name: "Henry")
        6.times { widget.update_attribute(:name, FFaker::Lorem.word) }
        expect(widget.versions.first.event).to(eq("create"))
        expect(widget.versions.size).to(eq(3))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paper_trail-7.1.0 spec/paper_trail/config_spec.rb