From ed0441dc41957e272231dd6b1d59e610b32d5a4d Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sun, 1 Nov 2020 12:19:29 +0000 Subject: [PATCH] Fix a few more rubocop issues --- .rubocop_manual_todo.yml | 1 - .../admin/column_preferences_controller.rb | 3 ++- app/controllers/admin/variant_overrides_controller.rb | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 67d1f8a600..934e12057c 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -33,7 +33,6 @@ Layout/LineLength: - app/controllers/admin/product_import_controller.rb - app/controllers/admin/schedules_controller.rb - app/controllers/admin/subscriptions_controller.rb - - app/controllers/admin/variant_overrides_controller.rb - app/controllers/api/enterprise_attachment_controller.rb - app/controllers/api/product_images_controller.rb - app/controllers/spree/paypal_controller_decorator.rb diff --git a/app/controllers/admin/column_preferences_controller.rb b/app/controllers/admin/column_preferences_controller.rb index 90ba1bd37e..90b4cb850c 100644 --- a/app/controllers/admin/column_preferences_controller.rb +++ b/app/controllers/admin/column_preferences_controller.rb @@ -29,7 +29,8 @@ module Admin collection_hash = Hash[permitted_params[:column_preferences]. each_with_index.map { |cp, i| [i, cp] }] collection_hash.select!{ |_i, cp| cp[:action_name] == permitted_params[:action_name] } - @cp_set = Sets::ColumnPreferenceSet.new @column_preferences, collection_attributes: collection_hash + @cp_set = Sets::ColumnPreferenceSet.new(@column_preferences, + collection_attributes: collection_hash) end def collection diff --git a/app/controllers/admin/variant_overrides_controller.rb b/app/controllers/admin/variant_overrides_controller.rb index c4fd99a766..3c6778640c 100644 --- a/app/controllers/admin/variant_overrides_controller.rb +++ b/app/controllers/admin/variant_overrides_controller.rb @@ -60,14 +60,17 @@ module Admin for_hubs(editable_enterprises.collect(&:id)) options = [{ id: '0', name: 'All' }] - import_dates.collect(&:import_date).map { |i| options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) } + import_dates.collect(&:import_date).map { |i| + options.push(id: i.to_date, name: i.to_date.to_formatted_s(:long)) + } options end def load_collection collection_hash = Hash[variant_overrides_params.each_with_index.map { |vo, i| [i, vo] }] - @vo_set = Sets::VariantOverrideSet.new @variant_overrides, collection_attributes: collection_hash + @vo_set = Sets::VariantOverrideSet.new(@variant_overrides, + collection_attributes: collection_hash) end def collection @@ -82,8 +85,8 @@ module Admin [:index, :bulk_update, :bulk_reset] end - # This has been pulled from ModelSet as it is useful for compiling a list of errors on any generic collection (not necessarily a ModelSet) - # Could be pulled down into a lower level controller if it is useful in other high level controllers + # This method is also present in ModelSet + # This is useful for compiling a list of errors on any generic collection def collection_errors errors = ActiveModel::Errors.new self full_messages = @collection.map { |element| element.errors.full_messages }.flatten