diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-12 19:08:35 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-12 19:08:35 +0200 |
commit | 5fb572417e0c331afb62c8bbaa561b0fe7836fc5 (patch) | |
tree | e26e6a64d94a26b9a48aa0e998d93538f0fc0ba9 | |
parent | d0cdc2ee73c8421906fbd011d0f44d638616a864 (diff) | |
download | gitlab-ce-5fb572417e0c331afb62c8bbaa561b0fe7836fc5.tar.gz |
Fix minor issues according development guidelines
-rw-r--r-- | doc/api/groups.md | 2 | ||||
-rw-r--r-- | lib/api/groups.rb | 10 | ||||
-rw-r--r-- | spec/requests/api/groups_spec.rb | 16 |
3 files changed, 17 insertions, 11 deletions
diff --git a/doc/api/groups.md b/doc/api/groups.md index 59046190d0f..2821bc21b81 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -140,7 +140,7 @@ PUT /groups/:id | `name` | string | no | The name of the group |
| `path` | string | no | The path of the group |
| `description` | string | no | The description of the group |
-| `visibility_level` | integer | no | The visibility_level of the group. 0 for private, 10 for internal, 20 for public. |
+| `visibility_level` | integer | no | The visibility level of the group. 0 for private, 10 for internal, 20 for public. |
```bash
curl -X PUT -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/groups/5?name=Experimental"
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 964f691afcc..91e420832f3 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -47,7 +47,7 @@ module API # Update group. Available only for users who can administrate groups. # # Parameters: - # id (required) - The ID of a group + # id (required) - The ID of a group # path (optional) - The path of the group # description (optional) - The description of the group # visibility_level (optional) - The visibility level of the group @@ -59,12 +59,10 @@ module API attrs = attributes_for_keys [:name, :path, :description, :visibility_level] - ::Groups::UpdateService.new(group, current_user, attrs).execute - - if group.errors.any? - render_validation_error!(group) - else + if ::Groups::UpdateService.new(group, current_user, attrs).execute present group, with: Entities::GroupDetail + else + render_validation_error!(group) end end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index e7ccbff7ae2..7383c7d11aa 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -100,7 +100,7 @@ describe API::API, api: true do describe 'PUT /groups/:id' do let(:new_group_name) { 'New Group'} - context "when authenticated the group owner" do + context 'when authenticated as the group owner' do it 'updates the group' do put api("/groups/#{group1.id}", user1), name: new_group_name @@ -115,7 +115,7 @@ describe API::API, api: true do end end - context "when authenticated the admin" do + context 'when authenticated as the admin' do it 'updates the group' do put api("/groups/#{group1.id}", admin), name: new_group_name @@ -124,13 +124,21 @@ describe API::API, api: true do end end - context "when authenticated an user" do - it 'updates the group' do + context 'when authenticated as an user that can see the group' do + it 'does not updates the group' do put api("/groups/#{group1.id}", user2), name: new_group_name expect(response.status).to eq(403) end end + + context 'when authenticated as an user that cannot see the group' do + it 'returns 403 when trying to update the group' do + put api("/groups/#{group2.id}", user1), name: new_group_name + + expect(response.status).to eq(403) + end + end end describe "GET /groups/:id/projects" do |