Commit 3dc7c5bf authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'do_not_show_all_groups_on_notif_settings' into 'master'

Hide public groups from NotificationSettings view

See merge request gitlab-org/gitlab!40879
parents c13174dc f9d9cd13
...@@ -35,6 +35,6 @@ class Profiles::NotificationsController < Profiles::ApplicationController ...@@ -35,6 +35,6 @@ class Profiles::NotificationsController < Profiles::ApplicationController
private private
def user_groups def user_groups
GroupsFinder.new(current_user).execute.order_name_asc.page(params[:page]).per(NOTIFICATIONS_PER_PAGE) GroupsFinder.new(current_user, all_available: false).execute.order_name_asc.page(params[:page]).per(NOTIFICATIONS_PER_PAGE)
end end
end end
---
title: Do not show all public groups in global notification settings page
merge_request: 40879
author:
type: fixed
...@@ -54,19 +54,36 @@ RSpec.describe Profiles::NotificationsController do ...@@ -54,19 +54,36 @@ RSpec.describe Profiles::NotificationsController do
end end
context 'with group notifications' do context 'with group notifications' do
let(:notifications_per_page) { 5 }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroups) { create_list(:group, 10, parent: group) } let_it_be(:subgroups) { create_list(:group, 10, parent: group) }
before do before do
group.add_developer(user) group.add_developer(user)
sign_in(user) sign_in(user)
stub_const('Profiles::NotificationsController::NOTIFICATIONS_PER_PAGE', 5) stub_const('Profiles::NotificationsController::NOTIFICATIONS_PER_PAGE', notifications_per_page)
get :show
end end
it 'paginates the groups' do it 'paginates the groups' do
get :show
expect(assigns(:group_notifications).count).to eq(5) expect(assigns(:group_notifications).count).to eq(5)
end end
context 'when the user is not a member' do
let(:notifications_per_page) { 20 }
let_it_be(:public_group) { create(:group, :public) }
it 'does not show public groups', :aggregate_failures do
get :show
# Let's make sure we're grabbing all groups in one page, just in case
expect(assigns(:user_groups).count).to eq(11)
expect(assigns(:user_groups)).not_to include(public_group)
end
end
end end
context 'with project notifications' do context 'with project notifications' 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