Merge pull request #16545 from overleaf/dp-project-owner-delete-labels

Allow project owners to delete history labels

GitOrigin-RevId: 16111337681ac4085db2cf48e9d4c2fa87993b77
This commit is contained in:
David
2024-01-23 09:03:08 +00:00
committed by Copybot
parent 4683cad1cb
commit e3513a9d50
11 changed files with 198 additions and 15 deletions
@@ -45,6 +45,7 @@ describe('HttpController', function () {
this.LabelsManager = {
createLabel: sinon.stub(),
deleteLabel: sinon.stub().yields(),
deleteLabelForUser: sinon.stub().yields(),
getLabels: sinon.stub(),
}
this.HistoryApiManager = {
@@ -75,6 +76,7 @@ describe('HttpController', function () {
})
this.pathname = 'doc-id-123'
this.projectId = new ObjectId().toString()
this.projectOwnerId = new ObjectId().toString()
this.next = sinon.stub()
this.userId = new ObjectId().toString()
this.now = Date.now()
@@ -473,7 +475,7 @@ describe('HttpController', function () {
})
})
describe('deleteLabel', function () {
describe('deleteLabelForUser', function () {
beforeEach(function () {
this.req = {
params: {
@@ -482,12 +484,34 @@ describe('HttpController', function () {
label_id: (this.label_id = new ObjectId()),
},
}
this.HttpController.deleteLabelForUser(this.req, this.res, this.next)
})
it('should delete a label for a project', function () {
this.LabelsManager.deleteLabelForUser
.calledWith(this.projectId, this.userId, this.label_id)
.should.equal(true)
})
it('should return 204', function () {
this.res.sendStatus.calledWith(204).should.equal(true)
})
})
describe('deleteLabel', function () {
beforeEach(function () {
this.req = {
params: {
project_id: this.projectId,
label_id: (this.label_id = new ObjectId()),
},
}
this.HttpController.deleteLabel(this.req, this.res, this.next)
})
it('should create a label for a project', function () {
it('should delete a label for a project', function () {
this.LabelsManager.deleteLabel
.calledWith(this.projectId, this.userId, this.label_id)
.calledWith(this.projectId, this.label_id)
.should.equal(true)
})