diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-06-28 17:27:01 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-06-28 17:27:01 -0300 |
commit | bd4c2847f4a60b392902aa1866c1ccc87cfacbf6 (patch) | |
tree | bcd7c8ffc15c8610c16e9df2df440174d974da20 /spec/requests | |
parent | 7db276897f290889ba7c1e66b38389b1c55f3f80 (diff) | |
download | gitlab-ce-bd4c2847f4a60b392902aa1866c1ccc87cfacbf6.tar.gz |
Rename members_count to members_count_with_descendants and expose only to group admins
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/namespaces_spec.rb | 29 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/v3/projects_spec.rb | 4 |
3 files changed, 26 insertions, 11 deletions
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 03b1f549ce0..fdb7ebb6482 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -18,9 +18,15 @@ describe API::Namespaces do it "returns correct attributes" do get api("/namespaces", admin) + group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' } + user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' } + expect(response).to have_http_status(200) expect(response).to include_pagination_headers - expect(json_response.first).to include('id', 'name', 'path', 'full_path', 'parent_id', 'members_count') + expect(group_kind_json_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', + 'parent_id', 'members_count_with_descendants') + + expect(user_kind_json_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', 'parent_id') end it "admin: returns an array of all namespaces" do @@ -45,12 +51,25 @@ describe API::Namespaces do end context "when authenticated as a regular user" do - it "returns correct attributes" do + it "returns members_count_with_descendants if user can admin group" do + group1.add_owner(user) + get api("/namespaces", user) - expect(response).to have_http_status(200) - expect(response).to include_pagination_headers - expect(json_response.first).to include('id', 'name', 'path', 'full_path', 'parent_id', 'members_count') + owned_group_response = json_response.find { |resource| resource['id'] == group1.id } + + expect(owned_group_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', + 'parent_id', 'members_count_with_descendants') + end + + it "does not returns members_count_with_descendants if user cannot admin group" do + group1.add_guest(user) + + get api("/namespaces", user) + + guest_group_response = json_response.find { |resource| resource['id'] == group1.id } + + expect(guest_group_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', 'parent_id') end it "user: returns an array of namespaces" do diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index b4964ed302a..fd7ff0b9cff 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -698,9 +698,7 @@ describe API::Projects do 'name' => user.namespace.name, 'path' => user.namespace.path, 'kind' => user.namespace.kind, - 'full_path' => user.namespace.full_path, - 'parent_id' => nil, - 'members_count' => nil + 'full_path' => user.namespace.full_path }) end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index 225c28d6f13..cb74868324c 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -734,9 +734,7 @@ describe API::V3::Projects do 'name' => user.namespace.name, 'path' => user.namespace.path, 'kind' => user.namespace.kind, - 'full_path' => user.namespace.full_path, - 'parent_id' => nil, - 'members_count' => nil + 'full_path' => user.namespace.full_path }) end |