broken dropbox endpoints for user into its own controller

This commit is contained in:
Henry Oswald
2014-04-07 21:49:22 +01:00
parent 6891d1bfb5
commit bc07525d71
4 changed files with 100 additions and 20 deletions
@@ -0,0 +1,70 @@
SandboxedModule = require('sandboxed-module')
assert = require('assert')
require('chai').should()
sinon = require('sinon')
modulePath = require('path').join __dirname, '../../../../app/js/Features/Dropbox/DropboxUserController.js'
describe 'DropboxUserController', ->
beforeEach ->
@DropboxHandler =
getDropboxRegisterUrl: sinon.stub()
completeRegistration: sinon.stub()
unlinkAccount: sinon.stub()
@controller = SandboxedModule.require modulePath, requires:
'./DropboxHandler': @DropboxHandler
'logger-sharelatex':
log:->
err:->
@user_id = "23j21lk3j1312j321jkljkl"
@req =
session:
user:
_id: @user_id
@res = {}
describe "redirectUserToDropboxAuth", ->
beforeEach ->
@dropboxUrl = "www.dropbox.com"
@DropboxHandler.getDropboxRegisterUrl.callsArgWith(1, null, @dropboxUrl)
it "should call getDropboxRegisterUrl with the user id", (done)->
@res.redirect = (redirectUrl)=>
redirectUrl.should.equal @dropboxUrl
@DropboxHandler.getDropboxRegisterUrl.calledWith(@user_id).should.equal true
done()
@controller.redirectUserToDropboxAuth @req, @res
describe "completeDropboxRegistration", ->
beforeEach ->
@DropboxHandler.completeRegistration.callsArgWith(1)
it "should call getDropboxRegisterUrl with the user id", (done)->
@res.redirect = (redirectUrl)=>
redirectUrl.should.equal "/user/settings#dropboxSettings"
@DropboxHandler.completeRegistration.calledWith(@user_id).should.equal true
done()
@controller.completeDropboxRegistration @req, @res
describe "unlinkDropbox", ->
beforeEach ->
@DropboxHandler.unlinkAccount.callsArgWith(1)
it "should call getDropboxRegisterUrl with the user id", (done)->
@res.redirect = (redirectUrl)=>
redirectUrl.should.equal "/user/settings#dropboxSettings"
@DropboxHandler.unlinkAccount.calledWith(@user_id).should.equal true
done()
@controller.unlinkDropbox @req, @res