Commit f9d9cd13 authored by Mario de la Ossa's avatar Mario de la Ossa

Hide public groups from NotificationSettings view

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40326 we added
pagination for NotificationSettings view but accidentally removed
`all_available: false` from the service call, which makes all public
groups show up in the view and makes it much harder for a user to find
the group they're interested in.
parent 0a0557a3
......@@ -35,6 +35,6 @@ class Profiles::NotificationsController < Profiles::ApplicationController
private
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
---
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
end
context 'with group notifications' do
let(:notifications_per_page) { 5 }
let_it_be(:group) { create(:group) }
let_it_be(:subgroups) { create_list(:group, 10, parent: group) }
before do
group.add_developer(user)
sign_in(user)
stub_const('Profiles::NotificationsController::NOTIFICATIONS_PER_PAGE', 5)
get :show
stub_const('Profiles::NotificationsController::NOTIFICATIONS_PER_PAGE', notifications_per_page)
end
it 'paginates the groups' do
get :show
expect(assigns(:group_notifications).count).to eq(5)
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
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