Add test demonstrating namespace

Demonstrates changes to docs in
https://github.com/airblade/paper_trail/pull/559
This commit is contained in:
Jared Beck 2015-07-02 11:30:54 -04:00
parent c003ae99a4
commit 758e7e4a4b
4 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,14 @@
require 'rails_helper'
module Kitchen
describe Banana, :type => :model do
it { is_expected.to be_versioned }
describe '#versions' do
it "returns instances of Kitchen::BananaVersion", :versioning => true do
banana = described_class.create!
expect(banana.versions.first).to be_a(Kitchen::BananaVersion)
end
end
end
end

View File

@ -0,0 +1,5 @@
module Kitchen
class Banana < ActiveRecord::Base
has_paper_trail :class_name => "Kitchen::BananaVersion"
end
end

View File

@ -0,0 +1,5 @@
module Kitchen
class BananaVersion < PaperTrail::Version
self.table_name = 'banana_versions'
end
end

View File

@ -73,6 +73,20 @@ class SetUpTestTables < ActiveRecord::Migration
add_index :json_versions, [:item_type, :item_id]
end
create_table :bananas, :force => true do |t|
t.timestamps :null => true
end
create_table :banana_versions, :force => true do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
add_index :banana_versions, [:item_type, :item_id]
create_table :wotsits, :force => true do |t|
t.integer :widget_id
t.string :name