Merge pull request #2081 from overleaf/cmg-per-user-trash

Add per-user trashed state to project model

GitOrigin-RevId: 16a753702d3503eee011dd2adca5dc8df3da87f4
This commit is contained in:
Chrystal Maria Griffiths
2019-08-27 11:38:17 +01:00
committed by sharelatex
parent c1f8ac8de1
commit 6f2b4d3da3
7 changed files with 84 additions and 23 deletions

View File

@@ -80,7 +80,9 @@ describe('ProjectController', function() {
getProject: sinon.stub()
}
this.ProjectHelper = {
isArchived: sinon.stub()
isArchived: sinon.stub(),
isTrashed: sinon.stub(),
isArchivedOrTrashed: sinon.stub()
}
this.AuthenticationController = {
getLoggedInUser: sinon.stub().callsArgWith(1, null, this.user),
@@ -878,6 +880,7 @@ describe('ProjectController', function() {
const projects = [
{
archived: true,
trashed: true,
id: 'a',
name: 'A',
accessLevel: 'a',
@@ -892,6 +895,7 @@ describe('ProjectController', function() {
},
{
archived: false,
trashed: true,
id: 'c',
name: 'C',
accessLevel: 'c',
@@ -899,6 +903,7 @@ describe('ProjectController', function() {
},
{
archived: false,
trashed: false,
id: 'd',
name: 'D',
accessLevel: 'd',
@@ -906,16 +911,16 @@ describe('ProjectController', function() {
}
]
this.ProjectHelper.isArchived
this.ProjectHelper.isArchivedOrTrashed
.withArgs(projects[0], this.user._id)
.returns(true)
this.ProjectHelper.isArchived
this.ProjectHelper.isArchivedOrTrashed
.withArgs(projects[1], this.user._id)
.returns(false)
this.ProjectHelper.isArchived
this.ProjectHelper.isArchivedOrTrashed
.withArgs(projects[2], this.user._id)
.returns(false)
this.ProjectHelper.isArchived
.returns(true)
this.ProjectHelper.isArchivedOrTrashed
.withArgs(projects[3], this.user._id)
.returns(false)
@@ -934,7 +939,6 @@ describe('ProjectController', function() {
expect(data).to.deep.equal({
projects: [
{ _id: 'b', name: 'B', accessLevel: 'b' },
{ _id: 'c', name: 'C', accessLevel: 'c' },
{ _id: 'd', name: 'D', accessLevel: 'd' }
]
})