diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 12:07:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 12:07:53 +0300 |
commit | a821bd6ad17e304ca93838a411410a44ee9cff9f (patch) | |
tree | 5444ab20a2f8b22db736a93c5c376928dde8e450 /spec/support/shared_examples/requests | |
parent | f6e985dba4d0f5b1ede95e9174d30dd6a8bedf0d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/requests')
-rw-r--r-- | spec/support/shared_examples/requests/self_monitoring_shared_examples.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb b/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb new file mode 100644 index 00000000000..6dea7fcda3c --- /dev/null +++ b/spec/support/shared_examples/requests/self_monitoring_shared_examples.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'not accessible if feature flag is disabled' do + before do + stub_feature_flags(self_monitoring_project: false) + end + + it 'returns not_implemented' do + subject + + aggregate_failures do + expect(response).to have_gitlab_http_status(:not_implemented) + expect(json_response).to eq( + 'message' => _('Self-monitoring is not enabled on this GitLab server, contact your administrator.'), + 'documentation_url' => help_page_path('administration/monitoring/gitlab_instance_administration_project/index') + ) + end + end +end + +RSpec.shared_examples 'not accessible to non-admin users' do + context 'with unauthenticated user' do + it 'redirects to signin page' do + subject + + expect(response).to redirect_to(new_user_session_path) + end + end + + context 'with authenticated non-admin user' do + before do + login_as(create(:user)) + end + + it 'returns status not_found' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end +end |