Commit 65df88c4 authored by Alexis Reigel's avatar Alexis Reigel

move ability check from service class to view

parent 22f44b50
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
= _("Milestones") = _("Milestones")
%span.badge.badge-pill %span.badge.badge-pill
= limited_count(@search_results.limited_milestones_count) = limited_count(@search_results.limited_milestones_count)
- if can?(current_user, :read_users_list)
%li{ class: active_when(@scope == 'users') } %li{ class: active_when(@scope == 'users') }
= link_to search_filter_path(scope: 'users') do = link_to search_filter_path(scope: 'users') do
Users Users
......
...@@ -138,8 +138,6 @@ module Gitlab ...@@ -138,8 +138,6 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def users def users
return [] unless Ability.allowed?(current_user, :read_users_list)
UsersFinder.new(current_user, search: query).execute UsersFinder.new(current_user, search: query).execute
end end
......
...@@ -123,10 +123,6 @@ describe Gitlab::SearchResults do ...@@ -123,10 +123,6 @@ describe Gitlab::SearchResults do
end end
describe '#users' do describe '#users' do
it 'returns an empty array when the current_user is not allowed to read users list' do
expect(results.objects('users')).to be_empty
end
it 'calls the UsersFinder' do it 'calls the UsersFinder' do
expect(UsersFinder).to receive(:new).with(user, search: 'foo').and_call_original expect(UsersFinder).to receive(:new).with(user, search: 'foo').and_call_original
......
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