|
|
@@ -19,12 +19,11 @@ filestoreUrl = "filestore.sharelatex.com"
|
|
|
|
|
|
describe 'TpdsUpdateSender', ->
|
|
|
beforeEach ->
|
|
|
- @requestQueuer = regist:(queue, meth, opts, callback)->
|
|
|
+ @requestQueuer = (queue, meth, opts, callback)->
|
|
|
project = {owner_ref:user_id,readOnly_refs:[read_only_ref_1], collaberator_refs:[collaberator_ref_1]}
|
|
|
@Project = findById:sinon.stub().callsArgWith(2, null, project)
|
|
|
@docstoreUrl = "docstore.sharelatex.env"
|
|
|
@updateSender = SandboxedModule.require modulePath, requires:
|
|
|
- 'fairy':{connect:=>{queue:=>@requestQueuer}}
|
|
|
"settings-sharelatex":
|
|
|
siteUrl:siteUrl
|
|
|
httpAuthSiteUrl:httpAuthSiteUrl,
|
|
|
@@ -34,17 +33,17 @@ describe 'TpdsUpdateSender', ->
|
|
|
url: filestoreUrl
|
|
|
docstore:
|
|
|
pubUrl: @docstoreUrl
|
|
|
- redis:fairy:{}
|
|
|
+
|
|
|
"logger-sharelatex":{log:->}
|
|
|
'../../models/Project': Project:@Project
|
|
|
'request':->{pipe:->}
|
|
|
|
|
|
describe 'sending updates', ->
|
|
|
|
|
|
- it 'ques a post the file with user and file id', (done)->
|
|
|
+ it 'queues a post the file with user and file id', (done)->
|
|
|
file_id = '4545345'
|
|
|
path = '/some/path/here.jpg'
|
|
|
- @requestQueuer.enqueue = (uid, method, job, callback)->
|
|
|
+ @updateSender._enqueue = (uid, method, job, callback)->
|
|
|
uid.should.equal project_id
|
|
|
job.method.should.equal "post"
|
|
|
job.streamOrigin.should.equal "#{filestoreUrl}/project/#{project_id}/file/#{file_id}"
|
|
|
@@ -59,7 +58,7 @@ describe 'TpdsUpdateSender', ->
|
|
|
path = "/some/path/here.tex"
|
|
|
lines = ["line1", "line2", "line3"]
|
|
|
|
|
|
- @requestQueuer.enqueue = (uid, method, job, callback)=>
|
|
|
+ @updateSender._enqueue = (uid, method, job, callback)=>
|
|
|
uid.should.equal project_id
|
|
|
job.method.should.equal "post"
|
|
|
expectedUrl = "#{thirdPartyDataStoreApiUrl}/user/#{user_id}/entity/#{encodeURIComponent(project_name)}#{encodeURIComponent(path)}"
|
|
|
@@ -71,7 +70,7 @@ describe 'TpdsUpdateSender', ->
|
|
|
|
|
|
it 'deleting entity', (done)->
|
|
|
path = "/path/here/t.tex"
|
|
|
- @requestQueuer.enqueue = (uid, method, job, callback)->
|
|
|
+ @updateSender._enqueue = (uid, method, job, callback)->
|
|
|
uid.should.equal project_id
|
|
|
job.method.should.equal "DELETE"
|
|
|
expectedUrl = "#{thirdPartyDataStoreApiUrl}/user/#{user_id}/entity/#{encodeURIComponent(project_name)}#{encodeURIComponent(path)}"
|
|
|
@@ -83,7 +82,7 @@ describe 'TpdsUpdateSender', ->
|
|
|
it 'moving entity', (done)->
|
|
|
startPath = "staring/here/file.tex"
|
|
|
endPath = "ending/here/file.tex"
|
|
|
- @requestQueuer.enqueue = (uid, method, job, callback)->
|
|
|
+ @updateSender._enqueue = (uid, method, job, callback)->
|
|
|
uid.should.equal project_id
|
|
|
job.method.should.equal "put"
|
|
|
job.uri.should.equal "#{thirdPartyDataStoreApiUrl}/user/#{user_id}/entity"
|
|
|
@@ -96,7 +95,7 @@ describe 'TpdsUpdateSender', ->
|
|
|
it 'should be able to rename a project using the move entity func', (done)->
|
|
|
oldProjectName = "/oldProjectName/"
|
|
|
newProjectName = "/newProjectName/"
|
|
|
- @requestQueuer.enqueue = (uid, method, job, callback)->
|
|
|
+ @updateSender._enqueue = (uid, method, job, callback)->
|
|
|
uid.should.equal project_id
|
|
|
job.method.should.equal "put"
|
|
|
job.uri.should.equal "#{thirdPartyDataStoreApiUrl}/user/#{user_id}/entity"
|
|
|
@@ -107,9 +106,9 @@ describe 'TpdsUpdateSender', ->
|
|
|
@updateSender.moveEntity {project_id:project_id, project_name:oldProjectName, newProjectName:newProjectName}
|
|
|
|
|
|
it "pollDropboxForUser", (done) ->
|
|
|
- @requestQueuer.enqueue = sinon.stub().callsArg(3)
|
|
|
+ @updateSender._enqueue = sinon.stub().callsArg(3)
|
|
|
@updateSender.pollDropboxForUser user_id, (error) =>
|
|
|
- @requestQueuer.enqueue
|
|
|
+ @updateSender._enqueue
|
|
|
.calledWith(
|
|
|
"poll-dropbox:#{user_id}",
|
|
|
"standardHttpRequest",
|