2013-10-11 10:42:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-10-29 11:57:41 -04:00
|
|
|
describe PaperTrail::Version do
|
|
|
|
it "should include the `VersionConcern` module to get base functionality" do
|
|
|
|
PaperTrail::Version.should include(PaperTrail::VersionConcern)
|
2013-10-22 13:12:08 -04:00
|
|
|
end
|
|
|
|
|
2013-10-11 10:42:12 -04:00
|
|
|
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
|
2013-11-12 18:06:56 -05:00
|
|
|
it { should respond_to(:version_author) }
|
2013-10-11 10:42:12 -04:00
|
|
|
|
|
|
|
it "should be an alias for the `terminator` method" do
|
|
|
|
subject.method(:version_author).should == subject.method(:terminator)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|