-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update faraday to 2.12, remove deprecated faraday_middleware gem #393
Conversation
end | ||
|
||
it 'raise a proper error' do | ||
expect { client_response }.to raise_error(Faraday::ParsingError) |
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.
This error can not be raised in this spec anymore. We are stubbing the response which Faraday returns after the middleware is applied. So no JSON parsing takes place anymore.
lib/ioki/apis/endpoints/create.rb
Outdated
@@ -40,7 +40,7 @@ def call(client, model, args = [], options = {}) | |||
params: options[:params] | |||
) | |||
|
|||
return if parsed_response.nil? | |||
return if Support.blank?(parsed_response) |
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.
When a response is an empty string, it will not be cast to nil
anymore, so we check for empty?
or nil?
@eikes I quickly tested this in the two projects I'm working on and I do have failing tests. So there seems to be a behavioral change. Let me know if this PR is review ready, I'll then check what's going on! |
@phylor Yes, it's ready for review, using an outdated Faraday version was a problem for me. Please let me know how or what is failing. I can help debug if you want me to. |
It is a testing issue. I'm not so sure if this will ever happen in production code. The behavioral change is that we now return If we were defensive, we could change the condition to something like I'm not sure how often that happens in real code. It happens in our test code as we return an empty hash in mocked API calls when we're not interested in the response. We used to get an empty model back, i.e. we could still call all methods on it (they do return I'm also not sure if it's more logical/correct to return I thought about what happens when the API returns I don't have a strong opinion - I'm slightly leaning towards your proposed solution, as returning @eikes What do you think? |
@phylor Two things come to mind:
|
Okay, then let's agree that we don't change the existing behavior. At least not for the empty hash. |
It's no longer bundled since Faraday 2.
244f78f
to
4808f8e
Compare
The current behavior depends on the response: - response `""`: `nil` as model - response `nil`: `nil` as model - response `{}`: empty model
4808f8e
to
5aaad00
Compare
@eikes I changed a couple of things to make the update work without breaking existing behavior. Our behavior is inconsistent though. It depends on what the response is. If the response is invalid JSON, we return |
@phylor Thank you for working on this! I am fine with the changes as they are now. Please feel free to merge this. |
No description provided.