Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 12:07:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 12:07:53 +0300
commita821bd6ad17e304ca93838a411410a44ee9cff9f (patch)
tree5444ab20a2f8b22db736a93c5c376928dde8e450 /spec/support/shared_examples/requests
parentf6e985dba4d0f5b1ede95e9174d30dd6a8bedf0d (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.rb41
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