From cee63a109aa52434e20141feaf435045f5227b08 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Wed, 22 Jan 2025 20:00:19 -0600 Subject: [PATCH] Update specs that check mime type of header from content_type to media_type (#401) See: How ActionDispatch::Response#content_type Changed Between Rails 5.2 to 6.1 - FastRuby.io | Rails Upgrade Service --- spec/controllers/application_controller_spec.rb | 6 +++--- spec/controllers/comments_controller_spec.rb | 2 +- spec/support/shared_examples_for_controller_actions.rb | 2 +- spec/support/shared_examples_for_controller_creating.rb | 2 +- spec/support/shared_examples_for_controller_updating.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index eeb091f4..0ef0f056 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -9,7 +9,7 @@ before(:each){ get :root, format: :json } it 'should render json' do - expect(response.content_type).to eql 'application/json' + expect(response.media_type).to eql 'application/json' end it 'should list resources' do @@ -21,7 +21,7 @@ before(:each){ get :root, format: :json_api } it 'should render json' do - expect(response.content_type).to eql 'application/json' + expect(response.media_type).to eql 'application/json' end it 'should list resources' do @@ -36,7 +36,7 @@ end it 'should render html' do - expect(response.content_type).to eql 'text/html' + expect(response.media_type).to eql 'text/html' end it 'should redirect' do diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 26ab3f44..9332e919 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -140,7 +140,7 @@ end it 'should be json' do - expect(response.content_type).to eql 'application/json' + expect(response.media_type).to eql 'application/json' end it 'should be an object' do diff --git a/spec/support/shared_examples_for_controller_actions.rb b/spec/support/shared_examples_for_controller_actions.rb index e79616ff..366c66e9 100644 --- a/spec/support/shared_examples_for_controller_actions.rb +++ b/spec/support/shared_examples_for_controller_actions.rb @@ -19,7 +19,7 @@ it 'should be json' do # starting from Rails 5+, if responding with 204, content-type of response is set by Rails as nil - expect(response.content_type).to eql 'application/json' unless response.status == 204 + expect(response.media_type).to eql 'application/json' unless response.status == 204 end it 'should be an object' do diff --git a/spec/support/shared_examples_for_controller_creating.rb b/spec/support/shared_examples_for_controller_creating.rb index f994c484..bf099521 100644 --- a/spec/support/shared_examples_for_controller_creating.rb +++ b/spec/support/shared_examples_for_controller_creating.rb @@ -45,7 +45,7 @@ end it 'should be json' do - expect(response.content_type).to eql 'application/json' + expect(response.media_type).to eql 'application/json' end it 'should be an object' do diff --git a/spec/support/shared_examples_for_controller_updating.rb b/spec/support/shared_examples_for_controller_updating.rb index 8b5acc25..5397072f 100644 --- a/spec/support/shared_examples_for_controller_updating.rb +++ b/spec/support/shared_examples_for_controller_updating.rb @@ -48,7 +48,7 @@ end it 'should be json' do - expect(response.content_type).to eql 'application/json' + expect(response.media_type).to eql 'application/json' end it 'should be an object' do