From cb8fd2131e2c95242a968f83aa502723fa17c9aa Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Fri, 12 Mar 2021 21:29:31 +0000 Subject: [PATCH] Use body: nil instead of deprecated nothing: Ideally we would be using render head status but it's issuing quite a lot of double render problems, we can improve later --- app/controllers/admin/bulk_line_items_controller.rb | 4 ++-- app/controllers/admin/column_preferences_controller.rb | 2 +- .../admin/enterprise_relationships_controller.rb | 2 +- app/controllers/admin/enterprise_roles_controller.rb | 2 +- app/controllers/admin/tag_rules_controller.rb | 2 +- app/controllers/admin/variant_overrides_controller.rb | 2 +- app/controllers/line_items_controller.rb | 4 ++-- app/controllers/spree/admin/products_controller.rb | 2 +- app/controllers/stripe/webhooks_controller.rb | 6 +++--- lib/spree/core/controller_helpers/common.rb | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/admin/bulk_line_items_controller.rb b/app/controllers/admin/bulk_line_items_controller.rb index f8667f69ec..8a289d33cc 100644 --- a/app/controllers/admin/bulk_line_items_controller.rb +++ b/app/controllers/admin/bulk_line_items_controller.rb @@ -36,7 +36,7 @@ module Admin order.update_line_item_fees! @line_item order.update_order_fees! order.update! - render nothing: true, status: :no_content # No Content, does not trigger ng resource auto-update + render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update else render json: { errors: @line_item.errors }, status: :precondition_failed end @@ -50,7 +50,7 @@ module Admin authorize! :update, order @line_item.destroy - render nothing: true, status: :no_content # No Content, does not trigger ng resource auto-update + render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update end private diff --git a/app/controllers/admin/column_preferences_controller.rb b/app/controllers/admin/column_preferences_controller.rb index 90b4cb850c..4ff7734f22 100644 --- a/app/controllers/admin/column_preferences_controller.rb +++ b/app/controllers/admin/column_preferences_controller.rb @@ -12,7 +12,7 @@ module Admin elsif @cp_set.errors.present? render json: { errors: @cp_set.errors }, status: :bad_request else - render nothing: true, status: :internal_server_error + render body: nil, status: :internal_server_error end end diff --git a/app/controllers/admin/enterprise_relationships_controller.rb b/app/controllers/admin/enterprise_relationships_controller.rb index 4a17abb98d..d1c77d3d53 100644 --- a/app/controllers/admin/enterprise_relationships_controller.rb +++ b/app/controllers/admin/enterprise_relationships_controller.rb @@ -23,7 +23,7 @@ module Admin def destroy @enterprise_relationship = EnterpriseRelationship.find params[:id] @enterprise_relationship.destroy - render nothing: true + render body: nil end private diff --git a/app/controllers/admin/enterprise_roles_controller.rb b/app/controllers/admin/enterprise_roles_controller.rb index c1b7be07e0..be29df26fa 100644 --- a/app/controllers/admin/enterprise_roles_controller.rb +++ b/app/controllers/admin/enterprise_roles_controller.rb @@ -20,7 +20,7 @@ module Admin def destroy @enterprise_role = EnterpriseRole.find params[:id] @enterprise_role.destroy - render nothing: true + render body: nil end private diff --git a/app/controllers/admin/tag_rules_controller.rb b/app/controllers/admin/tag_rules_controller.rb index 7e9ab20d30..8ddbf82c83 100644 --- a/app/controllers/admin/tag_rules_controller.rb +++ b/app/controllers/admin/tag_rules_controller.rb @@ -3,7 +3,7 @@ module Admin respond_to :json respond_override destroy: { json: { - success: lambda { render nothing: true, status: :no_content } + success: lambda { render body: nil, status: :no_content } } } def map_by_tag diff --git a/app/controllers/admin/variant_overrides_controller.rb b/app/controllers/admin/variant_overrides_controller.rb index 284f581b5b..6c20f59f44 100644 --- a/app/controllers/admin/variant_overrides_controller.rb +++ b/app/controllers/admin/variant_overrides_controller.rb @@ -21,7 +21,7 @@ module Admin elsif @vo_set.errors.present? render json: { errors: @vo_set.errors }, status: :bad_request else - render nothing: true, status: :internal_server_error + render body: nil, status: :internal_server_error end end diff --git a/app/controllers/line_items_controller.rb b/app/controllers/line_items_controller.rb index b4d8624134..81cfd0ba5f 100644 --- a/app/controllers/line_items_controller.rb +++ b/app/controllers/line_items_controller.rb @@ -29,11 +29,11 @@ class LineItemsController < BaseController def unauthorized status = spree_current_user ? 403 : 401 - render(nothing: true, status: status) && return + render(body: nil, status: status) && return end def not_found - render(nothing: true, status: :not_found) && return + render(body: nil, status: :not_found) && return end def destroy_with_lock(item) diff --git a/app/controllers/spree/admin/products_controller.rb b/app/controllers/spree/admin/products_controller.rb index 17244f2a90..0860d5a5a5 100644 --- a/app/controllers/spree/admin/products_controller.rb +++ b/app/controllers/spree/admin/products_controller.rb @@ -84,7 +84,7 @@ module Spree elsif product_set.errors.present? render json: { errors: product_set.errors }, status: :bad_request else - render nothing: true, status: :internal_server_error + render body: nil, status: :internal_server_error end end diff --git a/app/controllers/stripe/webhooks_controller.rb b/app/controllers/stripe/webhooks_controller.rb index ce607fd8e7..41470d9e70 100644 --- a/app/controllers/stripe/webhooks_controller.rb +++ b/app/controllers/stripe/webhooks_controller.rb @@ -10,7 +10,7 @@ module Stripe handler = WebhookHandler.new(@event) result = handler.handle - render nothing: true, status: status_mappings[result] || 200 + render body: nil, status: status_mappings[result] || 200 end private @@ -20,9 +20,9 @@ module Stripe signature = request.headers["HTTP_STRIPE_SIGNATURE"] @event = Webhook.construct_event(payload, signature, Stripe.endpoint_secret) rescue JSON::ParserError - render nothing: true, status: :bad_request + render body: nil, status: :bad_request rescue Stripe::SignatureVerificationError - render nothing: true, status: :unauthorized + render body: nil, status: :unauthorized end # Stripe interprets a 4xx or 3xx response as a failure to receive the webhook, diff --git a/lib/spree/core/controller_helpers/common.rb b/lib/spree/core/controller_helpers/common.rb index c6978382e7..2854d8363b 100644 --- a/lib/spree/core/controller_helpers/common.rb +++ b/lib/spree/core/controller_helpers/common.rb @@ -46,7 +46,7 @@ module Spree formats: [:html], layout: nil } - type.all { render status: :not_found, nothing: true } + type.all { render status: :not_found, body: nil } end end