From d554b55fff560b6912304802f04c2c52e732c126 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 21 Aug 2018 01:07:48 +0100 Subject: [PATCH] Make product fields information static --- app/controllers/admin/product_import_controller.rb | 2 +- app/models/product_import/entry_validator.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index 231a39c59844..eb07ccf9f93a 100644 --- a/app/controllers/admin/product_import_controller.rb +++ b/app/controllers/admin/product_import_controller.rb @@ -14,7 +14,7 @@ def import @filepath = save_uploaded_file(params[:file]) @importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user, params[:settings]) @original_filename = params[:file].try(:original_filename) - @non_updatable_fields = @importer.validator.non_updatable_fields + @non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields check_file_errors @importer check_spreadsheet_has_data @importer diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index 10444ce24f0e..5a9aae60d00c 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -10,7 +10,7 @@ def initialize(current_user, import_time, spreadsheet_data, editable_enterprises @import_settings = import_settings end - def non_updatable_fields + def self.non_updatable_fields { category: :primary_taxon_id, variant_unit_name: :variant_unit_name, @@ -219,7 +219,7 @@ def mark_as_existing_variant(entry, existing_variant) end def apply_product_field_warnings(entry, existing_variant) - non_updatable_fields.each do |display_name, attribute| + EntryValidator.non_updatable_fields.each do |display_name, attribute| next if existing_variant.product.send(attribute) == entry.send(attribute) entry.warnings.add display_name, I18n.t('admin.product_import.model.not_updatable')