Merge pull request #25983 from overleaf/ii-managed-users-make-unmanaged-roles-access
[web] Prevent managers from removing/deleting themselves GitOrigin-RevId: 9287dc06bab8024bf03fecff678a4118a9456919
This commit is contained in:
@@ -13,6 +13,11 @@ describe('Subscription Locator Tests', function () {
|
||||
exec: sinon.stub().resolves(),
|
||||
}),
|
||||
find: sinon.stub().returns({
|
||||
populate: sinon.stub().returns({
|
||||
populate: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves([]),
|
||||
}),
|
||||
}),
|
||||
exec: sinon.stub().resolves(),
|
||||
}),
|
||||
}
|
||||
@@ -77,4 +82,110 @@ describe('Subscription Locator Tests', function () {
|
||||
subscription.should.equal(this.subscription)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getUserSubscriptionStatus', function () {
|
||||
it('should return no active personal or group subscription when no user is passed', async function () {
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
undefined
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({
|
||||
personal: false,
|
||||
group: false,
|
||||
})
|
||||
})
|
||||
|
||||
it('should return no active personal or group subscription when the user has no subscription', async function () {
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
this.user._id
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({
|
||||
personal: false,
|
||||
group: false,
|
||||
})
|
||||
})
|
||||
|
||||
it('should return active personal subscription', async function () {
|
||||
this.Subscription.findOne.returns({
|
||||
exec: sinon.stub().resolves({
|
||||
recurlyStatus: {
|
||||
state: 'active',
|
||||
},
|
||||
}),
|
||||
})
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
this.user._id
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({ personal: true, group: false })
|
||||
})
|
||||
|
||||
it('should return active group subscription when member of a group plan', async function () {
|
||||
this.Subscription.find.returns({
|
||||
populate: sinon.stub().returns({
|
||||
populate: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves([
|
||||
{
|
||||
recurlyStatus: {
|
||||
state: 'active',
|
||||
},
|
||||
groupPlan: true,
|
||||
},
|
||||
]),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
this.user._id
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({ personal: false, group: true })
|
||||
})
|
||||
|
||||
it('should return active group subscription when owner of a group plan', async function () {
|
||||
this.Subscription.findOne.returns({
|
||||
exec: sinon.stub().resolves({
|
||||
recurlyStatus: {
|
||||
state: 'active',
|
||||
},
|
||||
groupPlan: true,
|
||||
}),
|
||||
})
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
this.user._id
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({ personal: false, group: true })
|
||||
})
|
||||
|
||||
it('should return active personal and group subscription when has personal subscription and member of a group', async function () {
|
||||
this.Subscription.find.returns({
|
||||
populate: sinon.stub().returns({
|
||||
populate: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves([
|
||||
{
|
||||
recurlyStatus: {
|
||||
state: 'active',
|
||||
},
|
||||
groupPlan: true,
|
||||
},
|
||||
]),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
this.Subscription.findOne.returns({
|
||||
exec: sinon.stub().resolves({
|
||||
recurlyStatus: {
|
||||
state: 'active',
|
||||
},
|
||||
}),
|
||||
})
|
||||
const subscriptionStatus =
|
||||
await this.SubscriptionLocator.promises.getUserSubscriptionStatus(
|
||||
this.user._id
|
||||
)
|
||||
expect(subscriptionStatus).to.deep.equal({ personal: true, group: true })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -184,6 +184,7 @@ describe('UserMembershipController', function () {
|
||||
expect(viewParams.users).to.deep.equal(ctx.users)
|
||||
expect(viewParams.groupSize).to.equal(ctx.subscription.membersLimit)
|
||||
expect(viewParams.managedUsersActive).to.equal(true)
|
||||
expect(viewParams.isUserGroupManager).to.equal(false)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user