Merge branch 'github-sync'
Conflicts: package.json
This commit is contained in:
@@ -198,8 +198,8 @@ describe "ProjectController", ->
|
||||
first_name: 'James'
|
||||
'user-2':
|
||||
first_name: 'Henry'
|
||||
@users[@user._id] = @user # Owner
|
||||
@UserModel.findById = (id, fields, callback) =>
|
||||
fields.should.equal 'first_name last_name'
|
||||
callback null, @users[id]
|
||||
|
||||
@LimitationsManager.userHasSubscriptionOrIsGroupMember.callsArgWith(1, null, false)
|
||||
@@ -224,6 +224,12 @@ describe "ProjectController", ->
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
it "should send the user", (done)->
|
||||
@res.render = (pageName, opts)=>
|
||||
opts.user.should.deep.equal @user
|
||||
done()
|
||||
@ProjectController.projectListPage @req, @res
|
||||
|
||||
it "should inject the users", (done) ->
|
||||
@res.render = (pageName, opts)=>
|
||||
opts.projects[0].owner.should.equal (@users[@projects[0].owner_ref])
|
||||
|
||||
@@ -5,11 +5,12 @@ modulePath = require('path').join __dirname, '../../../../app/js/Features/ThirdP
|
||||
|
||||
|
||||
|
||||
describe 'third party data store', ->
|
||||
describe 'TpdsController', ->
|
||||
beforeEach ->
|
||||
@updateHandler = {}
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
'./TpdsUpdateHandler':@updateHandler
|
||||
@TpdsUpdateHandler = {}
|
||||
@TpdsController = SandboxedModule.require modulePath, requires:
|
||||
'./TpdsUpdateHandler':@TpdsUpdateHandler
|
||||
'./UpdateMerger': @UpdateMerger = {}
|
||||
'logger-sharelatex':
|
||||
log:->
|
||||
err:->
|
||||
@@ -24,11 +25,11 @@ describe 'third party data store', ->
|
||||
params:{0:path, "user_id":@user_id}
|
||||
session:
|
||||
destroy:->
|
||||
@updateHandler.newUpdate = sinon.stub().callsArg(5)
|
||||
@TpdsUpdateHandler.newUpdate = sinon.stub().callsArg(5)
|
||||
res = send: =>
|
||||
@updateHandler.newUpdate.calledWith(@user_id, "projectName","/here.txt", req).should.equal true
|
||||
@TpdsUpdateHandler.newUpdate.calledWith(@user_id, "projectName","/here.txt", req).should.equal true
|
||||
done()
|
||||
@controller.mergeUpdate req, res
|
||||
@TpdsController.mergeUpdate req, res
|
||||
|
||||
describe 'getting a delete update', ->
|
||||
it 'should process the delete with the update reciver', (done)->
|
||||
@@ -37,18 +38,18 @@ describe 'third party data store', ->
|
||||
params:{0:path, "user_id":@user_id}
|
||||
session:
|
||||
destroy:->
|
||||
@updateHandler.deleteUpdate = sinon.stub().callsArg(4)
|
||||
@TpdsUpdateHandler.deleteUpdate = sinon.stub().callsArg(4)
|
||||
res = send: =>
|
||||
@updateHandler.deleteUpdate.calledWith(@user_id, "projectName", "/here.txt").should.equal true
|
||||
@TpdsUpdateHandler.deleteUpdate.calledWith(@user_id, "projectName", "/here.txt").should.equal true
|
||||
done()
|
||||
@controller.deleteUpdate req, res
|
||||
@TpdsController.deleteUpdate req, res
|
||||
|
||||
describe 'parseParams', ->
|
||||
|
||||
it 'should take the project name off the start and replace with slash', ->
|
||||
path = "noSlashHere"
|
||||
req = params:{0:path, user_id:@user_id}
|
||||
result = @controller.parseParams(req)
|
||||
result = @TpdsController.parseParams(req)
|
||||
result.user_id.should.equal @user_id
|
||||
result.filePath.should.equal "/"
|
||||
result.projectName.should.equal path
|
||||
@@ -57,7 +58,7 @@ describe 'third party data store', ->
|
||||
it 'should take the project name off the start and return it with no slashes in', ->
|
||||
path = "/project/file.tex"
|
||||
req = params:{0:path, user_id:@user_id}
|
||||
result = @controller.parseParams(req)
|
||||
result = @TpdsController.parseParams(req)
|
||||
result.user_id.should.equal @user_id
|
||||
result.filePath.should.equal "/file.tex"
|
||||
result.projectName.should.equal "project"
|
||||
@@ -65,8 +66,57 @@ describe 'third party data store', ->
|
||||
it 'should take the project name of and return a slash for the file path', ->
|
||||
path = "/project_name"
|
||||
req = params:{0:path, user_id:@user_id}
|
||||
result = @controller.parseParams(req)
|
||||
result = @TpdsController.parseParams(req)
|
||||
result.projectName.should.equal "project_name"
|
||||
result.filePath.should.equal "/"
|
||||
|
||||
describe 'updateProjectContents', ->
|
||||
beforeEach ->
|
||||
@UpdateMerger.mergeUpdate = sinon.stub().callsArg(3)
|
||||
@req =
|
||||
params:
|
||||
0: @path = "chapters/main.tex"
|
||||
project_id: @project_id = "project-id-123"
|
||||
session:
|
||||
destroy: sinon.stub()
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
|
||||
@TpdsController.updateProjectContents @req, @res
|
||||
|
||||
it "should merge the update", ->
|
||||
@UpdateMerger.mergeUpdate
|
||||
.calledWith(@project_id, "/" + @path, @req)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success", ->
|
||||
@res.send.calledWith(200).should.equal true
|
||||
|
||||
it "should clear the session", ->
|
||||
@req.session.destroy.called.should.equal true
|
||||
|
||||
describe 'deleteProjectContents', ->
|
||||
beforeEach ->
|
||||
@UpdateMerger.deleteUpdate = sinon.stub().callsArg(2)
|
||||
@req =
|
||||
params:
|
||||
0: @path = "chapters/main.tex"
|
||||
project_id: @project_id = "project-id-123"
|
||||
session:
|
||||
destroy: sinon.stub()
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
|
||||
@TpdsController.deleteProjectContents @req, @res
|
||||
|
||||
it "should delete the file", ->
|
||||
@UpdateMerger.deleteUpdate
|
||||
.calledWith(@project_id, "/" + @path)
|
||||
.should.equal true
|
||||
|
||||
it "should return a success", ->
|
||||
@res.send.calledWith(200).should.equal true
|
||||
|
||||
it "should clear the session", ->
|
||||
@req.session.destroy.called.should.equal true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user