Commit e4293eb1 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'refactor-strange-search-tabs-method' into 'master'

Refactor search_tab? -> show_user_search_tab?

See merge request gitlab-org/gitlab!19205
parents 85ae815c b9f2409c
...@@ -273,7 +273,7 @@ module SearchHelper ...@@ -273,7 +273,7 @@ module SearchHelper
sanitize(html, tags: %w(a p ol ul li pre code)) sanitize(html, tags: %w(a p ol ul li pre code))
end end
def search_tabs?(tab) def show_user_search_tab?
return false if Feature.disabled?(:users_search, default_enabled: true) return false if Feature.disabled?(:users_search, default_enabled: true)
if @project if @project
......
- users = capture_haml do - users = capture_haml do
- if search_tabs?(:members) - if show_user_search_tab?
= search_filter_link 'users', _("Users") = search_filter_link 'users', _("Users")
.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller .scrolling-tabs-container.inner-page-scroll-tabs.is-smaller
......
...@@ -271,4 +271,50 @@ describe SearchHelper do ...@@ -271,4 +271,50 @@ describe SearchHelper do
expect(link).to have_css('li[data-foo="bar"]') expect(link).to have_css('li[data-foo="bar"]')
end end
end end
describe '#show_user_search_tab?' do
subject { show_user_search_tab? }
context 'when users_search feature is disabled' do
before do
stub_feature_flags(users_search: false)
end
it { is_expected.to eq(false) }
end
context 'when project search' do
before do
@project = :some_project
expect(self).to receive(:project_search_tabs?)
.with(:members)
.and_return(:value)
end
it 'delegates to project_search_tabs?' do
expect(subject).to eq(:value)
end
end
context 'when not project search' do
context 'when current_user can read_users_list' do
before do
allow(self).to receive(:current_user).and_return(:the_current_user)
allow(self).to receive(:can?).with(:the_current_user, :read_users_list).and_return(true)
end
it { is_expected.to eq(true) }
end
context 'when current_user cannot read_users_list' do
before do
allow(self).to receive(:current_user).and_return(:the_current_user)
allow(self).to receive(:can?).with(:the_current_user, :read_users_list).and_return(false)
end
it { is_expected.to eq(false) }
end
end
end
end end
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