From 1505625b0121ff5d90a688f14c2b6907d0961e92 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 8 Jun 2022 17:01:26 -0500 Subject: [PATCH 1/2] 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 580b8e9a4..0d4ebb677 100644 --- a/lib/jsonapi/acts_as_resource_controller.rb +++ b/lib/jsonapi/acts_as_resource_controller.rb @@ -140,8 +140,8 @@ def resource_klass_name end def verify_content_type_header - 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 true rescue => e 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 ee2b36674..b79c5135c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -471,7 +471,7 @@ class ActionDispatch::IntegrationTest fixtures :all def assert_jsonapi_response(expected_status, msg = nil) - media_type = Rails::VERSION::MAJOR >= 6 ? response.media_type : response.content_type + media_type = Rails::VERSION::MAJOR >= 6 ? response.media_type : response.media_type assert_equal JSONAPI::MEDIA_TYPE, media_type if status != expected_status && status >= 400 pp json_response rescue nil From d32e1e70ce38347fc153a89f4f57b4383a2e1c71 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Wed, 11 Jan 2023 11:55:57 -0600 Subject: [PATCH 2/2] Update test/test_helper.rb Co-authored-by: Larry Gebhardt --- test/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index b79c5135c..30d439ddb 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -471,7 +471,7 @@ class ActionDispatch::IntegrationTest fixtures :all def assert_jsonapi_response(expected_status, msg = nil) - media_type = Rails::VERSION::MAJOR >= 6 ? response.media_type : response.media_type + media_type = response.media_type assert_equal JSONAPI::MEDIA_TYPE, media_type if status != expected_status && status >= 400 pp json_response rescue nil