2015-11-27 16:33:40 -05:00
|
|
|
# Use this template to report PaperTrail bugs.
|
2016-07-05 21:16:54 -04:00
|
|
|
# Please include only the minimum code necessary to reproduce your issue.
|
|
|
|
require "bundler/inline"
|
2015-11-27 16:33:40 -05:00
|
|
|
|
2016-07-05 21:16:54 -04:00
|
|
|
# STEP ONE: What versions are you using?
|
2015-11-27 16:33:40 -05:00
|
|
|
gemfile(true) do
|
2016-07-05 21:16:54 -04:00
|
|
|
ruby "2.3.1"
|
2016-03-05 17:07:32 -05:00
|
|
|
source "https://rubygems.org"
|
2016-07-05 21:16:54 -04:00
|
|
|
gem "activerecord", "5.0.0"
|
|
|
|
gem "minitest", "5.9.0"
|
|
|
|
gem "paper_trail", "5.2.0", require: false
|
2016-03-05 17:07:32 -05:00
|
|
|
gem "sqlite3"
|
2015-11-27 16:33:40 -05:00
|
|
|
end
|
|
|
|
|
2016-03-05 17:07:32 -05:00
|
|
|
require "active_record"
|
|
|
|
require "minitest/autorun"
|
|
|
|
require "logger"
|
2017-05-15 11:33:52 -04:00
|
|
|
|
|
|
|
# Please use sqlite for your bug reports, if possible.
|
2016-03-05 17:07:32 -05:00
|
|
|
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
|
2016-07-05 21:16:54 -04:00
|
|
|
ActiveRecord::Base.logger = nil
|
2015-11-27 16:33:40 -05:00
|
|
|
ActiveRecord::Schema.define do
|
2016-07-05 21:16:54 -04:00
|
|
|
# STEP TWO: Define your tables here.
|
2015-11-27 16:33:40 -05:00
|
|
|
create_table :users, force: true do |t|
|
|
|
|
t.text :first_name, null: false
|
|
|
|
t.timestamps null: false
|
|
|
|
end
|
2016-07-05 21:16:54 -04:00
|
|
|
|
2015-11-27 16:33:40 -05:00
|
|
|
create_table :versions 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, limit: 1_073_741_823
|
|
|
|
t.text :object_changes, limit: 1_073_741_823
|
|
|
|
t.integer :transaction_id
|
|
|
|
t.datetime :created_at
|
|
|
|
end
|
2017-05-21 02:40:23 -04:00
|
|
|
add_index :versions, %i[item_type item_id]
|
2015-11-27 16:33:40 -05:00
|
|
|
add_index :versions, [:transaction_id]
|
|
|
|
|
|
|
|
create_table :version_associations do |t|
|
|
|
|
t.integer :version_id
|
|
|
|
t.string :foreign_key_name, null: false
|
|
|
|
t.integer :foreign_key_id
|
|
|
|
end
|
|
|
|
add_index :version_associations, [:version_id]
|
2017-05-21 02:40:23 -04:00
|
|
|
add_index :version_associations, %i[foreign_key_name foreign_key_id],
|
2016-03-05 17:07:32 -05:00
|
|
|
name: "index_version_associations_on_foreign_key"
|
2015-11-27 16:33:40 -05:00
|
|
|
end
|
2016-07-05 21:16:54 -04:00
|
|
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
|
|
require "paper_trail/config"
|
|
|
|
|
|
|
|
# STEP THREE: Configure PaperTrail as you would in your initializer
|
|
|
|
PaperTrail::Config.instance.track_associations = true
|
2015-11-27 16:33:40 -05:00
|
|
|
|
2016-03-05 17:07:32 -05:00
|
|
|
require "paper_trail"
|
2016-01-08 01:13:09 -05:00
|
|
|
|
2016-07-05 21:16:54 -04:00
|
|
|
# STEP FOUR: Define your AR models here.
|
2015-11-27 16:33:40 -05:00
|
|
|
class User < ActiveRecord::Base
|
|
|
|
has_paper_trail
|
|
|
|
end
|
|
|
|
|
2016-07-05 21:16:54 -04:00
|
|
|
# STEP FIVE: Please write a test that demonstrates your issue.
|
2015-11-27 16:33:40 -05:00
|
|
|
class BugTest < ActiveSupport::TestCase
|
|
|
|
def test_1
|
|
|
|
assert_difference(-> { PaperTrail::Version.count }, +1) {
|
|
|
|
User.create(first_name: "Jane")
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2017-03-02 15:53:03 -05:00
|
|
|
|
|
|
|
# STEP SIX: Run this script using `ruby my_bug_report.rb`
|