diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/controllers/explore/projects_controller_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/controllers/explore/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/explore/projects_controller_spec.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/controllers/explore/projects_controller_spec.rb b/spec/controllers/explore/projects_controller_spec.rb index a2b62aa49d2..2297198878d 100644 --- a/spec/controllers/explore/projects_controller_spec.rb +++ b/spec/controllers/explore/projects_controller_spec.rb @@ -200,6 +200,24 @@ RSpec.describe Explore::ProjectsController do let(:sorting_param) { 'created_asc' } end end + + describe 'GET #index' do + let(:controller_action) { :index } + let(:params_with_name) { { name: 'some project' } } + + context 'when disable_anonymous_project_search is enabled' do + before do + stub_feature_flags(disable_anonymous_project_search: true) + end + + it 'does not show a flash message' do + sign_in(create(:user)) + get controller_action, params: params_with_name + + expect(flash.now[:notice]).to be_nil + end + end + end end context 'when user is not signed in' do @@ -229,5 +247,50 @@ RSpec.describe Explore::ProjectsController do expect(response).to redirect_to new_user_session_path end end + + describe 'GET #index' do + let(:controller_action) { :index } + let(:params_with_name) { { name: 'some project' } } + + context 'when disable_anonymous_project_search is enabled' do + before do + stub_feature_flags(disable_anonymous_project_search: true) + end + + it 'shows a flash message' do + get controller_action, params: params_with_name + + expect(flash.now[:notice]).to eq('You must sign in to search for specific projects.') + end + + context 'when search param is not given' do + it 'does not show a flash message' do + get controller_action + + expect(flash.now[:notice]).to be_nil + end + end + + context 'when format is not HTML' do + it 'does not show a flash message' do + get controller_action, params: params_with_name.merge(format: :atom) + + expect(flash.now[:notice]).to be_nil + end + end + end + + context 'when disable_anonymous_project_search is disabled' do + before do + stub_feature_flags(disable_anonymous_project_search: false) + end + + it 'does not show a flash message' do + get controller_action, params: params_with_name + + expect(flash.now[:notice]).to be_nil + end + end + end end end |