mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Make sure userSelect directive uses our Admin::UserSerializer instead of base Spree api view
This commit is contained in:
committed by
Rob Harrington
parent
ec5ce45850
commit
b893dea810
@@ -46,6 +46,7 @@ angular.module("admin.enterprises")
|
||||
manager =
|
||||
id: manager.id
|
||||
email: manager.email
|
||||
confirmed: manager.confirmed
|
||||
if (user for user in $scope.Enterprise.users when user.id == manager.id).length == 0
|
||||
$scope.Enterprise.users.push manager
|
||||
else
|
||||
|
||||
@@ -13,7 +13,7 @@ Spree::Admin::SearchController.class_eval do
|
||||
}).result.limit(10)
|
||||
end
|
||||
|
||||
render :users
|
||||
render json: @users, each_serializer: Api::Admin::UserSerializer
|
||||
end
|
||||
|
||||
def customers
|
||||
|
||||
@@ -35,29 +35,29 @@ describe "enterpriseCtrl", ->
|
||||
describe "adding managers", ->
|
||||
u1 = u2 = u3 = null
|
||||
beforeEach ->
|
||||
u1 = { id: 1, email: 'name1@email.com' }
|
||||
u2 = { id: 2, email: 'name2@email.com' }
|
||||
u3 = { id: 3, email: 'name3@email.com' }
|
||||
u1 = { id: 1, email: 'name1@email.com', confirmed: true }
|
||||
u2 = { id: 2, email: 'name2@email.com', confirmed: true }
|
||||
u3 = { id: 3, email: 'name3@email.com', confirmed: true }
|
||||
enterprise.users = [u1, u2 ,u3]
|
||||
|
||||
it "adds a user to the list", ->
|
||||
u4 = { id: 4, email: "name4@email.com" }
|
||||
u4 = { id: 4, email: "name4@email.com", confirmed: true }
|
||||
scope.addManager u4
|
||||
expect(enterprise.users).toContain u4
|
||||
|
||||
it "ignores object without an id", ->
|
||||
u4 = { not_id: 4, email: "name4@email.com" }
|
||||
u4 = { not_id: 4, email: "name4@email.com", confirmed: true }
|
||||
scope.addManager u4
|
||||
expect(enterprise.users).not.toContain u4
|
||||
|
||||
it "it ignores objects without an email", ->
|
||||
u4 = { id: 4, not_email: "name4@email.com" }
|
||||
u4 = { id: 4, not_email: "name4@email.com", confirmed: true }
|
||||
scope.addManager u4
|
||||
expect(enterprise.users).not.toContain u4
|
||||
|
||||
it "ignores objects that are already in the list, and alerts the user", ->
|
||||
spyOn(window, "alert").and.callThrough()
|
||||
u4 = { id: 3, email: "email-doesn't-matter.com" }
|
||||
u4 = { id: 3, email: "email-doesn't-matter.com", confirmed: true }
|
||||
scope.addManager u4
|
||||
expect(enterprise.users).not.toContain u4
|
||||
expect(window.alert).toHaveBeenCalledWith "email-doesn't-matter.com is already a manager!"
|
||||
@@ -66,9 +66,9 @@ describe "enterpriseCtrl", ->
|
||||
describe "removing managers", ->
|
||||
u1 = u2 = u3 = null
|
||||
beforeEach ->
|
||||
u1 = { id: 1, email: 'name1@email.com' }
|
||||
u2 = { id: 2, email: 'name2@email.com' }
|
||||
u3 = { id: 3, email: 'name3@email.com' }
|
||||
u1 = { id: 1, email: 'name1@email.com', confirmed: true }
|
||||
u2 = { id: 2, email: 'name2@email.com', confirmed: true }
|
||||
u3 = { id: 3, email: 'name3@email.com', confirmed: true }
|
||||
enterprise.users = [u1, u2 ,u3]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user