mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #287 from sharelatex/ja-fix-delete-endpoint
Fix call of UpdateMerger.deleteUpdate in TpdsController.deleteProjectContents
This commit is contained in:
commit
a84cc16ce2
3 changed files with 40 additions and 3 deletions
|
@ -54,7 +54,7 @@ module.exports =
|
|||
path = "/" + req.params[0] # UpdateMerger expects leading slash
|
||||
source = req.headers["x-sl-update-source"] or "unknown"
|
||||
logger.log project_id: project_id, path: path, source: source, "received project contents delete request"
|
||||
UpdateMerger.deleteUpdate project_id, path, source, (error) ->
|
||||
UpdateMerger.deleteUpdate null, project_id, path, source, (error) ->
|
||||
return next(error) if error?
|
||||
res.sendStatus(200)
|
||||
|
||||
|
|
37
services/web/test/acceptance/coffee/TpdsUpdateTests.coffee
Normal file
37
services/web/test/acceptance/coffee/TpdsUpdateTests.coffee
Normal file
|
@ -0,0 +1,37 @@
|
|||
expect = require("chai").expect
|
||||
ProjectGetter = require "../../../app/js/Features/Project/ProjectGetter.js"
|
||||
request = require "./helpers/request"
|
||||
User = require "./helpers/User"
|
||||
|
||||
describe "TpdsUpdateTests", ->
|
||||
before (done) ->
|
||||
@owner = new User()
|
||||
@owner.login (error) =>
|
||||
throw error if error?
|
||||
@owner.createProject "test-project", {template: "example"}, (error, project_id) =>
|
||||
throw error if error?
|
||||
@project_id = project_id
|
||||
done()
|
||||
|
||||
describe "deleting a file", ->
|
||||
before (done) ->
|
||||
request {
|
||||
method: "DELETE"
|
||||
url: "/project/#{@project_id}/contents/main.tex"
|
||||
auth:
|
||||
username: "sharelatex"
|
||||
password: "password"
|
||||
sendImmediately: true
|
||||
}, (error, response, body) ->
|
||||
throw error if error?
|
||||
expect(response.statusCode).to.equal 200
|
||||
done()
|
||||
|
||||
it "should have deleted the file", (done) ->
|
||||
ProjectGetter.getProject @project_id, (error, [project]) ->
|
||||
throw error if error?
|
||||
projectFolder = project.rootFolder[0]
|
||||
for doc in projectFolder.docs
|
||||
if doc.name == "main.tex"
|
||||
throw new Error("expected main.tex to have been deleted")
|
||||
done()
|
|
@ -103,7 +103,7 @@ describe 'TpdsController', ->
|
|||
|
||||
describe 'deleteProjectContents', ->
|
||||
beforeEach ->
|
||||
@UpdateMerger.deleteUpdate = sinon.stub().callsArg(3)
|
||||
@UpdateMerger.deleteUpdate = sinon.stub().callsArg(4)
|
||||
@req =
|
||||
params:
|
||||
0: @path = "chapters/main.tex"
|
||||
|
@ -119,7 +119,7 @@ describe 'TpdsController', ->
|
|||
|
||||
it "should delete the file", ->
|
||||
@UpdateMerger.deleteUpdate
|
||||
.calledWith(@project_id, "/" + @path, @source)
|
||||
.calledWith(null, @project_id, "/" + @path, @source)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success", ->
|
||||
|
|
Loading…
Reference in a new issue