From 4d8a23346c65d63a034188e2b999fb6cd4aa22ee Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 12 Mar 2014 12:35:28 +1100 Subject: [PATCH] Fix bug: Unselecting product variant unit in BPE doesn't save --- .../admin/bulk_product_update.js.coffee | 4 ++++ .../unit/bulk_product_update_spec.js.coffee | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 97116f673b..260249371f 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -394,7 +394,11 @@ productEditModule.controller "AdminProductEditCtrl", [ else product.variant_unit = product.variant_unit_with_scale product.variant_unit_scale = null + else + product.variant_unit = product.variant_unit_scale = null + $scope.packVariant product, product.master if product.master + if product.variants for id, variant of product.variants $scope.packVariant product, variant diff --git a/spec/javascripts/unit/bulk_product_update_spec.js.coffee b/spec/javascripts/unit/bulk_product_update_spec.js.coffee index bd85419ac9..58a5ce1941 100644 --- a/spec/javascripts/unit/bulk_product_update_spec.js.coffee +++ b/spec/javascripts/unit/bulk_product_update_spec.js.coffee @@ -690,6 +690,21 @@ describe "AdminProductEditCtrl", -> variant_unit_scale: 1000 variant_unit_with_scale: 'volume_1000' + it "extracts a null value into null variant_unit and variant_unit_scale", -> + testProduct = + id: 1 + variant_unit: 'weight' + variant_unit_scale: 1 + variant_unit_with_scale: null + + scope.packProduct(testProduct) + + expect(testProduct).toEqual + id: 1 + variant_unit: null + variant_unit_scale: null + variant_unit_with_scale: null + it "extracts when variant_unit_with_scale is 'items'", -> testProduct = id: 1