Skip to content

A platform for community discussion. Free, open, simple.

DEV: Manually fix Rails/UnusedRenderContent offenses (#34418)

Jarek Radosz2c4e3d6d47f0
diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb
index 0541eed77cb..c1a0e85a8d5 100644
--- a/app/controllers/admin/themes_controller.rb
+++ b/app/controllers/admin/themes_controller.rb
@@ -290,7 +290,7 @@ class Admin::ThemesController < Admin::AdminController
def destroy
Themes::Destroy.call(service_params) do
- on_success { render json: {}, status: :no_content }
+ on_success { head :no_content }
on_failed_contract do |contract|
render json: failed_json.merge(errors: contract.errors.full_messages), status: 400
end
@@ -300,7 +300,7 @@ class Admin::ThemesController < Admin::AdminController
def bulk_destroy
Themes::BulkDestroy.call(service_params) do
- on_success { render json: {}, status: :no_content }
+ on_success { head :no_content }
on_failed_contract do |contract|
render json: failed_json.merge(errors: contract.errors.full_messages), status: 400
end
diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rb
index 457b2b08a71..342fe1e7d58 100644
--- a/app/controllers/stylesheets_controller.rb
+++ b/app/controllers/stylesheets_controller.rb
@@ -72,7 +72,7 @@ class StylesheetsController < ApplicationController
handle_missing_cache(location, target, digest) if !stylesheet_time
if cache_time.present? && stylesheet_time && stylesheet_time <= cache_time
- return render body: nil, status: 304
+ return head :not_modified
end
unless File.exist?(location)
diff --git a/app/controllers/theme_javascripts_controller.rb b/app/controllers/theme_javascripts_controller.rb
index 087f127b13a..3fa589d55ac 100644
--- a/app/controllers/theme_javascripts_controller.rb
+++ b/app/controllers/theme_javascripts_controller.rb
@@ -17,7 +17,7 @@ class ThemeJavascriptsController < ApplicationController
def show
raise Discourse::NotFound if last_modified.blank?
- return render body: nil, status: 304 if not_modified?
+ return head :not_modified if not_modified?
# Security: safe due to route constraint
cache_file = "#{DISK_CACHE_PATH}/#{params[:digest]}.js"
@@ -36,7 +36,7 @@ class ThemeJavascriptsController < ApplicationController
def show_map
raise Discourse::NotFound if last_modified.blank?
- return render body: nil, status: 304 if not_modified?
+ return head :not_modified if not_modified?
# Security: safe due to route constraint
cache_file = "#{DISK_CACHE_PATH}/#{params[:digest]}.map"
@@ -57,7 +57,7 @@ class ThemeJavascriptsController < ApplicationController
raise Discourse::NotFound if content.blank? || content_digest != digest
@cache_file = "#{TESTS_DISK_CACHE_PATH}/#{digest}.js"
- return render body: nil, status: 304 if not_modified?
+ return head :not_modified if not_modified?
write_if_not_cached(@cache_file) { content }
diff --git a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
index 4d9570b9b6c..8e95839a0e1 100644
--- a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
+++ b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb
@@ -40,7 +40,7 @@ module DiscourseZendeskPlugin
end
end
- render json: {}, status: 204
+ head :no_content
end
private