diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb index bb644fb..0bea5bc 100644 --- a/app/controllers/api/application_controller.rb +++ b/app/controllers/api/application_controller.rb @@ -37,7 +37,9 @@ module API end def json_filter! - head :not_acceptable if request.format != :json + if request.format != :json + head :not_acceptable, content_type: 'application/json' + end end end end diff --git a/spec/integration/api/application_spec.rb b/spec/integration/api/application_spec.rb index a86ff4f..7f69dad 100644 --- a/spec/integration/api/application_spec.rb +++ b/spec/integration/api/application_spec.rb @@ -15,6 +15,7 @@ describe 'API application' do it 'responds with a 406 when request format is not JSON' do get api_ping_path, format: :xml expect(response.status).to be 406 + expect(response.content_type).to eq :json expect(response.body).to be_empty end end