diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 631a940d31..c2c4a56af7 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -182,6 +182,8 @@ productsApp.controller "AdminBulkProductsCtrl", [ $scope.loadVariantUnit = (product) -> product.variant_unit_with_scale = if product.variant_unit && product.variant_unit_scale "#{product.variant_unit}_#{product.variant_unit_scale}" + else if product.variant_unit + product.variant_unit else null diff --git a/spec/javascripts/unit/bulk_product_update_spec.js.coffee b/spec/javascripts/unit/bulk_product_update_spec.js.coffee index c42028a2b9..282811aa3f 100644 --- a/spec/javascripts/unit/bulk_product_update_spec.js.coffee +++ b/spec/javascripts/unit/bulk_product_update_spec.js.coffee @@ -386,10 +386,10 @@ describe "AdminBulkProductsCtrl", -> scope.loadVariantUnit product expect(product.variant_unit_with_scale).toBeNull() - it 'sets variant_unit_with_scale to null when variant_unit_scale is null', -> - product = {variant_unit: 'weight', variant_unit_scale: null} + it 'sets variant_unit_with_scale to variant_unit when variant_unit_scale is null', -> + product = {variant_unit: 'items', variant_unit_scale: null, variant_unit_name: 'foo'} scope.loadVariantUnit product - expect(product.variant_unit_with_scale).toBeNull() + expect(product.variant_unit_with_scale).toEqual "items" describe "getting on_hand counts when products have variants", ->