From 7fffa03d8d76c222b7a28313a3526fcd9289a905 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 10 Nov 2015 11:18:31 +1100 Subject: [PATCH] Fix bug: set difference comparison of string with number --- app/models/spree/order_populator_decorator.rb | 2 +- spec/models/spree/order_populator_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/spree/order_populator_decorator.rb b/app/models/spree/order_populator_decorator.rb index 32d6afe12d..e9e3f0d0ed 100644 --- a/app/models/spree/order_populator_decorator.rb +++ b/app/models/spree/order_populator_decorator.rb @@ -76,7 +76,7 @@ Spree::OrderPopulator.class_eval do end def variants_removed(variants_data) - variant_ids_given = variants_data.map { |data| data[:variant_id] } + variant_ids_given = variants_data.map { |data| data[:variant_id].to_i } (variant_ids_in_cart - variant_ids_given).uniq end diff --git a/spec/models/spree/order_populator_spec.rb b/spec/models/spree/order_populator_spec.rb index 1e6e06677d..2ea77b5b5c 100644 --- a/spec/models/spree/order_populator_spec.rb +++ b/spec/models/spree/order_populator_spec.rb @@ -100,12 +100,12 @@ module Spree it "returns nothing when all items in the cart are provided" do op.stub(:variant_ids_in_cart) { [123] } - op.send(:variants_removed, [{variant_id: 123}]).should == [] + op.send(:variants_removed, [{variant_id: '123'}]).should == [] end it "returns nothing when items are added to cart" do op.stub(:variant_ids_in_cart) { [123] } - op.send(:variants_removed, [{variant_id: 123}, {variant_id: 456}]).should == [] + op.send(:variants_removed, [{variant_id: '123'}, {variant_id: '456'}]).should == [] end it "does not return duplicates" do