diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-06 11:08:43 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-06 11:08:43 +0000 |
commit | 24fc7c878aa317e6f0163409fbf6d08256f7b324 (patch) | |
tree | 16b8238b82b66d76d2f7c0a047ac0c43979c1360 /spec | |
parent | 1632ffa6ad16738994122f0e84f331d50f220879 (diff) | |
parent | ed43c6f1fd2c01307c4fe9fb8ba52a7c1a72f624 (diff) | |
download | gitlab-ce-24fc7c878aa317e6f0163409fbf6d08256f7b324.tar.gz |
Merge branch '19650-remove-admin-section-from-search-results-if-user-doesnt-have-access' into 'master'
Hide admin link from default search results for non-admins
Closes #19650
See merge request !14015
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/search_helper_spec.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index 463af15930d..ab647401e14 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -17,7 +17,7 @@ describe SearchHelper do end end - context "with a user" do + context "with a standard user" do let(:user) { create(:user) } before do @@ -29,7 +29,11 @@ describe SearchHelper do end it "includes default sections" do - expect(search_autocomplete_opts("adm").size).to eq(1) + expect(search_autocomplete_opts("dash").size).to eq(1) + end + + it "does not include admin sections" do + expect(search_autocomplete_opts("admin").size).to eq(0) end it "does not allow regular expression in search term" do @@ -67,6 +71,18 @@ describe SearchHelper do end end end + + context 'with an admin user' do + let(:admin) { create(:admin) } + + before do + allow(self).to receive(:current_user).and_return(admin) + end + + it "includes admin sections" do + expect(search_autocomplete_opts("admin").size).to eq(1) + end + end end describe 'search_filter_input_options' do |