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

Spy failing due to KWARGS handling with ::ActionController::Parameters without setting up strong parameter permitting #33

Open
broksonic21 opened this issue Feb 6, 2023 · 0 comments

Comments

@broksonic21
Copy link

I'm trying to spy on a method that is expecting to receive an ::ActionController::Parameters object. While hash-like, it's not a hash anymore in Rails, and hasn't been for a while

However, the spy code here: and related

https://github.com/ryanong/spy/blob/master/lib/spy/subroutine.rb#L246-L248

is calling ** on the last parameter, trying to un-double-splat it. That fails, since ::ActionController::Parameters doesn't let you convert to a hash unless you first called permit (you get an error of):

ActionController::UnfilteredParameters: ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash

Normally, requiring permitted parameters is 100% the right and secure thing to do, but I am trying to pass the parameter object explicitly to this sub method (and spy on it for testing) for logging purposes, and I want to get the original values, so don't want to permit the parameters in my higher-level code.

Is there a workaround? This worked in Spy 1.3, but failing in Spy 1.4 and 1.5

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

1 participant