           expect(err)               .to.not.exist
           expect(session)           .to.exist
           expect(session.username)  .to.be.equal username
+          queue.next()
+
+      -> done()
+
+    ]
+
+    daisy queue
+
+
+  it 'should save relationships correctly', (done) ->
+
+    slug                    = generateRandomString()
+    userId                  = ''
+    groupId                 = ''
+    username                = generateRandomString()
+    accountId               = ''
+    createTeamRequestParams = generateCreateTeamRequestParams
+      body        :
+        username  : username
+        slug      : slug
+
+    queue = [
+
+      ->
+        # expecting HTTP 200 status code
+        request.post createTeamRequestParams, (err, res, body) ->
+          expect(err)             .to.not.exist
+          expect(res.statusCode)  .to.be.equal 200
+          queue.next()
+
+      ->
+        # expecting user to be saved and holding userId
+        params = { username }
+
+        JUser.one params, (err, user) ->
+          expect(err)   .to.not.exist
+          expect(user)  .to.exist
+          userId = user._id
+          queue.next()
+
+      ->
+        # expecting account to be saved and holding accountId
+        params = { 'profile.nickname' : username }
+
+        JAccount.one params, (err, account) ->
+          expect(err)     .to.not.exist
+          expect(account) .to.exist
+          accountId = account._id
+          queue.next()
+
+      ->
+        # expecting group to be saved and holding groupId
+        params = { slug }
+
+        JGroup.one params, (err, group) ->
+          expect(err)     .to.not.exist
+          expect(group)   .to.exist
+          groupId = group._id
+          queue.next()
+
+      ->
+        # expecting owner account of the group to be saved
+        params =
+          $and : [
+            { as       : 'owner' }
+            { sourceId : groupId }
+            { targetId : accountId }
+          ]
+
+        Relationship.one params, (err, relationship) ->
+          expect(err)          .to.not.exist
+          expect(relationship) .to.exist
+          queue.next()
+
+      ->
+        # expecting account also to be saved as a member
+        params =
+          $and : [
+            { as       : 'member' }
+            { sourceId : groupId }
+            { targetId : accountId }
+          ]
+
+        Relationship.one params, (err, relationship) ->
+          expect(err)          .to.not.exist
+          expect(relationship) .to.exist
+          queue.next()
+
+      ->
+        # expecting user to be saved as the owner of the account
+        params =
+          $and : [
+            { as       : 'owner' }
+            { sourceId : userId }
+            { targetId : accountId }
+          ]
+
+        Relationship.one params, (err, relationship) ->
+          expect(err)          .to.not.exist
+          expect(relationship) .to.exist
           queue.next()
 
       -> done()

JGroup                              = null
JAccount                            = null
JSession                            = null
JDomainAlias                        = null



          queue.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 slug
          queue.next()

      ->
        # expecting session to be created
        params = { username }

