Skip to content

Commit

Permalink
Update specs that check mime type of header from content_type to medi…
Browse files Browse the repository at this point in the history
…a_type (#401)

See: How ActionDispatch::Response#content_type Changed Between Rails 5.2 to 6.1 - FastRuby.io | Rails Upgrade Service
  • Loading branch information
yuenmichelle1 authored Jan 23, 2025
1 parent a5027f2 commit cee63a1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples_for_controller_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples_for_controller_creating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples_for_controller_updating.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cee63a1

Please sign in to comment.