Merge branch 'master' into bom

This commit is contained in:
Rob H
2014-01-31 12:32:23 +08:00
38 changed files with 728 additions and 117 deletions

View File

@@ -466,6 +466,35 @@ describe "AdminProductEditCtrl", ->
expect(scope.variantUnitValue(product, variant)).toEqual null
describe "updating the product on hand count", ->
it "updates when product is not available on demand", ->
spyOn(scope, "onHand").andReturn 123
product = {on_demand: false}
scope.updateOnHand(product)
expect(product.on_hand).toEqual 123
it "updates when product's variants are not available on demand", ->
spyOn(scope, "onHand").andReturn 123
product = {on_demand: false, variants: [{on_demand: false}]}
scope.updateOnHand(product)
expect(product.on_hand).toEqual 123
it "does nothing when the product is available on demand", ->
product = {on_demand: true}
scope.updateOnHand(product)
expect(product.on_hand).toBeUndefined()
it "does nothing when one of the variants is available on demand", ->
product =
on_demand: false
variants: [
{on_demand: false, on_hand: 10}
{on_demand: true, on_hand: Infinity}
]
scope.updateOnHand(product)
expect(product.on_hand).toBeUndefined()
describe "getting on_hand counts when products have variants", ->
p1 = undefined
p2 = undefined
@@ -526,6 +555,24 @@ describe "AdminProductEditCtrl", ->
expect(scope.onHand(not_variants: [])).toEqual "error"
describe "determining whether a product has variants that are available on demand", ->
it "returns true when at least one variant does", ->
product =
variants: [
{on_demand: false}
{on_demand: true}
]
expect(scope.hasOnDemandVariants(product)).toBe(true)
it "returns false otherwise", ->
product =
variants: [
{on_demand: false}
{on_demand: false}
]
expect(scope.hasOnDemandVariants(product)).toBe(false)
describe "submitting products to be updated", ->
describe "packing products", ->
it "extracts variant_unit_with_scale into variant_unit and variant_unit_scale", ->