Created
December 11, 2013 00:08
-
-
Save willrjmarshall/7902773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'OrderCycle service', -> | |
$httpBackend = null | |
OrderCycle = null | |
Product = { | |
all: -> {} | |
} | |
beforeEach -> | |
module 'Shop', ($provide) -> | |
$provide.value('Product', Product); | |
inject ($injector, _$httpBackend_, Product)-> | |
OrderCycle = $injector.get("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