Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaperTrail is enabled by default for a controller even if it's disabled in general #281

Closed
maxcosworth opened this issue Oct 3, 2013 · 5 comments
Assignees
Milestone

Comments

@maxcosworth
Copy link

By default, the method paper_trail_enabled_for_controller always returns true, even if you have previously set PaperTrail.enabled = false.

That was making some of my controller specs to fail because PaperTrail was trying to call the user_for_paper_trail method, because paper_trail_enabled_for_controller is always true. And those controllers don't handle authentication.

I've a fix but I'd need to write some tests for it. Ok to ask for a pull-request?

@batter
Copy link
Collaborator

batter commented Oct 3, 2013

Sounds good to me. Even better if you can write tests for it 👍

@ghost ghost assigned batter Oct 3, 2013
@batter
Copy link
Collaborator

batter commented Oct 8, 2013

@maxcosworth - Any news on this? I just took a crack at an implementation but I'm not sure it covers everything. After reviewing this a little more closely I'm thinking that perhaps that the enabled_for_controller method is returning properly, but that the set_paper_trail_whodunnit method (this line) should be changed to this:

def set_paper_trail_whodunnit
  ::PaperTrail.whodunnit = user_for_paper_trail if paper_trail_enabled_for_controller && ::PaperTrail.enabled?
end

I think this makes more sense than trying to change the paper_trail_enabled_for_controller method since it is intended to be overwritten if desired. Also, I would think that in a case like yours, you might just overwrite the user_for_paper_trail method to return nil on that Controller?

@batter batter closed this as completed in 9dd154a Oct 10, 2013
@batter
Copy link
Collaborator

batter commented Oct 10, 2013

@maxcosworth - I'm trying to get a move on releasing 3.0.0, so I went ahead and implemented what I thought was the proper solution for this. Please take a look at 9dd154a, I think it should address the issue you were having.

@maxcosworth
Copy link
Author

Yep, it's ok, thanks. Sorry, I couldn't find time to submit the PR at the end.

@petervandenabeele
Copy link

I have the impression this commit triggered #293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants