From 85b3d7dac5287ccfaf5fb87ce3e348450d53160c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 12 Jun 2019 14:28:10 +0100 Subject: [PATCH] Move attribute check to method --- app/models/product_import/entry_validator.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index de898080e4..f964326d00 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -314,7 +314,7 @@ module ProductImport def product_field_errors(entry, existing_product) EntryValidator.non_updatable_fields.each do |display_name, attribute| next if attributes_match?(attribute, existing_product, entry) || attributes_blank?(attribute, existing_product, entry) - next if attribute == :description + next if ignore_when_updating_product?(attribute) mark_as_invalid(entry, attribute: display_name, error: I18n.t('admin.product_import.model.not_updatable')) end end @@ -325,6 +325,11 @@ module ProductImport existing_product_value == convert_to_trusted_type(entry_value, existing_product_value) end + def ignore_when_updating_product?(attribute) + attributes_to_ignore = [:description] + attributes_to_ignore.include? attribute + end + def convert_to_trusted_type(untrusted_attribute, trusted_attribute) case trusted_attribute when Integer