mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Changed name enable_reset to resettable in Variant Overrides table & updated views, specs accordingly
This commit is contained in:
committed by
Rob Harrington
parent
25454d3e97
commit
e423e890e0
@@ -1,9 +1,9 @@
|
||||
describe "VariantOverrides service", ->
|
||||
VariantOverrides = $httpBackend = null
|
||||
variantOverrides = [
|
||||
{id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: ''}
|
||||
{id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: ''}
|
||||
{id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: ''}
|
||||
{id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: '', resettable: false}
|
||||
{id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: '', resettable: false}
|
||||
{id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: '', resettable: false}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
@@ -19,10 +19,10 @@ describe "VariantOverrides service", ->
|
||||
it "indexes variant overrides by hub_id -> variant_id", ->
|
||||
expect(VariantOverrides.variantOverrides).toEqual
|
||||
10:
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: ''}
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: ''}
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: '', resettable: false}
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: '', resettable: false}
|
||||
20:
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: ''}
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: '', resettable: false}
|
||||
|
||||
it "ensures blank data available for some products", ->
|
||||
hubs = [{id: 10}, {id: 20}, {id: 30}]
|
||||
@@ -35,32 +35,32 @@ describe "VariantOverrides service", ->
|
||||
VariantOverrides.ensureDataFor hubs, products
|
||||
expect(VariantOverrides.variantOverrides).toEqual
|
||||
10:
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: ''}
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: ''}
|
||||
300: { hub_id: 10, variant_id: 300, price: '', count_on_hand: '', default_stock: ''}
|
||||
400: { hub_id: 10, variant_id: 400, price: '', count_on_hand: '', default_stock: ''}
|
||||
500: { hub_id: 10, variant_id: 500, price: '', count_on_hand: '', default_stock: ''}
|
||||
100: {id: 1, hub_id: 10, variant_id: 100, price: 1, count_on_hand: 1, default_stock: '', resettable: false}
|
||||
200: {id: 2, hub_id: 10, variant_id: 200, price: 2, count_on_hand: 2, default_stock: '', resettable: false}
|
||||
300: { hub_id: 10, variant_id: 300, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
400: { hub_id: 10, variant_id: 400, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
500: { hub_id: 10, variant_id: 500, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
20:
|
||||
100: { hub_id: 20, variant_id: 100, price: '', count_on_hand: '', default_stock: ''}
|
||||
200: { hub_id: 20, variant_id: 200, price: '', count_on_hand: '', default_stock: ''}
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: ''}
|
||||
400: { hub_id: 20, variant_id: 400, price: '', count_on_hand: '', default_stock: ''}
|
||||
500: { hub_id: 20, variant_id: 500, price: '', count_on_hand: '', default_stock: ''}
|
||||
100: { hub_id: 20, variant_id: 100, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
200: { hub_id: 20, variant_id: 200, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
300: {id: 3, hub_id: 20, variant_id: 300, price: 3, count_on_hand: 3, default_stock: '', resettable: false}
|
||||
400: { hub_id: 20, variant_id: 400, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
500: { hub_id: 20, variant_id: 500, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
30:
|
||||
100: { hub_id: 30, variant_id: 100, price: '', count_on_hand: '', default_stock: ''}
|
||||
200: { hub_id: 30, variant_id: 200, price: '', count_on_hand: '', default_stock: ''}
|
||||
300: { hub_id: 30, variant_id: 300, price: '', count_on_hand: '', default_stock: ''}
|
||||
400: { hub_id: 30, variant_id: 400, price: '', count_on_hand: '', default_stock: ''}
|
||||
500: { hub_id: 30, variant_id: 500, price: '', count_on_hand: '', default_stock: ''}
|
||||
100: { hub_id: 30, variant_id: 100, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
200: { hub_id: 30, variant_id: 200, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
300: { hub_id: 30, variant_id: 300, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
400: { hub_id: 30, variant_id: 400, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
500: { hub_id: 30, variant_id: 500, price: '', count_on_hand: '', default_stock: '', resettable: false}
|
||||
|
||||
it "updates the IDs of variant overrides", ->
|
||||
VariantOverrides.variantOverrides[2] = {}
|
||||
VariantOverrides.variantOverrides[2][3] = {hub_id: 2, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: ''}
|
||||
VariantOverrides.variantOverrides[2][8] = {hub_id: 2, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: ''}
|
||||
VariantOverrides.variantOverrides[2][3] = {hub_id: 2, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: '', resettable: false}
|
||||
VariantOverrides.variantOverrides[2][8] = {hub_id: 2, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: '', resettable: false}
|
||||
|
||||
updatedVos = [
|
||||
{id: 1, hub_id: 2, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: ''}
|
||||
{id: 6, hub_id: 2, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: ''}
|
||||
{id: 1, hub_id: 2, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: '', resettable: false}
|
||||
{id: 6, hub_id: 2, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: '', resettable: false}
|
||||
]
|
||||
|
||||
VariantOverrides.updateIds updatedVos
|
||||
@@ -75,14 +75,14 @@ describe "VariantOverrides service", ->
|
||||
|
||||
it "updates the variant overrides on the page with new data", ->
|
||||
VariantOverrides.variantOverrides[1] =
|
||||
3: {id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: 3}
|
||||
8: {id: 2, hub_id: 1, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: ''}
|
||||
3: {id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 5, default_stock: 3, resettable: true}
|
||||
8: {id: 2, hub_id: 1, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: '', resettable: false}
|
||||
# Updated count on hand to 3
|
||||
updatedVos = [
|
||||
{id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 3, default_stock: 3}
|
||||
{id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 3, default_stock: 3, resettable: true}
|
||||
]
|
||||
|
||||
VariantOverrides.updateData(updatedVos)
|
||||
expect(VariantOverrides.variantOverrides[1]).toEqual
|
||||
3: {id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 3, default_stock: 3}
|
||||
8: {id: 2, hub_id: 1, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: ''}
|
||||
3: {id: 1, hub_id: 1, variant_id: 3, price: "4.0", count_on_hand: 3, default_stock: 3, resettable: true}
|
||||
8: {id: 2, hub_id: 1, variant_id: 8, price: "9.0", count_on_hand: 10, default_stock: '', resettable: false}
|
||||
|
||||
Reference in New Issue
Block a user