Allow whodunnit to be a proc#976
Conversation
jaredbeck
left a comment
There was a problem hiding this comment.
I think this will not be a commonly used feature, but it adds so little complexity that I'm happy to add it.
Please add an entry to the changelog under "Unreleased"
| gemspec | ||
|
|
||
| gem "rubocop-rspec", "~> 1.15.1" | ||
| gem "rails-controller-testing" |
There was a problem hiding this comment.
Please do not edit the Gemfile. Please edit Appraisals instead. But, I don't think any changes to gems are necessary.
There was a problem hiding this comment.
Kk. I'm not familiar with Appraisals, but I can go figure it out.
There was a problem hiding this comment.
You're correct, when run via appraisal, everything is fine.
| paper_trail_store[:whodunnit].call | ||
| else | ||
| paper_trail_store[:whodunnit] | ||
| end |
There was a problem hiding this comment.
Should the conditional check respond_to?(:call) instead of == Proc?
There was a problem hiding this comment.
Yah, that makes a lot of sense; sharp knives and all that.
| expect(described_class.whodunnit).to eq(1) | ||
| expect(described_class.whodunnit).to eq(2) | ||
| end | ||
| end |
|
Updated as per review and failed tests; rewrote Git history of this branch to keep it super clean. I added a bit to the documentation where I (as a new and inexperienced contributor) was confused. |
|
Merged. Thanks for your contribution! |
* Allow whodunnit to be a proc * Update contribution quidelines
Basically, I've got a circumstance where I'm trying to figure out what is changing one of my models (it's not Sidekiq jobs, and it's not going through the controllers...).
Right now I've got:
This works, but it also only covers Sidekiq; if there's no place to stick the
whodunnitinitialization like this, there's no way to make thewhodunnitdynamic and record the actual situation.However, with a change like this, you could set a whodunnit during the creation of the paper trail, so you could evaluate anything you like (inspecting the callstack, the originally run Ruby command, etc etc).
PS - Honestly, I was 100% convinced I wanted this feature as part of tracking down this issue, but in this moment I'm honestly no remembering what the plan was that needed it.... :P
PPS - I totally don't expect this PR to get accepted, but I wanted to start the conversation and figured this'd be more illustrative than making an issue. LMK how I should proceed!
PPPS - I also ran into a couple of issues when first running
rspecon Papertrail, so there's a couple of Gemfile commits to fix that.