Merge pull request #1948 from overleaf/cmg-allow-array-archiving

Make checking for project.archived array-friendly

GitOrigin-RevId: 2902a12fb4611a5786d4b10feba534b1cd29668b
This commit is contained in:
Alasdair Smith
2019-08-09 10:40:11 +01:00
committed by sharelatex
parent c8140f9641
commit 3422c17dc4
7 changed files with 122 additions and 13 deletions
@@ -79,6 +79,9 @@ describe('ProjectController', function() {
findAllUsersProjects: sinon.stub(),
getProject: sinon.stub()
}
this.ProjectHelper = {
isArchived: sinon.stub()
}
this.AuthenticationController = {
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
getLoggedInUserId: sinon.stub().returns(this.user._id),
@@ -136,6 +139,7 @@ describe('ProjectController', function() {
'./ProjectDuplicator': this.ProjectDuplicator,
'./ProjectCreationHandler': this.ProjectCreationHandler,
'../Editor/EditorController': this.EditorController,
'./ProjectHelper': this.ProjectHelper,
'../Subscription/SubscriptionLocator': this.SubscriptionLocator,
'../Subscription/LimitationsManager': this.LimitationsManager,
'../Tags/TagsHandler': this.TagsHandler,
@@ -897,13 +901,27 @@ describe('ProjectController', function() {
somethingElse: 1
}
]
this.ProjectHelper.isArchived
.withArgs(projects[0], this.user._id)
.returns(true)
this.ProjectHelper.isArchived
.withArgs(projects[1], this.user._id)
.returns(false)
this.ProjectHelper.isArchived
.withArgs(projects[2], this.user._id)
.returns(false)
this.ProjectHelper.isArchived
.withArgs(projects[3], this.user._id)
.returns(false)
this.ProjectGetter.findAllUsersProjects = sinon
.stub()
.callsArgWith(2, null, [])
this.ProjectController._buildProjectList = sinon.stub().returns(projects)
this.AuthenticationController.getLoggedInUserId = sinon
.stub()
.returns('abc')
.returns(this.user._id)
return done()
})