|
@@ -78,6 +78,9 @@ describe('TpdsUpdateHandler', function () {
|
|
|
this.ProjectGetter = {
|
|
this.ProjectGetter = {
|
|
|
promises: {
|
|
promises: {
|
|
|
findUsersProjectsByName: sinon.stub(),
|
|
findUsersProjectsByName: sinon.stub(),
|
|
|
|
|
+ findAllUsersProjects: sinon
|
|
|
|
|
+ .stub()
|
|
|
|
|
+ .resolves({ owned: [this.projects.active1], readAndWrite: [] }),
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
this.ProjectHelper = {
|
|
this.ProjectHelper = {
|
|
@@ -119,6 +122,26 @@ describe('TpdsUpdateHandler', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('getting an update', function () {
|
|
describe('getting an update', function () {
|
|
|
|
|
+ describe('byId', function () {
|
|
|
|
|
+ describe('with no matching project', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.projectId = ObjectId().toString()
|
|
|
|
|
+ })
|
|
|
|
|
+ receiveUpdateById()
|
|
|
|
|
+ expectProjectNotCreated()
|
|
|
|
|
+ expectUpdateNotProcessed()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('with one matching active project', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.projectId = this.projects.active1._id.toString()
|
|
|
|
|
+ })
|
|
|
|
|
+ receiveUpdateById()
|
|
|
|
|
+ expectProjectNotCreated()
|
|
|
|
|
+ expectUpdateProcessed()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
describe('with no matching project', function () {
|
|
describe('with no matching project', function () {
|
|
|
setupMatchingProjects([])
|
|
setupMatchingProjects([])
|
|
|
receiveUpdate()
|
|
receiveUpdate()
|
|
@@ -183,6 +206,7 @@ describe('TpdsUpdateHandler', function () {
|
|
|
await expect(
|
|
await expect(
|
|
|
this.TpdsUpdateHandler.promises.newUpdate(
|
|
this.TpdsUpdateHandler.promises.newUpdate(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ '', // projectId
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
this.path,
|
|
this.path,
|
|
|
this.update,
|
|
this.update,
|
|
@@ -195,6 +219,26 @@ describe('TpdsUpdateHandler', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('getting a file delete', function () {
|
|
describe('getting a file delete', function () {
|
|
|
|
|
+ describe('byId', function () {
|
|
|
|
|
+ describe('with no matching project', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.projectId = ObjectId().toString()
|
|
|
|
|
+ })
|
|
|
|
|
+ receiveFileDeleteById()
|
|
|
|
|
+ expectDeleteNotProcessed()
|
|
|
|
|
+ expectProjectNotDeleted()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ describe('with one matching active project', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ this.projectId = this.projects.active1._id.toString()
|
|
|
|
|
+ })
|
|
|
|
|
+ receiveFileDeleteById()
|
|
|
|
|
+ expectDeleteProcessed()
|
|
|
|
|
+ expectProjectNotDeleted()
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
describe('with no matching project', function () {
|
|
describe('with no matching project', function () {
|
|
|
setupMatchingProjects([])
|
|
setupMatchingProjects([])
|
|
|
receiveFileDelete()
|
|
receiveFileDelete()
|
|
@@ -342,6 +386,7 @@ describe('TpdsUpdateHandler', function () {
|
|
|
await expect(
|
|
await expect(
|
|
|
this.TpdsUpdateHandler.promises.createFolder(
|
|
this.TpdsUpdateHandler.promises.createFolder(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ this.projectId,
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
this.path
|
|
this.path
|
|
|
)
|
|
)
|
|
@@ -377,6 +422,7 @@ function receiveUpdate() {
|
|
|
beforeEach(async function () {
|
|
beforeEach(async function () {
|
|
|
await this.TpdsUpdateHandler.promises.newUpdate(
|
|
await this.TpdsUpdateHandler.promises.newUpdate(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ '', // projectId
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
this.path,
|
|
this.path,
|
|
|
this.update,
|
|
this.update,
|
|
@@ -385,10 +431,25 @@ function receiveUpdate() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function receiveUpdateById() {
|
|
|
|
|
+ beforeEach(function (done) {
|
|
|
|
|
+ this.TpdsUpdateHandler.newUpdate(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ this.projectId,
|
|
|
|
|
+ '', // projectName
|
|
|
|
|
+ this.path,
|
|
|
|
|
+ this.update,
|
|
|
|
|
+ this.source,
|
|
|
|
|
+ done
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function receiveFileDelete() {
|
|
function receiveFileDelete() {
|
|
|
beforeEach(async function () {
|
|
beforeEach(async function () {
|
|
|
await this.TpdsUpdateHandler.promises.deleteUpdate(
|
|
await this.TpdsUpdateHandler.promises.deleteUpdate(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ '', // projectId
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
this.path,
|
|
this.path,
|
|
|
this.source
|
|
this.source
|
|
@@ -396,10 +457,24 @@ function receiveFileDelete() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function receiveFileDeleteById() {
|
|
|
|
|
+ beforeEach(function (done) {
|
|
|
|
|
+ this.TpdsUpdateHandler.deleteUpdate(
|
|
|
|
|
+ this.userId,
|
|
|
|
|
+ this.projectId,
|
|
|
|
|
+ '', // projectName
|
|
|
|
|
+ this.path,
|
|
|
|
|
+ this.source,
|
|
|
|
|
+ done
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function receiveProjectDelete() {
|
|
function receiveProjectDelete() {
|
|
|
beforeEach(async function () {
|
|
beforeEach(async function () {
|
|
|
await this.TpdsUpdateHandler.promises.deleteUpdate(
|
|
await this.TpdsUpdateHandler.promises.deleteUpdate(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ '', // projectId
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
'/',
|
|
'/',
|
|
|
this.source
|
|
this.source
|
|
@@ -411,6 +486,7 @@ function receiveFolderUpdate() {
|
|
|
beforeEach(async function () {
|
|
beforeEach(async function () {
|
|
|
await this.TpdsUpdateHandler.promises.createFolder(
|
|
await this.TpdsUpdateHandler.promises.createFolder(
|
|
|
this.userId,
|
|
this.userId,
|
|
|
|
|
+ this.projectId,
|
|
|
this.projectName,
|
|
this.projectName,
|
|
|
this.folderPath
|
|
this.folderPath
|
|
|
)
|
|
)
|