mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Make VO count on hand readonly unless limited stock
This commit is contained in:
@@ -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}}}
|
||||
|
||||
Reference in New Issue
Block a user