summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2017-06-28 17:27:01 -0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2017-06-28 17:27:01 -0300
commitbd4c2847f4a60b392902aa1866c1ccc87cfacbf6 (patch)
treebcd7c8ffc15c8610c16e9df2df440174d974da20 /spec/requests
parent7db276897f290889ba7c1e66b38389b1c55f3f80 (diff)
downloadgitlab-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.rb29
-rw-r--r--spec/requests/api/projects_spec.rb4
-rw-r--r--spec/requests/api/v3/projects_spec.rb4
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