 
     profileRequestParams  = generateGetProfileRequestParams { email, method : 'post' }
 
-    queue.push ->
+    queue.push (next) ->
 
       request registerRequestParams, (err, res, body) ->
-        expect(err)             .to.not.exist
-        expect(res.statusCode)  .to.be.equal 200
-        queue.next()
+        expect(err).to.not.exist
+        expect(res.statusCode).to.be.equal 200
+        next()
 
-    queue.push ->
+    queue.push (next) ->
 
       request profileRequestParams, (err, res, body) ->
-        expect(err)             .to.not.exist
-        expect(res.statusCode)  .to.be.equal 200
-        queue.next()
+        expect(err).to.not.exist
+        expect(res.statusCode).to.be.equal 200
+        next()
 
-    queue.push -> done()
-
-    daisy queue
+    async.series queue, done

JUser            = null
JAccount         = null

Bongo            = require 'bongo'
koding           = require './../bongo'
request          = require 'request'

{ daisy }        = Bongo
{ expect }       = require 'chai'

{ generateRandomEmail
  generateRandomString }            = require '../../../testhelper'
{ generateRegisterRequestParams }   = require '../../../testhelper/handler/registerhelper'
{ generateGetProfileRequestParams } = require '../../../testhelper/handler/getprofilehelper'

# begin tests
describe 'server.handlers.getprofile', ->

  beforeEach (done) ->

    # including models before each test case, requiring them outside of
    # tests suite is causing undefined errors
    {
      JUser
      JAccount
    } = koding.models

    done()


  it 'should send HTTP 404 if user is not found for the given email.', (done) ->



    methods.forEach (method) ->
      requestParams = generateGetProfileRequestParams { email, method }
      queue.push (next) ->
        request requestParams, (err, res, body) ->
          expect(err).to.not.exist
          expect(res.statusCode).to.be.equal 404
          expect(body).to.be.equal 'no user found'
          next()

    async.series queue, done


  it 'should send HTTP 200 if user is found for the given email.', (done) ->
