Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/projects/group_links/create_service_spec.rb')
-rw-r--r--spec/services/projects/group_links/create_service_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/services/projects/group_links/create_service_spec.rb b/spec/services/projects/group_links/create_service_spec.rb
index e3f170ef3fe..6bc0b86545a 100644
--- a/spec/services/projects/group_links/create_service_spec.rb
+++ b/spec/services/projects/group_links/create_service_spec.rb
@@ -103,11 +103,57 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute', feature_category
it_behaves_like 'shareable'
end
end
+
+ context 'when sharing it to a group with OWNER access' do
+ let(:opts) do
+ {
+ link_group_access: Gitlab::Access::OWNER,
+ expires_at: nil
+ }
+ end
+
+ it 'does not share and returns a forbiden error' do
+ expect do
+ result = subject.execute
+
+ expect(result[:status]).to eq(:error)
+ expect(result[:http_status]).to eq(403)
+ end.not_to change { project.reload.project_group_links.count }
+ end
+ end
+ end
+
+ context 'when the user is an OWNER in the project' do
+ before do
+ project.add_owner(user)
+ end
+
+ it_behaves_like 'shareable'
+
+ context 'when sharing it to a group with OWNER access' do
+ let(:opts) do
+ {
+ link_group_access: Gitlab::Access::OWNER,
+ expires_at: nil
+ }
+ end
+
+ it_behaves_like 'shareable'
+ end
end
end
context 'when user does not have permissions to share the project with a group' do
it_behaves_like 'not shareable'
+
+ context 'when the user has less than MAINTAINER access in the project' do
+ before do
+ group.add_guest(user)
+ project.add_developer(user)
+ end
+
+ it_behaves_like 'not shareable'
+ end
end
context 'when group is blank' do