From 1232b55211511643eb59fc82155d07dca4baa127 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 19 May 2026 03:16:24 -0400 Subject: [PATCH] Use mime type symbol to set `content_type` for custom css response (#37845) --- app/controllers/custom_css_controller.rb | 2 +- spec/requests/custom_css_spec.rb | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/custom_css_controller.rb b/app/controllers/custom_css_controller.rb index 5b98914114..21fa8d4fe1 100644 --- a/app/controllers/custom_css_controller.rb +++ b/app/controllers/custom_css_controller.rb @@ -3,7 +3,7 @@ class CustomCssController < ActionController::Base # rubocop:disable Rails/ApplicationController def show expires_in 1.month, public: true - render content_type: 'text/css' + render content_type: :css end private diff --git a/spec/requests/custom_css_spec.rb b/spec/requests/custom_css_spec.rb index 66ff5c4b13..7dd15dc4b2 100644 --- a/spec/requests/custom_css_spec.rb +++ b/spec/requests/custom_css_spec.rb @@ -13,11 +13,10 @@ RSpec.describe 'Custom CSS' do expect(response) .to have_http_status(200) .and have_cacheable_headers - .and have_attributes( - content_type: match('text/css') - ) - expect(response.body.presence) - .to be_nil + expect(response.media_type) + .to eq('text/css') + expect(response.body) + .to be_blank end end @@ -32,9 +31,8 @@ RSpec.describe 'Custom CSS' do expect(response) .to have_http_status(200) .and have_cacheable_headers - .and have_attributes( - content_type: match('text/css') - ) + expect(response.media_type) + .to eq('text/css') expect(response.body.strip) .to eq(expected_css) end