Fixing up the tests with some refactoring

This commit is contained in:
Will Marshall
2013-12-11 15:33:57 +11:00
parent 71a5d84a1d
commit bc4f472523
7 changed files with 19 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product) ->
$scope.products = Product.all()
$scope.data = Product.data
Product.update()
#$scope.order_cycle = OrderCycle.order_cycle

View File

@@ -4,7 +4,8 @@ Shop.factory 'OrderCycle', ($resource, Product) ->
order_cycle_id: null
}
@set_order_cycle: ->
new $resource("/shop/order_cycle").save {order_cycle_id: @order_cycle.order_cycle_id}, ->
@set_order_cycle: (id)->
@order_cycle.order_cycle_id = id
new $resource("/shop/order_cycle").save {order_cycle_id: id}, ->
Product.update()

View File

@@ -1,9 +1,11 @@
Shop.factory 'Product', ($resource) ->
new class Product
@products: null
data: {
products: null
}
update: ->
@products = $resource("/shop/products").query()
console.log @products
@products
@data.products = $resource("/shop/products").query =>
#console.log @products
@data
all: ->
@products || @update()
@data.products || @update()