diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 12:06:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 12:06:26 +0000 |
commit | d2798d607e11e0ebae83ae909404834388733428 (patch) | |
tree | 096b7f4d4bdb315d28cdcd4d6db4e80911112e9c /spec/controllers | |
parent | d8211a0ed119eada7d292e974a8fc7b0cd982d3c (diff) | |
download | gitlab-ce-d2798d607e11e0ebae83ae909404834388733428.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 0b3833e6515..52a68e987f0 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -171,16 +171,40 @@ describe ApplicationController do end describe '#route_not_found' do + controller(described_class) do + def index + route_not_found + end + end + it 'renders 404 if authenticated' do - allow(controller).to receive(:current_user).and_return(user) - expect(controller).to receive(:not_found) - controller.send(:route_not_found) + sign_in(user) + + get :index + + expect(response).to have_gitlab_http_status(404) end - it 'does redirect to login page via authenticate_user! if not authenticated' do - allow(controller).to receive(:current_user).and_return(nil) - expect(controller).to receive(:authenticate_user!) - controller.send(:route_not_found) + it 'redirects to login page via authenticate_user! if not authenticated' do + get :index + + expect(response).to redirect_to new_user_session_path + end + + context 'request format is unknown' do + it 'redirects if unauthenticated' do + get :index, format: 'unknown' + + expect(response).to redirect_to new_user_session_path + end + + it 'returns a 401 if the feature flag is disabled' do + stub_feature_flags(devise_redirect_unknown_formats: false) + + get :index, format: 'unknown' + + expect(response).to have_gitlab_http_status(401) + end end end |