mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Add rspec for concern
This commit is contained in:
parent
1f5f8493b7
commit
00bf38ff1e
1 changed files with 46 additions and 0 deletions
|
@ -1,5 +1,51 @@
|
|||
require 'spec_helper'
|
||||
|
||||
module Foo
|
||||
class Base < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
|
||||
class Document < Base
|
||||
has_paper_trail :class_name => 'Foo::Version'
|
||||
end
|
||||
|
||||
class Version < Base
|
||||
include PaperTrail::VersionConcern
|
||||
end
|
||||
end
|
||||
Foo::Base.establish_connection(:adapter => 'sqlite3', :database => File.expand_path('../../../test/dummy/db/test-foo.sqlite3', __FILE__))
|
||||
|
||||
module Bar
|
||||
class Base < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
|
||||
class Document < Base
|
||||
has_paper_trail :class_name => 'Bar::Version'
|
||||
end
|
||||
|
||||
class Version < Base
|
||||
include PaperTrail::VersionConcern
|
||||
end
|
||||
end
|
||||
Bar::Base.establish_connection(:adapter => 'sqlite3', :database => File.expand_path('../../../test/dummy/db/test-bar.sqlite3', __FILE__))
|
||||
|
||||
describe PaperTrail::VersionConcern do
|
||||
it 'allows included class to have different connections' do
|
||||
Foo::Version.connection.should_not eq Bar::Version.connection
|
||||
end
|
||||
|
||||
it 'allows custom version class to share connection with superclass' do
|
||||
Foo::Version.connection.should eq Foo::Document.connection
|
||||
Bar::Version.connection.should eq Bar::Document.connection
|
||||
end
|
||||
|
||||
it 'can be used with class_name option' do
|
||||
Foo::Document.version_class_name.should eq 'Foo::Version'
|
||||
Bar::Document.version_class_name.should eq 'Bar::Version'
|
||||
end
|
||||
end
|
||||
|
||||
describe PaperTrail::Version do
|
||||
describe "Attributes" do
|
||||
it { should have_db_column(:item_type).of_type(:string) }
|
||||
|
|
Loading…
Reference in a new issue