mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #1444 from sharelatex/ta-ns-check-institution-users
add script to check all if users on institution are upgraded GitOrigin-RevId: 903f3a65fc038862178a82f43d97a5a4630cf470
This commit is contained in:
committed by
sharelatex
parent
7739e0ece8
commit
b311f997aa
@@ -3,6 +3,7 @@ SandboxedModule = require('sandboxed-module')
|
||||
path = require('path')
|
||||
sinon = require('sinon')
|
||||
modulePath = path.join __dirname, "../../../../app/js/Features/Institutions/InstitutionsManager"
|
||||
expect = require('chai').expect
|
||||
|
||||
describe "InstitutionsManager", ->
|
||||
beforeEach ->
|
||||
@@ -10,12 +11,15 @@ describe "InstitutionsManager", ->
|
||||
@logger = log: ->
|
||||
@getInstitutionAffiliations = sinon.stub()
|
||||
@refreshFeatures = sinon.stub().yields()
|
||||
@getUsersByAnyConfirmedEmail = sinon.stub().yields()
|
||||
@InstitutionsManager = SandboxedModule.require modulePath, requires:
|
||||
'logger-sharelatex': @logger
|
||||
'./InstitutionsAPI':
|
||||
getInstitutionAffiliations: @getInstitutionAffiliations
|
||||
'../Subscription/FeaturesUpdater':
|
||||
refreshFeatures: @refreshFeatures
|
||||
'../User/UserGetter':
|
||||
getUsersByAnyConfirmedEmail: @getUsersByAnyConfirmedEmail
|
||||
|
||||
describe 'upgradeInstitutionUsers', ->
|
||||
it 'refresh all users Features', (done) ->
|
||||
@@ -28,3 +32,33 @@ describe "InstitutionsManager", ->
|
||||
should.not.exist(error)
|
||||
sinon.assert.calledTwice(@refreshFeatures)
|
||||
done()
|
||||
|
||||
describe.only 'checkInstitutionUsers', ->
|
||||
it 'check all users Features', (done) ->
|
||||
affiliations = [
|
||||
{ email: 'foo@bar.com' }
|
||||
{ email: 'baz@boo.edu' }
|
||||
]
|
||||
stubbedUsers = [
|
||||
{
|
||||
_id: '123abc123abc123abc123abc'
|
||||
features: {collaborators: -1, trackChanges: true}
|
||||
}
|
||||
{
|
||||
_id: '456def456def456def456def'
|
||||
features: {collaborators: 10, trackChanges: false}
|
||||
}
|
||||
{
|
||||
_id: '789def789def789def789def'
|
||||
features: {collaborators: -1, trackChanges: false}
|
||||
}
|
||||
]
|
||||
@getInstitutionAffiliations.yields(null, affiliations)
|
||||
@getUsersByAnyConfirmedEmail.yields(null, stubbedUsers)
|
||||
@InstitutionsManager.checkInstitutionUsers @institutionId, (error, usersSummary) =>
|
||||
should.not.exist(error)
|
||||
usersSummary.totalConfirmedUsers.should.equal 3
|
||||
usersSummary.totalConfirmedProUsers.should.equal 1
|
||||
usersSummary.totalConfirmedNonProUsers.should.equal 2
|
||||
expect(usersSummary.confirmedNonProUsers).to.deep.equal ['456def456def456def456def', '789def789def789def789def']
|
||||
done()
|
||||
Reference in New Issue
Block a user