diff --git a/app/controllers/admin/product_import_controller.rb b/app/controllers/admin/product_import_controller.rb index 231a39c5984..eb07ccf9f93 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 10444ce24f0..5a9aae60d00 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') diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 63a48b4f758..ca3f691695a 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -6,7 +6,7 @@ class ProductImporter include ActiveModel::Conversion include ActiveModel::Validations - attr_reader :updated_ids, :import_settings, :validator + attr_reader :updated_ids, :import_settings def initialize(file, current_user, import_settings = {}) unless file.is_a?(File)