users_spec.rb 937 字节
Newer Older
N
Nihad Abbasov 已提交
1 2 3
require 'spec_helper'

describe Gitlab::API do
4 5
  include ApiHelpers

N
Nihad Abbasov 已提交
6 7 8 9
  let(:user) { Factory :user }

  describe "GET /users" do
    it "should return authentication error" do
R
Robert Speicher 已提交
10
      get api("/users")
N
Nihad Abbasov 已提交
11 12 13 14 15
      response.status.should == 401
    end

    describe "authenticated GET /users" do
      it "should return an array of users" do
R
Robert Speicher 已提交
16
        get api("/users", user)
N
Nihad Abbasov 已提交
17
        response.status.should == 200
N
Nihad Abbasov 已提交
18 19
        json_response.should be_an Array
        json_response.first['email'].should == user.email
N
Nihad Abbasov 已提交
20 21 22 23 24 25
      end
    end
  end

  describe "GET /users/:id" do
    it "should return a user by id" do
R
Robert Speicher 已提交
26
      get api("/users/#{user.id}", user)
N
Nihad Abbasov 已提交
27
      response.status.should == 200
N
Nihad Abbasov 已提交
28
      json_response['email'].should == user.email
N
Nihad Abbasov 已提交
29 30 31 32 33
    end
  end

  describe "GET /user" do
    it "should return current user" do
R
Robert Speicher 已提交
34
      get api("/user", user)
N
Nihad Abbasov 已提交
35
      response.status.should == 200
N
Nihad Abbasov 已提交
36
      json_response['email'].should == user.email
N
Nihad Abbasov 已提交
37 38 39
    end
  end
end