You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to limited volunteers, issues that do not follow these instructions will be
closed without comment.
Check the following boxes:
This is not a usage question, this is a bug report
This bug can be reproduced with the script I provide below
This bug can be reproduced in the latest release of the paper_trail gem
Due to limited volunteers, we cannot answer usage questions. Please ask such
questions on StackOverflow.
Bug reports must use the following template:
# frozen_string_literal: true# Use this template to report PaperTrail bugs.# Please include only the minimum code necessary to reproduce your issue.require"bundler/inline"# STEP ONE: What versions are you using?gemfile(true)doruby"3.2.2"source"https://rubygems.org"gem"activerecord","7.1.3"gem"minitest","5.22.0"gem"paper_trail","15.1.0",require: falsegem"sqlite3","1.7.2"endrequire"active_record"require"minitest/autorun"require"logger"# Please use sqlite for your bug reports, if possible.ActiveRecord::Base.establish_connection(adapter: "sqlite3",database: ":memory:")ActiveRecord::Base.logger=nilActiveRecord::Schema.definedo# STEP TWO: Define your tables here.create_table:users,force: truedo |t|
t.text:first_name,null: falset.timestampsnull: falseendcreate_table:versionsdo |t|
t.string:item_type,null: falset.integer:item_id,null: falset.string:event,null: falset.string:whodunnitt.text:object,limit: 1_073_741_823t.text:object_changes,limit: 1_073_741_823t.datetime:created_atendadd_index:versions,%i[item_typeitem_id]endActiveRecord::Base.logger=Logger.new(STDOUT)require"paper_trail"# STEP FOUR: Define your AR models here.classUser < ActiveRecord::Basehas_paper_trailend# STEP FIVE: Please write a test that demonstrates your issue.classBugTest < ActiveSupport::TestCasedeftest_paper_trail_logs_psych_disallowed_classuser=User.create(first_name: 'bug')# tacitly changes created_at + updated_atrefute_includesActiveRecord.yaml_column_permitted_classes,Timeassert_output(nil,PaperTrail::Version::E_YAML_PERMITTED_CLASSES % "Tried to load unspecified class: Time\n")douser.versions.last.changesetendendend# STEP SIX: Run this script using `ruby my_bug_report.rb`
This issue is because the error raised is an instance of Psych::DisallowedClass, but the check around the warning is for e.instance_of?(::Psych::Exception):
instance_of? will only respond true when the object is an instance of the exact class; what we really want is is_a? which will also respond true for any subclasses: https://stackoverflow.com/a/3893305
#1397 only tests a stub that raises a Psych::Exception directly, hence why this was never caught. If I update my local installation of the paper_trail gem to use is_a? instead of instance_of?, the bug report script above passes.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
Bug reports must provide a script that reproduces the bug, using our template. Feature suggestions must include a promise to build the feature yourself.
Thank you for all your contributions.
Thank you for your contribution!
Due to limited volunteers, issues that do not follow these instructions will be
closed without comment.
Check the following boxes:
paper_trail
gemDue to limited volunteers, we cannot answer usage questions. Please ask such
questions on StackOverflow.
Bug reports must use the following template:
This issue is because the error raised is an instance of
Psych::DisallowedClass
, but the check around the warning is fore.instance_of?(::Psych::Exception)
:paper_trail/lib/paper_trail/version_concern.rb
Lines 358 to 360 in 47dbc22
instance_of?
will only respond true when the object is an instance of the exact class; what we really want isis_a?
which will also respond true for any subclasses: https://stackoverflow.com/a/3893305#1397 only tests a stub that raises a
Psych::Exception
directly, hence why this was never caught. If I update my local installation of the paper_trail gem to useis_a?
instead ofinstance_of?
, the bug report script above passes.The text was updated successfully, but these errors were encountered: