From 1a513567f2b397ee91ad625065d465c6a0b5d894 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Mon, 7 Sep 2020 20:48:18 +0100 Subject: [PATCH] Fix easy rubocop issues --- app/controllers/spree/admin/orders_controller.rb | 8 ++++++-- app/controllers/spree/admin/variants_controller.rb | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/spree/admin/orders_controller.rb b/app/controllers/spree/admin/orders_controller.rb index 7b257522bb..56dc8b0ed7 100644 --- a/app/controllers/spree/admin/orders_controller.rb +++ b/app/controllers/spree/admin/orders_controller.rb @@ -91,7 +91,9 @@ module Spree Spree::OrderMailer.invoice_email(@order.id, pdf).deliver flash[:success] = t('admin.orders.invoice_email_sent') - respond_with(@order) { |format| format.html { redirect_to spree.edit_admin_order_path(@order) } } + respond_with(@order) { |format| + format.html { redirect_to spree.edit_admin_order_path(@order) } + } end def print @@ -131,7 +133,9 @@ module Spree flash[:error] = t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) - respond_with(@order) { |format| format.html { redirect_to spree.edit_admin_order_path(@order) } } + respond_with(@order) { |format| + format.html { redirect_to spree.edit_admin_order_path(@order) } + } end def load_distribution_choices diff --git a/app/controllers/spree/admin/variants_controller.rb b/app/controllers/spree/admin/variants_controller.rb index 3a591f59c0..bb1f8284ac 100644 --- a/app/controllers/spree/admin/variants_controller.rb +++ b/app/controllers/spree/admin/variants_controller.rb @@ -61,17 +61,21 @@ module Spree @url_filters = ::ProductFilters.new.extract(request.query_parameters) @variant = Spree::Variant.find(params[:id]) - flash[:success] = if VariantDeleter.new.delete(@variant) - Spree.t('notice_messages.variant_deleted') - else - Spree.t('notice_messages.variant_not_deleted') - end + flash[:success] = delete_variant redirect_to spree.admin_product_variants_url(params[:product_id], @url_filters) end protected + def delete_variant + if VariantDeleter.new.delete(@variant) + Spree.t('notice_messages.variant_deleted') + else + Spree.t('notice_messages.variant_not_deleted') + end + end + def create_before option_values = params[:new_variant] option_values.andand.each_value { |id| @object.option_values << OptionValue.find(id) }