summaryrefslogtreecommitdiff
path: root/spec/controllers/groups
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 15:07:53 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 15:07:53 +0000
commita5ab3467a705b62911feacc3cf627fdbb00aa198 (patch)
tree65143ce13405efccb922fc428624ad57c38b6efa /spec/controllers/groups
parenteb30dd6e28f6fc9eb8021d205f6ed84511f001e2 (diff)
downloadgitlab-ce-a5ab3467a705b62911feacc3cf627fdbb00aa198.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/groups')
-rw-r--r--spec/controllers/groups/group_links_controller_spec.rb96
-rw-r--r--spec/controllers/groups/group_members_controller_spec.rb6
2 files changed, 102 insertions, 0 deletions
diff --git a/spec/controllers/groups/group_links_controller_spec.rb b/spec/controllers/groups/group_links_controller_spec.rb
index 8f04822fee6..04f2e33b26a 100644
--- a/spec/controllers/groups/group_links_controller_spec.rb
+++ b/spec/controllers/groups/group_links_controller_spec.rb
@@ -111,4 +111,100 @@ describe Groups::GroupLinksController do
end
end
end
+
+ describe '#update' do
+ let!(:link) do
+ create(:group_group_link, { shared_group: shared_group,
+ shared_with_group: shared_with_group })
+ end
+
+ let(:expiry_date) { 1.month.from_now.to_date }
+
+ subject do
+ post(:update, params: { group_id: shared_group,
+ id: link.id,
+ group_link: { group_access: Gitlab::Access::GUEST,
+ expires_at: expiry_date } })
+ end
+
+ context 'when user has admin access to the shared group' do
+ before do
+ shared_group.add_owner(user)
+ end
+
+ it 'updates existing link' do
+ expect(link.group_access).to eq(Gitlab::Access::DEVELOPER)
+ expect(link.expires_at).to be_nil
+
+ subject
+
+ link.reload
+
+ expect(link.group_access).to eq(Gitlab::Access::GUEST)
+ expect(link.expires_at).to eq(expiry_date)
+ end
+ end
+
+ context 'when user does not have admin access to the shared group' do
+ it 'renders 404' do
+ subject
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(share_group_with_group: false)
+ end
+
+ it 'renders 404' do
+ subject
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+ end
+
+ describe '#destroy' do
+ let!(:link) do
+ create(:group_group_link, { shared_group: shared_group,
+ shared_with_group: shared_with_group })
+ end
+
+ subject do
+ post(:destroy, params: { group_id: shared_group,
+ id: link.id })
+ end
+
+ context 'when user has admin access to the shared group' do
+ before do
+ shared_group.add_owner(user)
+ end
+
+ it 'deletes existing link' do
+ expect { subject }.to change(GroupGroupLink, :count).by(-1)
+ end
+ end
+
+ context 'when user does not have admin access to the shared group' do
+ it 'renders 404' do
+ subject
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(share_group_with_group: false)
+ end
+
+ it 'renders 404' do
+ subject
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+ end
end
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb
index a144d9e0786..1c8a2bd160d 100644
--- a/spec/controllers/groups/group_members_controller_spec.rb
+++ b/spec/controllers/groups/group_members_controller_spec.rb
@@ -31,6 +31,12 @@ describe Groups::GroupMembersController do
expect(assigns(:invited_members).map(&:invite_email)).to match_array(invited.map(&:invite_email))
end
+ it 'assigns skip groups' do
+ get :index, params: { group_id: group }
+
+ expect(assigns(:skip_groups)).to match_array(group.related_group_ids)
+ end
+
it 'restricts search to one email' do
get :index, params: { group_id: group, search_invited: invited.first.invite_email }