-
Notifications
You must be signed in to change notification settings - Fork 698
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
Avoid overly-general rescue in callback controller #1530
Avoid overly-general rescue in callback controller #1530
Conversation
@@ -35,13 +35,13 @@ class CallbackControllerTest < ActionController::TestCase | |||
end | |||
|
|||
test "#callback flashes error when omniauth is not present" do | |||
get :callback, params: { shop: "shop" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rescue
meant these tests were passing, but for the wrong reason. Without the rescue
, they failed with:
Error:
ShopifyApp::CallbackControllerTest#test_#callback_flashes_error_in_Spanish:
ArgumentError: missing keywords: :code, :timestamp, :state, :host, :hmac
test/controllers/callback_controller_test.rb:44:in `block in <class:CallbackControllerTest>'
5692966
to
7b34a9a
Compare
rescue | ||
return respond_with_error | ||
rescue => e | ||
if e.class.module_parent == ShopifyAPI::Errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no common base for the error classes, this seemed the cleanest way. (It's from ActiveSupport).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach!
I guess the other tricky consideration would be, what if it is an error from the gem?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's possible here - the code within the rescued block only calls out to ShopifyAPI
, and the ShopifyAPI
gem has no knowledge of ShopifyApp
.
I think we should get the logging in place before doing this. |
I plan to change this to emit a deprecation warning instead of raising. |
7b34a9a
to
a332f41
Compare
7c84257
to
0157633
Compare
0157633
to
6eaaa41
Compare
@nelsonwittwer ready for a final review. |
/shipit |
* Avoid overly-general rescue in callback controller * Deprecation error * Add tests * Update CHANGELOG Co-authored-by: Andy Waite <[email protected]>
Closes #1527
Still to test, just looking for feedback on the approach.