Merge pull request #12582 from cyrillefr/FixRails_UnusedRenderContentIssues

Fixes offenses raised by Rails/UnusedRenderContent
This commit is contained in:
Maikel
2024-06-19 11:19:22 +10:00
committed by GitHub
7 changed files with 7 additions and 18 deletions

View File

@@ -746,17 +746,6 @@ Rails/UnknownEnv:
Exclude:
- 'app/models/spree/app_configuration.rb'
# Offense count: 7
# Configuration parameters: Severity.
Rails/UnusedRenderContent:
Exclude:
- 'app/controllers/admin/bulk_line_items_controller.rb'
- 'app/controllers/admin/tag_rules_controller.rb'
- 'app/controllers/api/v0/enterprise_fees_controller.rb'
- 'app/controllers/api/v0/products_controller.rb'
- 'app/controllers/api/v0/taxons_controller.rb'
- 'app/controllers/api/v0/variants_controller.rb'
# Offense count: 1
Security/Open:
Exclude:

View File

@@ -35,7 +35,7 @@ module Admin
order.with_lock do
if order.contents.update_item(@line_item, line_item_params)
# No Content, does not trigger ng resource auto-update
render body: nil, status: :no_content
head :no_content
else
render json: { errors: @line_item.errors }, status: :precondition_failed
end
@@ -49,7 +49,7 @@ module Admin
authorize! :update, order
order.contents.remove(@line_item.variant)
render body: nil, status: :no_content # No Content, does not trigger ng resource auto-update
head :no_content # No Content, does not trigger ng resource auto-update
end
private

View File

@@ -5,7 +5,7 @@ module Admin
respond_to :json
respond_override destroy: { json: {
success: lambda { render body: nil, status: :no_content }
success: lambda { head :no_content }
} }
def map_by_tag

View File

@@ -9,7 +9,7 @@ module Api
authorize! :destroy, enterprise_fee
if enterprise_fee.destroy
render plain: I18n.t(:successfully_removed), status: :no_content
head :no_content
else
render plain: enterprise_fee.errors.full_messages.first, status: :forbidden
end

View File

@@ -44,7 +44,7 @@ module Api
authorize! :delete, @product
@product.destroyed_by = current_api_user
@product.destroy
render json: @product, serializer: Api::Admin::ProductSerializer, status: :no_content
head :no_content
end
def bulk_products

View File

@@ -55,7 +55,7 @@ module Api
def destroy
authorize! :delete, Spree::Taxon
taxon.destroy
render json: taxon, serializer: Api::TaxonSerializer, status: :no_content
head :no_content
end
private

View File

@@ -44,7 +44,7 @@ module Api
authorize! :delete, @variant
VariantDeleter.new.delete(@variant)
render json: @variant, serializer: Api::VariantSerializer, status: :no_content
head :no_content
end
private