diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb index eeb7509..2961396 100644 --- a/app/controllers/api/application_controller.rb +++ b/app/controllers/api/application_controller.rb @@ -6,7 +6,7 @@ module API skip_before_filter :authenticate!, only: :cor_preflight before_filter :cor_filter - before_filter :json_filter! + before_filter :json_filter!, except: :cor_preflight def not_found head :not_found @@ -37,8 +37,11 @@ module API end def json_filter! - return if request.format.json? - head :not_acceptable, content_type: 'application/json' + if request.format.json? || request.accepts.include?(:json) + request.format = :json + else + head :not_acceptable, content_type: 'application/json' + end end end end diff --git a/spec/support/acceptance_helpers.rb b/spec/support/acceptance_helpers.rb index 8ba6bc4..52fe785 100644 --- a/spec/support/acceptance_helpers.rb +++ b/spec/support/acceptance_helpers.rb @@ -40,8 +40,8 @@ module AcceptanceHelpers end end - def json - expect(response).to be_success + def json status = 200 + expect(response.status).to be status JSON.parse(response.body, symbolize_names: true) end end