Keep code in options hash

This commit is contained in:
Matt Jankowski 2024-03-14 09:46:41 -04:00
parent 6725327e1a
commit 007bef5a64
1 changed files with 15 additions and 15 deletions

View File

@ -19,20 +19,20 @@ describe Api::ErrorHandling do
end end
{ {
ActiveRecord::RecordInvalid => 422, ActiveRecord::RecordInvalid => { code: 422 },
ActiveRecord::RecordNotFound => 404, ActiveRecord::RecordNotFound => { code: 404 },
ActiveRecord::RecordNotUnique => 422, ActiveRecord::RecordNotUnique => { code: 422 },
Date::Error => 422, Date::Error => { code: 422 },
HTTP::Error => 503, HTTP::Error => { code: 503 },
Mastodon::InvalidParameterError => 400, Mastodon::InvalidParameterError => { code: 400 },
Mastodon::NotPermittedError => 403, Mastodon::NotPermittedError => { code: 403 },
Mastodon::RaceConditionError => 503, Mastodon::RaceConditionError => { code: 503 },
Mastodon::RateLimitExceededError => 429, Mastodon::RateLimitExceededError => { code: 429 },
Mastodon::UnexpectedResponseError => 503, Mastodon::UnexpectedResponseError => { code: 503 },
Mastodon::ValidationError => 422, Mastodon::ValidationError => { code: 422 },
OpenSSL::SSL::SSLError => 503, OpenSSL::SSL::SSLError => { code: 503 },
Seahorse::Client::NetworkingError => 503, Seahorse::Client::NetworkingError => { code: 503 },
Stoplight::Error::RedLight => 503, Stoplight::Error::RedLight => { code: 503 },
}.each do |error, options| }.each do |error, options|
it "Handles error class of #{error}" do it "Handles error class of #{error}" do
allow(FakeService) allow(FakeService)
@ -42,7 +42,7 @@ describe Api::ErrorHandling do
get :failure get :failure
expect(response) expect(response)
.to have_http_status(options) .to have_http_status(options[:code])
expect(FakeService) expect(FakeService)
.to have_received(:new) .to have_received(:new)
end end