         generateCreateTeamRequestParams options, (createTeamRequestParams) ->
 
           request.post createTeamRequestParams, (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()
+
+      (next) ->
         # expecting group to be crated
         JGroup.one { slug :groupSlug }, (err, group) ->
-          expect(err)         .to.not.exist
-          expect(group)       .to.exist
-          queue.next()
-
-      ->
+          expect(err).to.not.exist
+          expect(group).to.exist
+          next()
+
+      (next) ->
         # expecting invitation to be created with correct data
         params = { email : inviteeEmail }
 
         JInvitation.one params, (err, invitation) ->
-          expect(err)                   .to.not.exist
-          expect(invitation)            .to.exist
-          expect(invitation.code)       .to.exist
-          expect(invitation.email)      .to.be.equal inviteeEmail
-          expect(invitation.status)     .to.be.equal 'pending'
-          expect(invitation.groupName)  .to.be.equal groupSlug
+          expect(err).to.not.exist
+          expect(invitation).to.exist
+          expect(invitation.code).to.exist
+          expect(invitation.email).to.be.equal inviteeEmail
+          expect(invitation.status).to.be.equal 'pending'
+          expect(invitation.groupName).to.be.equal groupSlug
 
           token = invitation.code
-          queue.next()
-
-      ->
+          next()
+
+      (next) ->
         # expecting to be able to get team members data
         url = generateUrl
           route : "-/team/#{groupSlug}/members?token=#{token}&limit=10"


    queue = [

      ->
        options = { body : { slug : groupSlug } }
        generateCreateTeamRequestParams options, (createTeamRequestParams) ->

          request.post createTeamRequestParams, (err, res, body) ->
            expect(err)             .to.not.exist
            expect(res.statusCode)  .to.be.equal 200
            queue.next()

      ->
        getTeamMembersRequestParams = generateGetTeamMembersRequestParams
          groupSlug : groupSlug
          body      :
            token   : ''

        request.get getTeamMembersRequestParams, (err, res, body) ->
          expect(err)             .to.not.exist
          expect(res.statusCode)  .to.be.equal 403
          expect(body)            .to.be.equal 'not authorized'
          queue.next()

      -> done()

    ]

    daisy queue


  it 'should send HTTP 403 when token is invalid', (done) ->

{ Relationship }                        = require 'jraphical'
{ async
  expect
  request
  querystring
  generateUrl
  generateRandomEmail
  generateRandomString }                = require '../../../testhelper'
{ generateRegisterRequestParams }       = require '../../../testhelper/handler/registerhelper'
{ generateCreateTeamRequestParams
  generateGetTeamMembersRequestParams } = require '../../../testhelper/handler/teamhelper'

JGroup      = require '../../../models/group'
JInvitation = require '../../../models/invitation'


# here we have actual tests
runTests = -> describe 'server.handlers.getteammembers', ->

  it 'should send HTTP 404 if group does not exist', (done) ->

    getTeamMembersRequestParams = generateGetTeamMembersRequestParams
      groupSlug : 'someInvalidGroup'

    request.post getTeamMembersRequestParams, (err, res, body) ->
      expect(err).to.not.exist
      expect(res.statusCode).to.be.equal 404
      expect(body).to.be.equal 'no group found'
      done()


