mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Adding flash notifications
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
//= require angular-animate
|
||||
//= require angular-mocks
|
||||
//= require angular-cookies
|
||||
//
|
||||
//= require angular-flash.min.js
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user