diff options
author | Małgorzata Ksionek <meksionek@gmail.com> | 2019-02-12 13:29:47 +0100 |
---|---|---|
committer | Małgorzata Ksionek <meksionek@gmail.com> | 2019-02-20 11:08:13 +0100 |
commit | 211c4e5985bf40afe7cf2391c76a6cfde153fb49 (patch) | |
tree | f675af054959391d825b3ebd8d0af02767bf2557 /spec/controllers/projects/group_links_controller_spec.rb | |
parent | 459276846372d8309220a5667cb4389dcfc66281 (diff) | |
download | gitlab-ce-211c4e5985bf40afe7cf2391c76a6cfde153fb49.tar.gz |
Change policy regarding group visibility
Diffstat (limited to 'spec/controllers/projects/group_links_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/group_links_controller_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb index 675eeff8d12..ce021b2f085 100644 --- a/spec/controllers/projects/group_links_controller_spec.rb +++ b/spec/controllers/projects/group_links_controller_spec.rb @@ -65,8 +65,24 @@ describe Projects::GroupLinksController do end end + context 'when user does not have access to the public group' do + let(:group) { create(:group, :public) } + + include_context 'link project to group' + + it 'renders 404' do + expect(response.status).to eq 404 + end + + it 'does not share project with that group' do + expect(group.shared_projects).not_to include project + end + end + context 'when project group id equal link group id' do before do + group2.add_developer(user) + post(:create, params: { namespace_id: project.namespace, project_id: project, @@ -102,5 +118,26 @@ describe Projects::GroupLinksController do expect(flash[:alert]).to eq('Please select a group.') end end + + context 'when link is not persisted in the database' do + before do + allow(::Projects::GroupLinks::CreateService).to receive_message_chain(:new, :execute) + .and_return({ status: :error, http_status: 409, message: 'error' }) + + post(:create, params: { + namespace_id: project.namespace, + project_id: project, + link_group_id: group.id, + link_group_access: ProjectGroupLink.default_access + }) + end + + it 'redirects to project group links page' do + expect(response).to redirect_to( + project_project_members_path(project) + ) + expect(flash[:alert]).to eq('error') + end + end end end |