From 2ade78783bf14b7477592f2c1c2d587989187dee Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 14 Jun 2018 14:25:44 +0100 Subject: [PATCH] Add acceptance test for refreshing output file from v1 project --- .../LinkedFiles/ProjectOutputFileAgent.coffee | 2 +- .../acceptance/coffee/LinkedFilesTests.coffee | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee b/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee index 5d81420cd8..5969b25c5b 100644 --- a/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee +++ b/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee @@ -99,7 +99,7 @@ module.exports = ProjectOutputFileAgent = { else if error instanceof ProjectNotFoundError res.status(404).send("Project not found") else if error instanceof ProjectFileAgent.V1ProjectNotFoundError - res.status(404).send(ProjectFileAgent._v1ProjectNotFoundMessage) + res.status(409).send(ProjectFileAgent._v1ProjectNotFoundMessage) else next(error) } diff --git a/services/web/test/acceptance/coffee/LinkedFilesTests.coffee b/services/web/test/acceptance/coffee/LinkedFilesTests.coffee index af7573a151..173aefa154 100644 --- a/services/web/test/acceptance/coffee/LinkedFilesTests.coffee +++ b/services/web/test/acceptance/coffee/LinkedFilesTests.coffee @@ -412,3 +412,37 @@ describe "LinkedFiles", -> expect(firstFile._id.toString()).to.equal(new_file_id.toString()) expect(firstFile.name).to.equal('test.pdf') done() + + describe "with a linked project_output_file from a v1 project that has not been imported", -> + before (done) -> + async.series [ + (cb) => + @owner.createProject 'output-v1-test-one', {template: 'blank'}, (error, project_id) => + @project_one_id = project_id + cb(error) + (cb) => + @owner.getProject @project_one_id, (error, project) => + @project_one = project + @project_one_root_folder_id = project.rootFolder[0]._id.toString() + @project_one.rootFolder[0].fileRefs.push { + linkedFileData: { + provider: "project_output_file", + v1_source_doc_id: 9999999, # We won't find this id in the database + source_output_file_path: "output.pdf" + }, + _id: "abcdef", + rev: 0, + created: new Date(), + name: "whatever.pdf" + } + @owner.saveProject @project_one, cb + ], done + + it 'should refuse to refresh', (done) -> + @owner.request.post { + url: "/project/#{@project_one_id}/linked_file/abcdef/refresh", + json: true + }, (error, response, body) => + expect(response.statusCode).to.equal 409 + expect(body).to.equal "Sorry, the source project is not yet imported to Overleaf v2. Please import it to Overleaf v2 to refresh this file" + done()