From cc4825290bc550fd6bd0085a0ea0b229a045d024 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 29 Jan 2019 15:45:22 +0000 Subject: [PATCH] Fix type conversion problem in product import entry validator --- app/models/product_import/entry_validator.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index ce7eae7b19..89a6d26ccc 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -287,10 +287,18 @@ module ProductImport end def attributes_match?(attribute, existing_product, entry) - if existing_product.public_send(attribute).is_a?(Numeric) || entry.public_send(attribute).is_a?(Numeric) - return existing_product.public_send(attribute).to_i == entry.public_send(attribute).to_i + existing_product_value = existing_product.public_send(attribute) + entry_value = entry.public_send(attribute) + existing_product_value == convert_to_trusted_type(entry_value, existing_product_value) + end + + def convert_to_trusted_type(untrusted_attribute, trusted_attribute) + if trusted_attribute.is_a? Integer + untrusted_attribute.to_i + elsif trusted_attribute.is_a? Float + untrusted_attribute.to_f else - return existing_product.public_send(attribute).to_s == entry.public_send(attribute).to_s + untrusted_attribute.to_s end end