Make VO count on hand readonly unless limited stock

This commit is contained in:
Kristina Lim
2018-11-29 04:08:08 +08:00
parent cc003c99d5
commit 09b9f968b7
4 changed files with 9 additions and 53 deletions

View File

@@ -89,36 +89,6 @@ describe "VariantOverridesCtrl", ->
expect(StatusMessage.display).toHaveBeenCalledWith 'success', 'Stocks reset to defaults.'
describe "ensuring that on demand and count on hand settings are compatible", ->
describe "changing to limited stock when count on hand is set", ->
beforeEach ->
scope.variantOverrides = {123: {2: {id: 5, on_demand: true}}}
describe "when count on hand is set", ->
beforeEach ->
scope.variantOverrides[123][2].count_on_hand = 1
it "changes to limited stock and registers dirty attribute", ->
scope.selectLimitedStockIfCountOnHandSet(123, 2)
expect(scope.variantOverrides[123][2].on_demand).toBe(false)
dirtyVariantOverride = DirtyVariantOverrides.dirtyVariantOverrides[123][2]
expect(dirtyVariantOverride.on_demand).toBe(false)
describe "when count on hand is null", ->
beforeEach ->
scope.variantOverrides[123][2].count_on_hand = null
it "does not change to limited stock", ->
scope.selectLimitedStockIfCountOnHandSet(123, 2)
expect(scope.variantOverrides[123][2].on_demand).toBe(true)
describe "when count on hand is blank string", ->
beforeEach ->
scope.variantOverrides[123][2].count_on_hand = ''
it "does not change to limited stock", ->
scope.selectLimitedStockIfCountOnHandSet(123, 2)
expect(scope.variantOverrides[123][2].on_demand).toBe(true)
describe "clearing count on hand when not limited stock", ->
beforeEach ->
scope.variantOverrides = {123: {2: {id: 5, count_on_hand: 1}}}