From 0c1e754736e74b6d135545888315760c1a31782d Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 20 Dec 2018 10:36:47 +0000 Subject: [PATCH] Merge pull request #1289 from sharelatex/sk-labeled-versions-in-git-bridge-v2 Add support for labeled-versions in git-bridge api. GitOrigin-RevId: 94858627034ffd000d49b92ba5c7ab45e7294840 --- services/web/test/acceptance/coffee/LabelsTests.coffee | 8 ++++---- .../coffee/helpers/MockProjectHistoryApi.coffee | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/services/web/test/acceptance/coffee/LabelsTests.coffee b/services/web/test/acceptance/coffee/LabelsTests.coffee index 8832f2a326..2c6176f574 100644 --- a/services/web/test/acceptance/coffee/LabelsTests.coffee +++ b/services/web/test/acceptance/coffee/LabelsTests.coffee @@ -22,7 +22,7 @@ describe 'Labels', -> label_id = new ObjectId().toString() comment = 'a label comment' version = 3 - MockProjectHistoryApi.addLabel @project_id, label_id, comment, version + MockProjectHistoryApi.addLabel @project_id, {id: label_id, comment, version} @owner.request { method: 'GET' @@ -31,7 +31,7 @@ describe 'Labels', -> }, (error, response, body) => throw error if error? expect(response.statusCode).to.equal 200 - expect(body).to.deep.equal [{ label_id, comment, version }] + expect(body).to.deep.equal [{ id: label_id, comment, version }] done() it 'creating a label', (done) -> @@ -48,14 +48,14 @@ describe 'Labels', -> {label_id} = body expect( MockProjectHistoryApi.getLabels(@project_id) - ).to.deep.equal [{label_id, comment, version} ] + ).to.deep.equal [{id: label_id, comment, version} ] done() it 'deleting a label', (done) -> label_id = new ObjectId().toString() comment = 'a label comment' version = 3 - MockProjectHistoryApi.addLabel @project_id, label_id, comment, version + MockProjectHistoryApi.addLabel @project_id, {id: label_id, comment, version} @owner.request { method: 'DELETE' diff --git a/services/web/test/acceptance/coffee/helpers/MockProjectHistoryApi.coffee b/services/web/test/acceptance/coffee/helpers/MockProjectHistoryApi.coffee index e58f276f47..8a5533e062 100644 --- a/services/web/test/acceptance/coffee/helpers/MockProjectHistoryApi.coffee +++ b/services/web/test/acceptance/coffee/helpers/MockProjectHistoryApi.coffee @@ -22,9 +22,11 @@ module.exports = MockProjectHistoryApi = setProjectVersionInfo: (project_id, versionInfo) -> @projectVersions[project_id] = versionInfo - addLabel: (project_id, label_id, comment, version) -> + addLabel: (project_id, label) -> + if !label.id? + label.id = new ObjectId().toString() @labels[project_id] ?= {} - @labels[project_id][label_id] = {label_id,comment,version} + @labels[project_id][label.id] = label deleteLabel: (project_id, label_id) -> delete @labels[project_id][label_id] @@ -69,7 +71,7 @@ module.exports = MockProjectHistoryApi = {project_id} = req.params {comment, version} = req.body label_id = new ObjectId().toString() - @addLabel project_id, label_id, comment, version + @addLabel project_id, {id: label_id, comment, version} res.json {label_id, comment, version} app.delete "/project/:project_id/user/:user_id/labels/:label_id", (req, res, next) =>