   # GitLab.Client
   # ----------------------------------------------------------------
 
-  describe("GitLab.Client", ->
+  describe("Client", ->
 
     it("saves token", ->
       expect(gitlab.token).toBe(token)

  #        expect(user.sshkeys.first().get("title")).toEqual("Public key")
  #      )
  #    )

  
#
  # GitLab.Blob
  # ----------------------------------------------------------------

  describe("GitLab.Blob", ->
    
    masterBlob = null
    slaveBlob = null

    beforeEach(->
      masterBlob = new GitLab.Blob(
        name: "subfolder/master.txt"
      ,
        project: project1
      )

      slaveBlob = new GitLab.Blob(
        name: "subfolder/slave.txt"
      ,
        project: project1
        branch: "slave"
      )
    )

    it("should fail if correct options are not given", ->
      expect(true).toBe(false)
    )

    describe("fetchContent()", ->

      it("should fetch the blob contents and merge with other data", ->
        spyOnAjax()
        masterBlob.fetchContent()
        waitsFor(->
          return masterBlob.get("content")
        , "blob content never loaded", ajaxTimeout
        )
        runs(->
          expect(lastAjaxCall().args[0].url).toEqual(url + "/projects/owner%2Fproject/repository/blobs/master?filepath=subfolder/master.txt")
          expect(masterBlob.get("content")).toEqual("Hello!")
          expect(masterBlob.get("name")).toEqual("subfolder/master.txt")
        )
      )
  
      it("should use branch if specified", ->
        spyOnAjax()
        slaveBlob.fetchContent()
        expect(lastAjaxCall().args[0].url).toEqual(url + "/projects/owner%2Fproject/repository/blobs/slave?filepath=subfolder/slave.txt")
      )
    )

    describe("defaultCommitMessage()", ->

      it("should give correct message when isNew", ->
        expect(masterBlob.defaultCommitMessage()).toEqual("Created subfolder/master.txt")
      )

      it("should give correct message when !isNew", ->
        masterBlob.set("id", 1)
        expect(masterBlob.defaultCommitMessage()).toEqual("Updated subfolder/master.txt")
      )
    )

    describe("save()", ->

      describe("CREATE", ->

        it("should use correct defaults", ->
          spyOnAjax() 
          masterBlob.set("content", "New Content")
          masterBlob.save()
          expect(lastAjaxCall().args[0].url).toEqual(url + "/projects/owner%2Fproject/repository/files")
          expect(lastAjaxCall().args[0].type).toEqual("POST")
          expect(JSON.parse(lastAjaxCall().args[0].data)).toEqual(
            file_name: "master.txt"
            file_path: "subfolder/"
            content: "New Content"
            commit_message: "Created subfolder/master.txt"
            branch_name: "master"
          )
        )
  
        it("should use branch and commit message if specified", ->
          spyOnAjax() 
          slaveBlob.set("content", "New Content")
          slaveBlob.save(
            commit_message: "Another Message"
          )
          expect(lastAjaxCall().args[0].url).toEqual(url + "/projects/owner%2Fproject/repository/files")
          expect(lastAjaxCall().args[0].type).toEqual("POST")
          expect(JSON.parse(lastAjaxCall().args[0].data)).toEqual(
            file_name: "slave.txt"
            file_path: "subfolder/"
            content: "New Content"
            commit_message: "Another Message"
            branch_name: "slave"
          )
        )
      )
  
      describe("UPDATE", ->
        # CHECK THAT MODEL fetchContent or tree() always gives back a blob model that calls update, not create!!!!
      )
    )
  )

  # gitlab.project
  # ----------------------------------------------------------------

  describe("gitlab.project", ->

    

    it("should fetch the project", ->
      project = gitlab.project("runemadsen/book") # override project to bypass canned folder thing
      project.fetch()
      waitsFor(-> 
        return project.id
      , "project never loaded", ajaxTimeout
      )
      runs(->
        expect(project.get("name")).toBe("Book")
      )
    )

    # gitlab.project.branches
    # ---------------------------------------------------------

    describe("gitlab.project.branches", ->

      it("should fill collection on fetch", ->
        expect(project.branches.url()).toEqual(url + "/projects/owner%2Fproject/repository/branches")
        project.branches.fetch()
        waitsFor(-> 
          return project.branches.length > 0
        , "ssh keys never loaded", ajaxTimeout
        )
        runs(->
          expect(project.branches.length).toBe(2)
          expect(project.branches.first().backboneClass).toEqual("Branch")
          expect(project.branches.first().get("name")).toEqual("master")
        )
      )

    )

    # gitlab.project.members
    # ---------------------------------------------------------

    describe("gitlab.project.members", ->

      it("should instantiate an empty GitLab.Members collection on GitLab.Project#initialize", ->
        expect(project.members.backboneClass).toEqual("Members")
        expect(project.members.length).toBe(0)
      )

      it("should fill collection on fetch", ->
        expect(project.members.url()).toEqual(url + "/projects/owner%2Fproject/members")
        project.members.fetch()
        waitsFor(-> 
          return project.members.length > 0
        , "members never loaded", ajaxTimeout
        )
        runs(->
          expect(project.members.length).toBe(3)
          expect(project.members.first().backboneClass).toEqual("Member")
          expect(project.members.first().get("name")).toEqual("Rune Madsen")
        )
      )

      it("should create a new member", ->
        project.members.create(name:"Rune Madsen")
        waitsFor(-> 
          return project.members.length > 0 && project.members.first().id
        , "member never created", ajaxTimeout
        )
        runs(->
          expect(project.members.length).toBe(1)
          expect(project.members.first().get("username")).toEqual("runemadsen")
        )
      )
    )

    # gitlab.project.tree
    # ---------------------------------------------------------

    describe("gitlab.project.tree", ->

      it("should fetch the tree and parse trees/blobs", ->
        tree = project.tree("/")
        tree.fetch()
        waitsFor(->
          return tree.length > 0
        , "tree never loaded", ajaxTimeout
        )
        runs(->
          # put blobs in models array
          expect(tree.length).toBe(1)
          blob = tree.first()
          expect(blob.backboneClass).toEqual("Blob")
          
          # put trees in trees array
          expect(tree.trees.length).toBe(1)
          subfolder = tree.trees[0]
          expect(subfolder.backboneClass).toEqual("Tree")
          expect(subfolder.path).toEqual("assets")
          expect(subfolder.length).toBe(0)
          expect(subfolder.url()).toBe(url + "/projects/owner%2Fproject/repository/tree?path=assets&ref_name=master") 
        )
      )

      it("should use branch if specified", ->
        tree = project.tree("/", "slave")
        expect(tree.url()).toEqual(url + "/projects/owner%2Fproject/repository/tree?path=%2F&ref_name=slave")
        tree.fetch()
        waitsFor(->
          return tree.length > 0
        , "tree never loaded", ajaxTimeout
        )
        runs(->
          blob = tree.first()
          expect(blob.branch).toEqual("slave") 
          subfolder = tree.trees[0]
          expect(subfolder.url()).toBe(url + "/projects/owner%2Fproject/repository/tree?path=assets&ref_name=slave") 
        )
      )
    )

  )
)

# make sure that the trees api returns full path in blob names when listing a subfolder. Otherwise blob.get("name") logic is wrong.

      it("returns empty GitLab.User model on gitlab.user", ->
        expect(gitlab.user.backboneClass).toEqual("User")
      )
      it("returns empty GitLab.Project model on gitlab.project(full_path)", ->
        expect(project2.backboneClass).toEqual("Project")
        # CHECK THAT THE full_name IS SET TO CORRECT VARS
      )
    )
  )

  # GitLab.User
  # ----------------------------------------------------------------

  describe("User", ->

    describe("fetch()", ->
      it("should call correct URL", ->
