From 04be842b30b14d34b588472430a9179cde0361dc Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 25 Jun 2018 12:27:56 +0100 Subject: [PATCH] Fix validation of project-output-file, no build_id for imported v1 projects --- .../LinkedFiles/ProjectOutputFileAgent.coffee | 16 +++++++++++----- .../acceptance/coffee/LinkedFilesTests.coffee | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee b/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee index 5be0866ee2..e6a5392ba2 100644 --- a/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee +++ b/services/web/app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee @@ -93,11 +93,17 @@ module.exports = ProjectOutputFileAgent = { _getSourceProject: LinkedFilesHandler.getSourceProject _validate: (data) -> - return ( - (data.source_project_id? || data.v1_source_doc_id?) && - data.source_output_file_path? && - data.build_id? - ) + if data.v1_source_doc_id? + ( + data.v1_source_doc_id? && + data.source_output_file_path? + ) + else + ( + data.source_project_id? && + data.source_output_file_path? && + data.build_id? + ) _checkAuth: (project_id, data, current_user_id, callback = (err, allowed)->) -> callback = _.once(callback) diff --git a/services/web/test/acceptance/coffee/LinkedFilesTests.coffee b/services/web/test/acceptance/coffee/LinkedFilesTests.coffee index 0c369097cd..0d437f3ec0 100644 --- a/services/web/test/acceptance/coffee/LinkedFilesTests.coffee +++ b/services/web/test/acceptance/coffee/LinkedFilesTests.coffee @@ -428,8 +428,7 @@ describe "LinkedFiles", -> linkedFileData: { provider: "project_output_file", v1_source_doc_id: 9999999, # We won't find this id in the database - source_output_file_path: "project.pdf", - build_id: '123' + source_output_file_path: "project.pdf" }, _id: "abcdef", rev: 0,