Last active
May 17, 2016 17:33
-
-
Save md5/8dd14bd20d0ee532f79c8be59500098e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.2.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Use this template to report PaperTrail bugs. | |
# It is based on the ActiveRecord template. | |
# https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
ruby "2.2.4" | |
source "https://rubygems.org" | |
gem "activerecord", "5.0.0.rc1" | |
gem "minitest", "5.8.3" | |
gem "paper_trail", "4.1.0", require: false | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.belongs_to_required_by_default = true | |
ActiveRecord::Schema.define do | |
create_table :users, force: true do |t| | |
t.text :first_name, null: false | |
t.timestamps null: false | |
end | |
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 | |
add_index :versions, [:item_type, :item_id] | |
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] | |
add_index :version_associations, [:foreign_key_name, :foreign_key_id], | |
name: "index_version_associations_on_foreign_key" | |
end | |
# Require `paper_trail.rb` after the `version_associations` table | |
# exists so that PT will track associations. | |
require "paper_trail" | |
# Include your models here. Please only include the minimum code necessary to | |
# reproduce your issue. | |
class User < ActiveRecord::Base | |
has_paper_trail | |
end | |
# Please write a test that demonstrates your issue by failing. | |
class BugTest < ActiveSupport::TestCase | |
def test_1 | |
assert_difference(-> { PaperTrail::Version.count }, +2) { | |
user = User.create(first_name: "Jane") | |
user.destroy | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment