mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Reworking our bindings so everything stacks on objects and automagically updates
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Shop.controller "OrderCycleCtrl", ($scope, $rootScope, OrderCycle) ->
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
$scope.changeOrderCycle = ->
|
||||
OrderCycle.set_order_cycle()
|
||||
OrderCycle.push_order_cycle()
|
||||
|
||||
@@ -4,8 +4,7 @@ Shop.factory 'OrderCycle', ($resource, Product) ->
|
||||
order_cycle_id: null
|
||||
}
|
||||
|
||||
@set_order_cycle: (id)->
|
||||
@order_cycle.order_cycle_id = id
|
||||
new $resource("/shop/order_cycle").save {order_cycle_id: id}, ->
|
||||
@push_order_cycle: ->
|
||||
new $resource("/shop/order_cycle").save {order_cycle_id: @order_cycle.order_cycle_id}, ->
|
||||
Product.update()
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ describe 'OrderCycle service', ->
|
||||
it "posts the order_cycle ID and tells product to update", ->
|
||||
$httpBackend.expectPOST("/shop/order_cycle", {"order_cycle_id" : 10}).respond(200)
|
||||
spyOn(mockProduct, "update")
|
||||
OrderCycle.set_order_cycle(10)
|
||||
OrderCycle.order_cycle.order_cycle_id = 10
|
||||
OrderCycle.push_order_cycle()
|
||||
$httpBackend.flush()
|
||||
expect(mockProduct.update).toHaveBeenCalled()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user