Sha256: 110fb33c38d022187ee15f17c0c342fb652786ddb717deda4daee1709e5631fa

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe PaperTrail::Version do
  it "should include the `VersionConcern` module to get base functionality" do
    PaperTrail::Version.should include(PaperTrail::VersionConcern)
  end

  describe "Attributes" do
    it { should have_db_column(:item_type).of_type(:string) }
    it { should have_db_column(:item_id).of_type(:integer) }
    it { should have_db_column(:event).of_type(:string) }
    it { should have_db_column(:whodunnit).of_type(:string) }
    it { should have_db_column(:object).of_type(:text) }
    it { should have_db_column(:created_at).of_type(:datetime) }
  end

  describe "Indexes" do
    it { should have_db_index([:item_type, :item_id]) }
  end

  describe "Methods" do
    describe "Instance" do
      subject { PaperTrail::Version.new(attributes) rescue PaperTrail::Version.new }

      describe :terminator do
        it { should respond_to(:terminator) }

        let(:attributes) { {:whodunnit => Faker::Name.first_name} }

        it "is an alias for the `whodunnit` attribute" do
          subject.whodunnit.should == attributes[:whodunnit]
        end
      end

      describe :version_author do
        it { should respond_to(:version_author) }

        it "should be an alias for the `terminator` method" do
          subject.method(:version_author).should == subject.method(:terminator)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paper_trail-3.0.2 spec/models/version_spec.rb
paper_trail-3.0.1 spec/models/version_spec.rb
paper_trail-3.0.0 spec/models/version_spec.rb
paper_trail-3.0.0.rc2 spec/models/version_spec.rb