mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove Angular and Stimulus Reflex from the Settings > Images section
This commit is contained in:
@@ -25,72 +25,6 @@ describe "enterpriseCtrl", ->
|
||||
it "stores enterprise", ->
|
||||
expect(scope.Enterprise).toEqual enterprise
|
||||
|
||||
describe "removing logo", ->
|
||||
deferred = null
|
||||
|
||||
beforeEach inject ($q) ->
|
||||
spyOn(scope, "$emit")
|
||||
deferred = $q.defer()
|
||||
spyOn(window, "confirm").and.returnValue(true)
|
||||
spyOn(Enterprises, "removeLogo").and.returnValue(deferred.promise)
|
||||
spyOn(StatusMessage, "display").and.callThrough()
|
||||
scope.removeLogo()
|
||||
|
||||
describe "when successful", ->
|
||||
beforeEach inject ($rootScope) ->
|
||||
deferred.resolve()
|
||||
$rootScope.$digest()
|
||||
|
||||
it "emits an 'enterprise:updated' event", ->
|
||||
expect(scope.$emit).toHaveBeenCalledWith("enterprise:updated", scope.Enterprise)
|
||||
|
||||
it "notifies user of success", ->
|
||||
expect(StatusMessage.display).toHaveBeenCalledWith("success", "Logo removed successfully")
|
||||
|
||||
describe "when unsuccessful", ->
|
||||
beforeEach inject ($rootScope) ->
|
||||
deferred.reject({ data: { error: "Logo does not exist" } })
|
||||
$rootScope.$digest()
|
||||
|
||||
it "does not emit an 'enterprise:updated' event", ->
|
||||
expect(scope.$emit).not.toHaveBeenCalled()
|
||||
|
||||
it "notifies user of failure", ->
|
||||
expect(StatusMessage.display).toHaveBeenCalledWith("failure", "Logo does not exist")
|
||||
|
||||
describe "removing promo image", ->
|
||||
deferred = null
|
||||
|
||||
beforeEach inject ($q) ->
|
||||
spyOn(scope, "$emit")
|
||||
deferred = $q.defer()
|
||||
spyOn(window, "confirm").and.returnValue(true)
|
||||
spyOn(Enterprises, "removePromoImage").and.returnValue(deferred.promise)
|
||||
spyOn(StatusMessage, "display").and.callThrough()
|
||||
scope.removePromoImage()
|
||||
|
||||
describe "when successful", ->
|
||||
beforeEach inject ($rootScope) ->
|
||||
deferred.resolve()
|
||||
$rootScope.$digest()
|
||||
|
||||
it "emits an 'enterprise:updated' event", ->
|
||||
expect(scope.$emit).toHaveBeenCalledWith("enterprise:updated", scope.Enterprise)
|
||||
|
||||
it "notifies user of success", ->
|
||||
expect(StatusMessage.display).toHaveBeenCalledWith("success", "Promo image removed successfully")
|
||||
|
||||
describe "when unsuccessful", ->
|
||||
beforeEach inject ($rootScope) ->
|
||||
deferred.reject({ data: { error: "Promo image does not exist" } })
|
||||
$rootScope.$digest()
|
||||
|
||||
it "does not emit an 'enterprise:updated' event", ->
|
||||
expect(scope.$emit).not.toHaveBeenCalled()
|
||||
|
||||
it "notifies user of failure", ->
|
||||
expect(StatusMessage.display).toHaveBeenCalledWith("failure", "Promo image does not exist")
|
||||
|
||||
describe "adding managers", ->
|
||||
u1 = u2 = u3 = null
|
||||
beforeEach ->
|
||||
|
||||
@@ -119,72 +119,3 @@ describe "Enterprises service", ->
|
||||
Enterprises.resetAttribute(enterprise, "name")
|
||||
expect(enterprise.name).toEqual "enterprise1"
|
||||
|
||||
describe "#removeLogo", ->
|
||||
enterprise = null
|
||||
|
||||
describe "success", ->
|
||||
resolved = false
|
||||
|
||||
beforeEach ->
|
||||
enterprise = new EnterpriseResource({ id: 15, permalink: "enterprise1", name: "Enterprise 1", logo: {} })
|
||||
$httpBackend.expectDELETE("/api/v0/enterprises/enterprise1/logo.json").respond 200, { id: 15, name: "Enterprise 1"}
|
||||
Enterprises.removeLogo(enterprise).then( -> resolved = true)
|
||||
$httpBackend.flush()
|
||||
|
||||
it "updates the pristine copy of the enterprise", ->
|
||||
expect(Enterprises.pristineByID[15]).not.toBeUndefined()
|
||||
expect(Enterprises.pristineByID[15]["id"]).toEqual(15)
|
||||
expect(Enterprises.pristineByID[15]["logo"]).toBeUndefined()
|
||||
|
||||
it "resolves the promise", ->
|
||||
expect(resolved).toBe(true)
|
||||
|
||||
describe "failure", ->
|
||||
rejected = false
|
||||
|
||||
beforeEach ->
|
||||
enterprise = new EnterpriseResource( { id: 15, permalink: "enterprise1", name: "Enterprise 1" } )
|
||||
$httpBackend.expectDELETE("/api/v0/enterprises/enterprise1/logo.json").respond 409, { error: "obj" }
|
||||
Enterprises.removeLogo(enterprise).catch( -> rejected = true)
|
||||
$httpBackend.flush()
|
||||
|
||||
it "does not update the pristine copy of the enterprise", ->
|
||||
expect(Enterprises.pristineByID[15]).toBeUndefined()
|
||||
|
||||
it "rejects the promise", ->
|
||||
expect(rejected).toBe(true)
|
||||
|
||||
describe "#removePromoImage", ->
|
||||
enterprise = null
|
||||
|
||||
describe "success", ->
|
||||
resolved = false
|
||||
|
||||
beforeEach ->
|
||||
enterprise = new EnterpriseResource({ id: 15, permalink: "enterprise1", name: "Enterprise 1", promo_image: {} })
|
||||
$httpBackend.expectDELETE("/api/v0/enterprises/enterprise1/promo_image.json").respond 200, { id: 15, name: "Enterprise 1"}
|
||||
Enterprises.removePromoImage(enterprise).then( -> resolved = true)
|
||||
$httpBackend.flush()
|
||||
|
||||
it "updates the pristine copy of the enterprise", ->
|
||||
expect(Enterprises.pristineByID[15]).not.toBeUndefined()
|
||||
expect(Enterprises.pristineByID[15]["id"]).toEqual(15)
|
||||
expect(Enterprises.pristineByID[15]["promo_image"]).toBeUndefined()
|
||||
|
||||
it "resolves the promise", ->
|
||||
expect(resolved).toBe(true)
|
||||
|
||||
describe "failure", ->
|
||||
rejected = false
|
||||
|
||||
beforeEach ->
|
||||
enterprise = new EnterpriseResource( { id: 15, permalink: "enterprise1", name: "Enterprise 1" } )
|
||||
$httpBackend.expectDELETE("/api/v0/enterprises/enterprise1/promo_image.json").respond 409, { error: "obj" }
|
||||
Enterprises.removePromoImage(enterprise).catch( -> rejected = true)
|
||||
$httpBackend.flush()
|
||||
|
||||
it "does not update the pristine copy of the enterprise", ->
|
||||
expect(Enterprises.pristineByID[15]).toBeUndefined()
|
||||
|
||||
it "rejects the promise", ->
|
||||
expect(rejected).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user