From 2a2798a60318e81ce9037e31d54e3d7c41726a09 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 8 Jun 2022 17:01:26 -0500 Subject: [PATCH] Rails 7.0 deprecates content_type in favor of media_type Affects 0.10 and 0.9 --- lib/jsonapi/acts_as_resource_controller.rb | 4 ++-- test/helpers/functional_helpers.rb | 4 ++-- test/test_helper.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jsonapi/acts_as_resource_controller.rb b/lib/jsonapi/acts_as_resource_controller.rb index 90fd296b8..5d8b1cd6a 100644 --- a/lib/jsonapi/acts_as_resource_controller.rb +++ b/lib/jsonapi/acts_as_resource_controller.rb @@ -167,8 +167,8 @@ def resource_klass_name def verify_content_type_header if ['create', 'create_relationship', 'update_relationship', 'update'].include?(params[:action]) - unless request.content_type == JSONAPI::MEDIA_TYPE - fail JSONAPI::Exceptions::UnsupportedMediaTypeError.new(request.content_type) + unless request.media_type == JSONAPI::MEDIA_TYPE + fail JSONAPI::Exceptions::UnsupportedMediaTypeError.new(request.media_type) end end end diff --git a/test/helpers/functional_helpers.rb b/test/helpers/functional_helpers.rb index e0f504df2..3d6dc9d34 100644 --- a/test/helpers/functional_helpers.rb +++ b/test/helpers/functional_helpers.rb @@ -32,8 +32,8 @@ module FunctionalHelpers # end # end # - # if @response.content_type - # ct = @response.content_type + # if @response.media_type + # ct = @response.media_type # elsif methods.include?('assert_response_response') # ct = assert_response_response # else diff --git a/test/test_helper.rb b/test/test_helper.rb index 42a86c9a6..16731a447 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -474,7 +474,7 @@ class ActionDispatch::IntegrationTest fixtures :all def assert_jsonapi_response(expected_status, msg = nil) - assert_equal JSONAPI::MEDIA_TYPE, response.content_type + assert_equal JSONAPI::MEDIA_TYPE, response.media_type if status != expected_status && status >= 400 pp json_response rescue nil end