Use .all convention for shipping and payment methods resource services

This commit is contained in:
Rob Harrington
2018-02-19 13:46:09 +11:00
committed by Rob H
parent 8951c79f71
commit 3ac57269ed
6 changed files with 16 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
angular.module("admin.enterprises")
.factory "EnterprisePaymentMethods", (enterprise, PaymentMethods) ->
new class EnterprisePaymentMethods
paymentMethods: PaymentMethods.paymentMethods
paymentMethods: PaymentMethods.all
constructor: ->
for payment_method in @paymentMethods

View File

@@ -1,7 +1,7 @@
angular.module("admin.enterprises")
.factory "EnterpriseShippingMethods", (enterprise, ShippingMethods) ->
new class EnterpriseShippingMethods
shippingMethods: ShippingMethods.shippingMethods
shippingMethods: ShippingMethods.all
constructor: ->
for shipping_method in @shippingMethods

View File

@@ -1,7 +1,7 @@
angular.module("admin.resources")
.factory "PaymentMethods", ($injector) ->
new class PaymentMethods
paymentMethods: []
all: []
byID: {}
pristineByID: {}
@@ -11,6 +11,6 @@ angular.module("admin.resources")
load: (paymentMethods) ->
for paymentMethod in paymentMethods
@paymentMethods.push paymentMethod
@all.push paymentMethod
@byID[paymentMethod.id] = paymentMethod
@pristineByID[paymentMethod.id] = angular.copy(paymentMethod)

View File

@@ -1,7 +1,7 @@
angular.module("admin.resources")
.factory "ShippingMethods", ($injector) ->
new class ShippingMethods
shippingMethods: []
all: []
byID: {}
pristineByID: {}
@@ -11,6 +11,6 @@ angular.module("admin.resources")
load: (shippingMethods) ->
for shippingMethod in shippingMethods
@shippingMethods.push shippingMethod
@all.push shippingMethod
@byID[shippingMethod.id] = shippingMethod
@pristineByID[shippingMethod.id] = angular.copy(shippingMethod)

View File

@@ -7,7 +7,7 @@ describe "EnterprisePaymentMethods service", ->
enterprise =
payment_method_ids: [ 1, 3 ]
PaymentMethods =
paymentMethods: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
all: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
module 'admin.enterprises'
module ($provide) ->
@@ -20,10 +20,10 @@ describe "EnterprisePaymentMethods service", ->
describe "selecting payment methods", ->
it "sets the selected property of each payment method", ->
expect(PaymentMethods.paymentMethods[0].selected).toBe true
expect(PaymentMethods.paymentMethods[1].selected).toBe false
expect(PaymentMethods.paymentMethods[2].selected).toBe true
expect(PaymentMethods.paymentMethods[3].selected).toBe false
expect(PaymentMethods.all[0].selected).toBe true
expect(PaymentMethods.all[1].selected).toBe false
expect(PaymentMethods.all[2].selected).toBe true
expect(PaymentMethods.all[3].selected).toBe false
describe "determining payment method colour", ->
it "returns 'blue' when at least one payment method is selected", ->

View File

@@ -7,7 +7,7 @@ describe "EnterpriseShippingMethods service", ->
enterprise =
shipping_method_ids: [ 1, 3 ]
ShippingMethods =
shippingMethods: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
all: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ]
module 'admin.enterprises'
module ($provide) ->
@@ -20,10 +20,10 @@ describe "EnterpriseShippingMethods service", ->
describe "selecting shipping methods", ->
it "sets the selected property of each shipping method", ->
expect(ShippingMethods.shippingMethods[0].selected).toBe true
expect(ShippingMethods.shippingMethods[1].selected).toBe false
expect(ShippingMethods.shippingMethods[2].selected).toBe true
expect(ShippingMethods.shippingMethods[3].selected).toBe false
expect(ShippingMethods.all[0].selected).toBe true
expect(ShippingMethods.all[1].selected).toBe false
expect(ShippingMethods.all[2].selected).toBe true
expect(ShippingMethods.all[3].selected).toBe false
describe "determining shipping method colour", ->
it "returns 'blue' when at least one shipping method is selected", ->