removed tpds from settings.defaults.coffee, if not set updates are now not queued

This commit is contained in:
Henry Oswald 2015-07-02 12:09:08 +01:00
parent 56346ad88c
commit 8020cd8f47
3 changed files with 40 additions and 13 deletions

View file

@ -15,10 +15,15 @@ buildPath = (user_id, project_name, filePath)->
tpdsworkerEnabled = -> settings.apis.tpdsworker?.url?
if !tpdsworkerEnabled()
logger.log "tpdsworker is not enabled, request will not be sent to it"
module.exports = TpdsUpdateSender =
_enqueue: (group, method, job, callback)->
if !tpdsworkerEnabled()
return callback()
opts =
uri:"#{settings.apis.tpdsworker.url}/enqueue/web_to_tpds_http_requests"
json :

View file

@ -68,8 +68,6 @@ module.exports =
thirdPartyDataStore:
url : "http://localhost:3002"
emptyProjectFlushDelayMiliseconds: 5 * seconds
tpdsworker:
url: "http://localhost:3030"
tags:
url :"http://localhost:3012"
spelling:

View file

@ -23,8 +23,8 @@ describe 'TpdsUpdateSender', ->
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:
"settings-sharelatex":
@request = sinon.stub().returns(pipe:->)
@settings =
siteUrl:siteUrl
httpAuthSiteUrl:httpAuthSiteUrl,
apis:
@ -33,10 +33,34 @@ describe 'TpdsUpdateSender', ->
url: filestoreUrl
docstore:
pubUrl: @docstoreUrl
@updateSender = SandboxedModule.require modulePath, requires:
"settings-sharelatex": @settings
"logger-sharelatex":{log:->}
'../../models/Project': Project:@Project
'request':->{pipe:->}
'request':@request
describe "_enqueue", ->
it "should not call request if there is no tpdsworker url", (done)->
@updateSender._enqueue null, null, null, (err)=>
@request.called.should.equal false
done()
it "should post the message to the tpdsworker", (done)->
@settings.apis.tpdsworker = url:"www.tpdsworker.env"
group = "myproject"
method = "somemethod"
job = "do something"
@request.callsArgWith(1)
@updateSender._enqueue group, method, job, (err)=>
args = @request.args[0][0]
args.json.group.should.equal group
args.json.job.should.equal job
args.json.method.should.equal method
args.uri.should.equal "www.tpdsworker.env/enqueue/web_to_tpds_http_requests"
done()
describe 'sending updates', ->