Commit 5fb57241 authored by Robert Schilling's avatar Robert Schilling

Fix minor issues according development guidelines

parent d0cdc2ee
...@@ -140,7 +140,7 @@ PUT /groups/:id ...@@ -140,7 +140,7 @@ PUT /groups/:id
| `name` | string | no | The name of the group | | `name` | string | no | The name of the group |
| `path` | string | no | The path of the group | | `path` | string | no | The path of the group |
| `description` | string | no | The description 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 ```bash
curl -X PUT -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/groups/5?name=Experimental" curl -X PUT -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/groups/5?name=Experimental"
......
...@@ -59,12 +59,10 @@ module API ...@@ -59,12 +59,10 @@ module API
attrs = attributes_for_keys [:name, :path, :description, :visibility_level] attrs = attributes_for_keys [:name, :path, :description, :visibility_level]
::Groups::UpdateService.new(group, current_user, attrs).execute if ::Groups::UpdateService.new(group, current_user, attrs).execute
if group.errors.any?
render_validation_error!(group)
else
present group, with: Entities::GroupDetail present group, with: Entities::GroupDetail
else
render_validation_error!(group)
end end
end end
......
...@@ -100,7 +100,7 @@ describe API::API, api: true do ...@@ -100,7 +100,7 @@ describe API::API, api: true do
describe 'PUT /groups/:id' do describe 'PUT /groups/:id' do
let(:new_group_name) { 'New Group'} 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 it 'updates the group' do
put api("/groups/#{group1.id}", user1), name: new_group_name put api("/groups/#{group1.id}", user1), name: new_group_name
...@@ -115,7 +115,7 @@ describe API::API, api: true do ...@@ -115,7 +115,7 @@ describe API::API, api: true do
end end
end end
context "when authenticated the admin" do context 'when authenticated as the admin' do
it 'updates the group' do it 'updates the group' do
put api("/groups/#{group1.id}", admin), name: new_group_name put api("/groups/#{group1.id}", admin), name: new_group_name
...@@ -124,13 +124,21 @@ describe API::API, api: true do ...@@ -124,13 +124,21 @@ describe API::API, api: true do
end end
end end
context "when authenticated an user" do context 'when authenticated as an user that can see the group' do
it 'updates the group' do it 'does not updates the group' do
put api("/groups/#{group1.id}", user2), name: new_group_name put api("/groups/#{group1.id}", user2), name: new_group_name
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
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 end
describe "GET /groups/:id/projects" do describe "GET /groups/:id/projects" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment