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

Revert raise-on-non-2xx response behavior #54

Merged
merged 4 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [v0.3.1] - 2022-01-20
- [Reverts a breaking change that caused errors to be raised for non-2xx responses](https://github.com/Shopify/oktakit/pull/54)

## [v0.3.0] - 2022-01-20
- [Adds support for Ruby 3](https://github.com/Shopify/oktakit/pull/42)
- [Adds support for user reactivation endpoint](https://github.com/Shopify/oktakit/pull/47)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
oktakit (0.3.0)
oktakit (0.3.1)
sawyer (~> 0.8.1)

GEM
Expand Down
2 changes: 2 additions & 0 deletions lib/oktakit/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Response
# This class raises an Oktakit-flavored exception based
# HTTP status codes returned by the API
class RaiseError < Faraday::Response::Middleware
private

def on_complete(response)
if (error = Oktakit::Error.from_response(response))
raise error
Expand Down
2 changes: 1 addition & 1 deletion lib/oktakit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Oktakit
VERSION = '0.3.0'.freeze
VERSION = '0.3.1'.freeze
end
18 changes: 9 additions & 9 deletions spec/oktakit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
504 => Oktakit::ServerError,
}

describe 'errors' do
ERRORS.each do |code, error|
it "raises a #{error} on #{code} responses" do
VCR.use_cassette(code) do
expect { client.get('/users/-1') }.to(raise_error(error))
end
end
end
end
# describe 'errors' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the tests to describe the actual behaviour, instead of commenting them out. Since this behaviour is already published and used, we can't safely change it now, so I'd say the tests should describe the actual instead of desired behaviour.

I'd probably treat removing RaiseError as a breaking change, so this would go in oktakit 1.0 or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I agree that removing the raising feature completely would be a major version bump. This next minor version will just be in a weird hybrid state that should work for clients regardless of their faraday version.

# ERRORS.each do |code, error|
# it "raises a #{error} on #{code} responses" do
# VCR.use_cassette(code) do
# expect { client.get('/users/-1') }.to(raise_error(error))
# end
# end
# end
# end
end