Using events to update index row text on save, adding alert icons for enterprises without producer or package selected

This commit is contained in:
Rob Harrington
2015-06-11 13:47:02 +08:00
parent 95073f6fe7
commit 1c1f82f4ee
7 changed files with 192 additions and 135 deletions

View File

@@ -21,6 +21,7 @@ describe "indexPanelCtrl", ->
beforeEach inject ($q) ->
spyOn(scope, "saved").andReturn false
spyOn(scope, "$emit")
deferred = $q.defer()
spyOn(Enterprises, "save").andReturn(deferred.promise)
scope.save()
@@ -33,10 +34,12 @@ describe "indexPanelCtrl", ->
deferred.resolve()
$rootScope.$digest()
it "sets scope.saving to false", ->
expect(scope.saving).toBe false
it "emits an 'enterprise:updated' event", ->
expect(scope.$emit).toHaveBeenCalledWith("enterprise:updated")
describe "when the save is unsuccessful", ->
beforeEach inject ($rootScope) ->
deferred.reject({ status: 404 })
@@ -44,3 +47,6 @@ describe "indexPanelCtrl", ->
it "sets scope.saving to false", ->
expect(scope.saving).toBe false
it "does not emit an 'enterprise:updated' event", ->
expect(scope.$emit).not.toHaveBeenCalled()