Use Dropbox Real-time polling

This commit is contained in:
James Allen
2014-08-13 17:26:18 +01:00
parent 2a6041752d
commit 670e8e5cb9
12 changed files with 185 additions and 32 deletions
@@ -0,0 +1,48 @@
SandboxedModule = require('sandboxed-module')
assert = require('assert')
require('chai').should()
sinon = require('sinon')
modulePath = require('path').join __dirname, '../../../../app/js/Features/Dropbox/DropboxWebhookController.js'
describe 'DropboxWebhookController', ->
beforeEach ->
@DropboxWebhookController = SandboxedModule.require modulePath, requires:
"./DropboxWebhookHandler": @DropboxWebhookHandler = {}
'logger-sharelatex':
log:->
err:->
describe "verify", ->
beforeEach ->
@res =
send: sinon.stub()
@req.query =
challenge: @challenge = "foo"
@DropboxWebhookController.verify(@req, @res)
it "should echo the challenge parameter back", ->
@res.send.calledWith(@challenge).should.equal true
describe "webhook", ->
beforeEach ->
@req.body =
delta:
users: @dropbox_uids = [
"123456",
"789123"
]
@res.send = sinon.stub()
@DropboxWebhookHandler.pollDropboxUids = sinon.stub().callsArg(1)
@DropboxWebhookController.webhook(@req, @res)
it "should poll the Dropbox uids", ->
@DropboxWebhookHandler.pollDropboxUids
.calledWith(@dropbox_uids)
.should.equal true
it "should return success", ->
@res.send
.calledWith(200)
.should.equal true