Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created December 11, 2013 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrjmarshall/7902875 to your computer and use it in GitHub Desktop.
Save willrjmarshall/7902875 to your computer and use it in GitHub Desktop.
describe 'OrderCycle service', ->
$httpBackend = null
OrderCycle = null
Product = {
all: -> {}
}
beforeEach ->
module 'Shop', ($provide) ->
$provide.value('Product', Product);
inject (_OrderCycle_, _$httpBackend_, _Product_)->
OrderCycle = _OrderCycle_
$httpBackend = _$httpBackend_
it "posts the order_cycle ID and tells product to update", ->
$httpBackend.expectPOST("/shop/order_cycle", {"order_cycle_id" : 10}).respond(200)
spyOn(Product, "all")
OrderCycle.set_order_cycle(10)
$httpBackend.flush()
expect(Product.all).toHaveBeenCalled()
Shop.factory 'OrderCycle', ($resource, Product) ->
class OrderCycle
@order_cycle = {
order_cycle_id: null
}
@set_order_cycle: (id = null)->
new $resource("/shop/order_cycle").save {order_cycle_id: id}, ->
Product.all()
console.log "response"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment