mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
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
This commit is contained in:
parent
97e357f772
commit
0c1e754736
2 changed files with 9 additions and 7 deletions
|
@ -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'
|
||||
|
|
|
@ -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) =>
|
||||
|
|
Loading…
Reference in a new issue