Fix authHooks test suite

This commit is contained in:
Juan Cruz Viotti 2014-11-26 09:19:02 -04:00
parent d4310bf970
commit 76e92fea22
2 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,9 @@ exports.failIfNotLoggedIn = (fn, onError) ->
if not isLoggedIn
error = new Error(messages.errors.loginRequired)
return onError?(error) or throw error
if onError?
return onError(error)
else
throw error
fn.apply(null, args)

View File

@ -4,6 +4,7 @@ sinon = require('sinon')
expect = require('chai').expect
config = require('../config')
auth = require('../auth/auth')
data = require('../data/data')
authHooks = require('./auth')
johnDoeFixture = require('../../tests/fixtures/johndoe')
mock = require('../../tests/utils/mock')
@ -18,6 +19,13 @@ describe 'Auth Hooks:', ->
after ->
mock.connection.restore()
beforeEach (done) ->
mock.fs.init()
data.prefix.set(config.dataPrefix, done)
afterEach ->
mock.fs.restore()
describe 'if not logged in', ->
beforeEach (done) ->