Commit d88c4c12 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Test for group creation and remove duplicated test

parent 32e3955b
...@@ -90,6 +90,9 @@ module API ...@@ -90,6 +90,9 @@ module API
group_access: params.delete(:ldap_access) group_access: params.delete(:ldap_access)
} }
# EE
authenticated_as_admin! if params[:shared_runners_minutes_limit]
group = ::Groups::CreateService.new(current_user, declared_params(include_missing: false)).execute group = ::Groups::CreateService.new(current_user, declared_params(include_missing: false)).execute
if group.persisted? if group.persisted?
......
...@@ -494,23 +494,31 @@ describe API::Groups do ...@@ -494,23 +494,31 @@ describe API::Groups do
group_attributes = attributes_for(:group, ldap_cn: 'ldap-group', ldap_access: Gitlab::Access::DEVELOPER) group_attributes = attributes_for(:group, ldap_cn: 'ldap-group', ldap_access: Gitlab::Access::DEVELOPER)
expect { post api("/groups", admin), group_attributes }.to change{ LdapGroupLink.count }.by(1) expect { post api("/groups", admin), group_attributes }.to change{ LdapGroupLink.count }.by(1)
end end
end
end
describe "PUT /groups" do # EE
context "when authenticated as user without group permissions" do context 'when shared_runners_minutes_limit is given' do
it "does not create group" do context 'when the current user is not an admin' do
put api("/groups/#{group2.id}", user1), attributes_for(:group) it "does not create a group with shared_runners_minutes_limit" do
expect(response.status).to eq(404) group = attributes_for(:group, { shared_runners_minutes_limit: 133 })
end
end
context "when authenticated as user with group permissions" do post api("/groups", user3), group
it "updates group" do
group2.update(owner: user2) expect(response).to have_http_status(403)
put api("/groups/#{group2.id}", user2), { name: 'Renamed' } end
expect(response.status).to eq(200) end
expect(group2.reload.name).to eq('Renamed')
context 'when the current user is an admin' do
it "creates a group with shared_runners_minutes_limit" do
group = attributes_for(:group, { shared_runners_minutes_limit: 133 })
post api("/groups", admin), group
created_group = Group.find(json_response['id'])
expect(response).to have_http_status(201)
expect(created_group.shared_runners_minutes_limit).to eq(133)
end
end
end end
end end
end end
......
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