mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #853 from sharelatex/ta-institution-features-fix
Check Institution Confirmation Status
This commit is contained in:
commit
946726c898
3 changed files with 17 additions and 7 deletions
|
@ -7,7 +7,7 @@ module.exports = InstitutionsGetter =
|
|||
return callback error if error?
|
||||
|
||||
confirmedInstitutions = emailsData.filter (emailData) ->
|
||||
emailData.confirmedAt? and emailData.affiliation?.institution?
|
||||
emailData.confirmedAt? and emailData.affiliation?.institution?.confirmed
|
||||
.map (emailData) ->
|
||||
emailData.affiliation?.institution
|
||||
|
||||
|
|
|
@ -89,22 +89,31 @@ describe "FeatureUpdater.refreshFeatures", ->
|
|||
@institutionPlan = settings.plans.find (plan) ->
|
||||
plan.planCode == settings.institutionPlanCode
|
||||
@email = @user.emails[0].email
|
||||
affiliationData =
|
||||
@affiliationData =
|
||||
email: @email
|
||||
institution: { licence: 'pro_plus' }
|
||||
MockV1Api.setAffiliations [affiliationData]
|
||||
institution: { licence: 'pro_plus', confirmed: true }
|
||||
|
||||
it "should not set their features if email is not confirmed", (done) ->
|
||||
MockV1Api.setAffiliations [@affiliationData]
|
||||
syncUserAndGetFeatures @user, (error, features) =>
|
||||
expect(features).to.deep.equal(settings.defaultFeatures)
|
||||
done()
|
||||
|
||||
it "should set their features if email is confirmed", (done) ->
|
||||
MockV1Api.setAffiliations [@affiliationData]
|
||||
@user.confirmEmail @email, (error) =>
|
||||
syncUserAndGetFeatures @user, (error, features) =>
|
||||
expect(features).to.deep.equal(@institutionPlan.features)
|
||||
done()
|
||||
|
||||
it "should not set their features if institution is not confirmed", (done) ->
|
||||
@affiliationData.institution.confirmed = false
|
||||
MockV1Api.setAffiliations [@affiliationData]
|
||||
@user.confirmEmail @email, (error) =>
|
||||
syncUserAndGetFeatures @user, (error, features) =>
|
||||
expect(features).to.deep.equal(settings.defaultFeatures)
|
||||
done()
|
||||
|
||||
describe "when the user is due bonus features and has extra features that no longer apply", ->
|
||||
beforeEach ->
|
||||
User.update {
|
||||
|
|
|
@ -16,12 +16,13 @@ describe 'InstitutionsGetter', ->
|
|||
@userId = '12345abcde'
|
||||
|
||||
describe "getConfirmedInstitutions", ->
|
||||
it 'filters unconfirmed emails', (done) ->
|
||||
it 'filters unconfirmed affiliations', (done) ->
|
||||
@userEmails = [
|
||||
{ confirmedAt: null, affiliation: institution: { id: 123 } }
|
||||
{ confirmedAt: new Date(), affiliation: institution: { id: 456 } }
|
||||
{ confirmedAt: null, affiliation: institution: { id: 123, confirmed: true } }
|
||||
{ confirmedAt: new Date(), affiliation: institution: { id: 456, confirmed: true } }
|
||||
{ confirmedAt: new Date(), affiliation: null }
|
||||
{ confirmedAt: new Date(), affiliation: institution: null }
|
||||
{ confirmedAt: new Date(), affiliation: institution: { id: 789, confirmed: false } }
|
||||
]
|
||||
@UserGetter.getUserFullEmails.yields(null, @userEmails)
|
||||
@InstitutionsGetter.getConfirmedInstitutions @userId, (error, institutions) ->
|
||||
|
|
Loading…
Reference in a new issue