Skip to content

Commit

Permalink
assetId optional for Task
Browse files Browse the repository at this point in the history
  • Loading branch information
Alino committed Sep 7, 2018
1 parent 0907a73 commit 4670888
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 71 deletions.
3 changes: 2 additions & 1 deletion api/models/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ finished - the work on this Task is done and deliverableLocation is filled with
},

jobId: {
model: 'job'
model: 'job',
required: true
},

assetId: {
Expand Down
125 changes: 57 additions & 68 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,62 +168,6 @@ module.exports.routes = {
}
},

'DELETE /assets/:parentid/tasks/:id': {
controller: 'TaskController',
action: 'destroy',
swagger: {
summary: 'Delete a Task',
description: 'Deletes a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'GET /assets/:parentid/tasks/:id': {
controller: 'TaskController',
action: 'findOne',
swagger: {
summary: 'Get a Task',
description: 'Gets a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'PUT /assets/:parentid/tasks/:id': {
controller: 'TaskController',
action: 'update',
swagger: {
summary: 'Update a Task',
description: 'Updates a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'GET /assets/:parentid/tasks': {
controller: 'TaskController',
action: 'find',
swagger: {
summary: 'List all Task',
description: 'Lists all Task which belong to a specific job',
tags: [
'Task'
]
}
},
'POST /assets/:parentid/tasks': {
controller: 'TaskController',
action: 'create',
swagger: {
summary: 'Create a Task',
description: `Creates a Task which will belong to a specific job.`,
tags: [
'Task'
]
}
},

'POST /jobs/:parentid/assets/uploadfile':
{
controller: 'AssetController',
Expand Down Expand Up @@ -284,7 +228,62 @@ module.exports.routes = {
}
}
},
'POST /assets/:parentid/tasks/:id/uploaddeliverable': {


// task
'POST /tasks': {
controller: 'TaskController',
action: 'create',
swagger: {
summary: 'Create a Task',
description: `Creates a Task which will belong to a specific job.`,
tags: [
'Task'
]
}
},
'GET /tasks': {
controller: 'TaskController',
action: 'find',
swagger: {
summary: 'List all Tasks',
description: 'List all Tasks'
}
},
'GET /tasks/:id': {
controller: 'TaskController',
action: 'findOne',
swagger: {
summary: 'Get a Task',
description: 'Gets a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'PUT /tasks/:id': {
controller: 'TaskController',
action: 'update',
swagger: {
summary: 'Update a Task',
description: 'Updates a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'DELETE /tasks/:id': {
controller: 'TaskController',
action: 'destroy',
swagger: {
summary: 'Delete a Task',
description: 'Deletes a Task which belongs to a specific job',
tags: [
'Task'
]
}
},
'POST /tasks/:id/uploaddeliverable': {
controller: 'TaskController',
action: 'uploadFile',
swagger: {
Expand Down Expand Up @@ -323,7 +322,7 @@ module.exports.routes = {
}
}
},
'GET /assets/:parentid/tasks/:id/downloaddeliverable': {
'GET /tasks/:id/downloaddeliverable': {
controller: 'TaskController',
action: 'downloadFile',
swagger: {
Expand All @@ -346,16 +345,6 @@ module.exports.routes = {
}
},

// task
'GET /tasks': {
controller: 'TaskController',
action: 'find',
swagger: {
summary: 'List all Tasks',
description: 'List all Tasks'
}
},

// asset
'GET /assets': {
controller: 'AssetController',
Expand Down
5 changes: 3 additions & 2 deletions test/integration/controllers/TaskController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ describe('TaskController', function () {
}],
tasks: [{
id: 1,
jobId: 1,
assetId: 1,
progress: 'pending',
type: 'translation'
}]
}
describe('POST /assets/:parentid/tasks/:id/uploaddeliverable', function () {
describe('POST /tasks/:id/uploaddeliverable', function () {
beforeEach(function (done) {
const cb = () => Job.create(fixtures.jobs[0]).then(() => {
return Asset.create(fixtures.assets[0])
Expand All @@ -40,7 +41,7 @@ describe('TaskController', function () {
it('should upload the deliverable file to an existing Task', function (done) {

request(sails.hooks.http.app)
.post('/assets/1/tasks/1/uploaddeliverable')
.post('/tasks/1/uploaddeliverable')
.set('Authorization', 'Bearer ' + constants.ROOT_USER_API_KEY)
.attach('deliverable', 'test/fixtures/testDeliverableFile.txt')
.expect(200)
Expand Down

0 comments on commit 4670888

Please sign in to comment.