mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Fix subscription check for upgrade prompts in editor (#7799)
* Fix subscription check for upgrade prompts in editor GitOrigin-RevId: ec6d117748e4017ae189038e56363c4a7366f2b4
This commit is contained in:
parent
ebc24c5bf9
commit
ba3d278bd9
2 changed files with 30 additions and 2 deletions
|
@ -776,6 +776,17 @@ const ProjectController = {
|
|||
}
|
||||
SubscriptionLocator.getUsersSubscription(userId, cb)
|
||||
},
|
||||
userIsMemberOfGroupSubscription(cb) {
|
||||
if (sessionUser == null) {
|
||||
return cb(null, false)
|
||||
}
|
||||
LimitationsManager.userIsMemberOfGroupSubscription(
|
||||
sessionUser,
|
||||
(error, isMember) => {
|
||||
cb(error, isMember)
|
||||
}
|
||||
)
|
||||
},
|
||||
activate(cb) {
|
||||
InactiveProjectManager.reactivateProjectIfRequired(projectId, cb)
|
||||
},
|
||||
|
@ -906,6 +917,7 @@ const ProjectController = {
|
|||
userHasInstitutionLicence,
|
||||
learnedWords,
|
||||
subscription,
|
||||
userIsMemberOfGroupSubscription,
|
||||
isTokenMember,
|
||||
brandVariation,
|
||||
newSourceEditorAssignment,
|
||||
|
@ -1023,6 +1035,7 @@ const ProjectController = {
|
|||
'persistent-upgrade' &&
|
||||
userId &&
|
||||
!subscription &&
|
||||
!userIsMemberOfGroupSubscription &&
|
||||
!userHasInstitutionLicence
|
||||
|
||||
const template =
|
||||
|
|
|
@ -55,7 +55,12 @@ describe('ProjectController', function () {
|
|||
.callsArgWith(2, null, { _id: this.project_id }),
|
||||
}
|
||||
this.SubscriptionLocator = { getUsersSubscription: sinon.stub() }
|
||||
this.LimitationsManager = { hasPaidSubscription: sinon.stub() }
|
||||
this.LimitationsManager = {
|
||||
hasPaidSubscription: sinon.stub(),
|
||||
userIsMemberOfGroupSubscription: sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, false),
|
||||
}
|
||||
this.TagsHandler = { getAllTags: sinon.stub() }
|
||||
this.NotificationsHandler = { getUserNotifications: sinon.stub() }
|
||||
this.UserModel = { findById: sinon.stub(), updateOne: sinon.stub() }
|
||||
|
@ -1527,7 +1532,7 @@ describe('ProjectController', function () {
|
|||
}
|
||||
this.ProjectController.loadEditor(this.req, this.res)
|
||||
})
|
||||
it('should not show for a user with a subscription', function (done) {
|
||||
it('should not show for a user with a personal subscription', function (done) {
|
||||
this.SubscriptionLocator.getUsersSubscription = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, {})
|
||||
|
@ -1537,6 +1542,16 @@ describe('ProjectController', function () {
|
|||
}
|
||||
this.ProjectController.loadEditor(this.req, this.res)
|
||||
})
|
||||
it('should not show for a user who is a member of a group subscription', function (done) {
|
||||
this.LimitationsManager.userIsMemberOfGroupSubscription = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, true)
|
||||
this.res.render = (pageName, opts) => {
|
||||
expect(opts.showHeaderUpgradePrompt).to.equal(false)
|
||||
done()
|
||||
}
|
||||
this.ProjectController.loadEditor(this.req, this.res)
|
||||
})
|
||||
it('should not show for a user with an affiliated paid university', function (done) {
|
||||
this.InstitutionsFeatures.hasLicence = sinon
|
||||
.stub()
|
||||
|
|
Loading…
Reference in a new issue