File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def development? = self.class.development?
9292 plugin :not_allowed
9393 plugin :exception_page
9494 plugin :error_handler do |error |
95- next exception_page ( error ) if development? && !error . is_a? ( NotFoundError )
95+ next exception_page ( error ) if development? && !error . is_a? ( HttpError )
9696
9797 ErrorResponder . respond ( request : request , response : response , error : error )
9898 end
Original file line number Diff line number Diff line change @@ -216,6 +216,19 @@ def app = described_class
216216 expect ( json . dig ( 'error' , 'code' ) ) . to eq ( Html2rss ::Web ::InternalServerError ::CODE )
217217 expect ( json . dig ( 'error' , 'message' ) ) . to eq ( 'Internal Server Error' )
218218 end
219+
220+ it 'keeps API auth failures on the JSON error contract in development mode' do
221+ ClimateControl . modify ( 'RACK_ENV' => 'development' ) do
222+ post '/api/v1/feeds' , JSON . generate ( url : 'https://example.com/articles' ) ,
223+ { 'CONTENT_TYPE' => 'application/json' , 'HTTP_AUTHORIZATION' => 'Bearer invalid-token' }
224+ end
225+
226+ expect ( last_response . status ) . to eq ( 401 )
227+ expect ( last_response . headers [ 'Content-Type' ] ) . to include ( 'application/json' )
228+ json = JSON . parse ( last_response . body )
229+ expect ( json . dig ( 'error' , 'code' ) ) . to eq ( Html2rss ::Web ::UnauthorizedError ::CODE )
230+ expect ( json . dig ( 'error' , 'message' ) ) . to eq ( 'Authentication required' )
231+ end
219232 end
220233
221234 describe '.development?' do
You can’t perform that action at this time.
0 commit comments