config: flip action_dispatch_return_only_media_type_on_content_type

This makes `ActionDispatch::Controller#content_type` return not only
the MIME type, but also in some circumstances the charset.

Example:

```ruby
reponse.content_type == 'text/html; charset=utf-8'
```

The MIME type-only fragment can now be accessed using `#media_type`.

Changes to the tests are not stricly necessary (because no charset is
present in the actual value), but represent the intent better.
This commit is contained in:
Pierre de La Morinerie 2020-07-13 17:36:28 +02:00
parent 8427f0eb75
commit 65809f8ea0
3 changed files with 4 additions and 4 deletions

View file

@ -17,7 +17,7 @@ Rails.application.config.action_view.default_enforce_utf8 = false
Rails.application.config.action_dispatch.use_cookies_with_metadata = true
# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
# Return false instead of self when enqueuing is aborted from a callback.
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true

View file

@ -540,8 +540,8 @@ describe Instructeurs::ProceduresController, type: :controller do
format: :js
end
it "responses in the correct format" do
expect(response.content_type).to eq "text/javascript"
it 'responds in the correct format' do
expect(response.media_type).to eq('text/javascript')
expect(response).to have_http_status(:ok)
end
end

View file

@ -23,7 +23,7 @@ describe NewAdministrateur::AttestationTemplatesController, type: :controller do
render_views
it 'renders a PDF' do
expect(subject.status).to eq(200)
expect(subject.content_type).to eq('application/pdf')
expect(subject.media_type).to eq('application/pdf')
end
end