Adding flash notifications

This commit is contained in:
Will Marshall
2014-04-17 15:08:01 +10:00
parent 3b440ed027
commit c6395a686a
11 changed files with 55 additions and 9 deletions

View File

@@ -3,4 +3,4 @@
//= require angular-animate
//= require angular-mocks
//= require angular-cookies
//
//= require angular-flash.min.js

View File

@@ -3,6 +3,7 @@ describe 'Order service', ->
orderData = null
$httpBackend = null
CheckoutFormState = null
flash = null
beforeEach ->
orderData = {
@@ -27,6 +28,7 @@ describe 'Order service', ->
inject ($injector, _$httpBackend_)->
$httpBackend = _$httpBackend_
Order = $injector.get("Order")
flash = $injector.get("flash")
CheckoutFormState = $injector.get("CheckoutFormState")
spyOn(Order, "navigate") # Stubbing out writes to window.location
@@ -58,6 +60,19 @@ describe 'Order service', ->
Order.submit()
$httpBackend.flush()
it "sends flash messages to the flash service", ->
$httpBackend.expectPUT("/shop/checkout").respond 400, {flash: {error: "frogs"}}
Order.submit()
$httpBackend.flush()
expect(flash.error).toEqual "frogs"
it "puts errors into the scope", ->
$httpBackend.expectPUT("/shop/checkout").respond 400, {errors: {error: "frogs"}}
Order.submit()
$httpBackend.flush()
expect(Order.errors).toEqual {error: "frogs"}
it "Munges the order attributes to add _attributes as Rails needs", ->
expect(Order.preprocess().bill_address_attributes).not.toBe(undefined)
expect(Order.preprocess().bill_address).toBe(undefined)