Add test demonstrating namespace
Demonstrates changes to docs in https://github.com/airblade/paper_trail/pull/559
This commit is contained in:
parent
c003ae99a4
commit
758e7e4a4b
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
module Kitchen
|
||||||
|
class Banana < ActiveRecord::Base
|
||||||
|
has_paper_trail :class_name => "Kitchen::BananaVersion"
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
module Kitchen
|
||||||
|
class BananaVersion < PaperTrail::Version
|
||||||
|
self.table_name = 'banana_versions'
|
||||||
|
end
|
||||||
|
end
|
|
@ -73,6 +73,20 @@ class SetUpTestTables < ActiveRecord::Migration
|
||||||
add_index :json_versions, [:item_type, :item_id]
|
add_index :json_versions, [:item_type, :item_id]
|
||||||
end
|
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|
|
create_table :wotsits, :force => true do |t|
|
||||||
t.integer :widget_id
|
t.integer :widget_id
|
||||||
t.string :name
|
t.string :name
|
||||||
|
|
Loading…
Reference in New Issue