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
This commit is contained in:
Luis Ramos
2021-03-12 21:29:31 +00:00
parent 53d758ca21
commit cb8fd2131e
10 changed files with 14 additions and 14 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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,

View File

@@ -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