mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 07:00:47 +02:00
deal with users who may have been deleted but are still inside a subscription group
This commit is contained in:
@@ -28,6 +28,9 @@ module.exports =
|
||||
jobs = _.map subscription.member_ids, (user_id)->
|
||||
return (cb)->
|
||||
UserLocator.findById user_id, (err, user)->
|
||||
if err? or !user?
|
||||
users.push _id:user_id
|
||||
return cb()
|
||||
userViewModel = buildUserViewModel(user)
|
||||
users.push(userViewModel)
|
||||
cb()
|
||||
|
||||
@@ -76,11 +76,13 @@ describe "Subscription Group Handler", ->
|
||||
@UserLocator.findById.callsArgWith(1, null, {_id:"31232"})
|
||||
|
||||
it "should locate the subscription", (done)->
|
||||
@UserLocator.findById.callsArgWith(1, null, {_id:"31232"})
|
||||
@Handler.getPopulatedListOfMembers @adminUser_id, (err, users)=>
|
||||
@SubscriptionLocator.getUsersSubscription.calledWith(@adminUser_id).should.equal true
|
||||
done()
|
||||
|
||||
it "should get the users by id", (done)->
|
||||
@UserLocator.findById.callsArgWith(1, null, {_id:"31232"})
|
||||
@subscription.member_ids = ["1234", "342432", "312312"]
|
||||
@Handler.getPopulatedListOfMembers @adminUser_id, (err, users)=>
|
||||
@UserLocator.findById.calledWith(@subscription.member_ids[0]).should.equal true
|
||||
@@ -88,3 +90,13 @@ describe "Subscription Group Handler", ->
|
||||
@UserLocator.findById.calledWith(@subscription.member_ids[2]).should.equal true
|
||||
users.length.should.equal @subscription.member_ids.length
|
||||
done()
|
||||
|
||||
it "should just return the id if the user can not be found as they may have deleted their account", (done)->
|
||||
@UserLocator.findById.callsArgWith(1)
|
||||
@subscription.member_ids = ["1234", "342432", "312312"]
|
||||
@Handler.getPopulatedListOfMembers @adminUser_id, (err, users)=>
|
||||
assert.deepEqual users[0], {_id:@subscription.member_ids[0]}
|
||||
assert.deepEqual users[1], {_id:@subscription.member_ids[1]}
|
||||
assert.deepEqual users[2], {_id:@subscription.member_ids[2]}
|
||||
done()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user