diff options
author | Stan Hu <stanhu@gmail.com> | 2015-05-25 16:51:37 -0400 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-05-28 11:39:12 -0700 |
commit | 67992b9be6fc19ef4cc06de48995d1ee9617049a (patch) | |
tree | ccd191c5d27b5c9597daa4ca2e6ae1fb655ad823 /spec/requests | |
parent | 06250eef2e12ed509b88f3770ae6d3fa4614b74d (diff) | |
download | gitlab-ce-67992b9be6fc19ef4cc06de48995d1ee9617049a.tar.gz |
Make namespace API available to all users
Closes https://github.com/gitlabhq/gitlabhq/issues/9328
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/namespaces_spec.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 6ddaaa0a6dd..21787fdd895 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe API::API, api: true do include ApiHelpers let(:admin) { create(:admin) } + let(:user) { create(:user) } let!(:group1) { create(:group) } let!(:group2) { create(:group) } @@ -14,7 +15,7 @@ describe API::API, api: true do end end - context "when authenticated as admin" do + context "when authenticated as admin" do it "admin: should return an array of all namespaces" do get api("/namespaces", admin) expect(response.status).to eq(200) @@ -22,6 +23,32 @@ describe API::API, api: true do expect(json_response.length).to eq(Namespace.count) end + + it "admin: should return an array of matched namespaces" do + get api("/namespaces?search=#{group1.name}", admin) + expect(response.status).to eq(200) + expect(json_response).to be_an Array + + expect(json_response.length).to eq(1) + end + end + + context "when authenticated as a regular user" do + it "user: should return an array of namespaces" do + get api("/namespaces", user) + expect(response.status).to eq(200) + expect(json_response).to be_an Array + + expect(json_response.length).to eq(1) + end + + it "admin: should return an array of matched namespaces" do + get api("/namespaces?search=#{user.username}", user) + expect(response.status).to eq(200) + expect(json_response).to be_an Array + + expect(json_response.length).to eq(1) + end end end end |