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:
Thomas
2022-04-29 08:03:26 +00:00
committed by Copybot
parent ebc24c5bf9
commit ba3d278bd9
2 changed files with 30 additions and 2 deletions
@@ -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()