debian-mirror-gitlab/spec/support/shared_examples/controllers/instance_statistics_controllers_shared_examples.rb

52 lines
1.3 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2020-03-13 15:44:24 +05:30
RSpec.shared_examples 'instance statistics availability' do
2018-11-18 11:00:15 +05:30
let(:user) { create(:user) }
before do
sign_in(user)
2018-11-20 20:47:30 +05:30
stub_application_setting(usage_ping_enabled: true)
2018-11-18 11:00:15 +05:30
end
describe 'GET #index' do
it 'is available when the feature is available publicly' do
get :index
expect(response).to have_gitlab_http_status(:success)
end
it 'renders a 404 when the feature is not available publicly' do
stub_application_setting(instance_statistics_visibility_private: true)
get :index
expect(response).to have_gitlab_http_status(:not_found)
end
context 'for admins' do
let(:user) { create(:admin) }
2020-05-24 23:13:21 +05:30
context 'when admin mode disabled' do
it 'forbids access when the feature is not available publicly' do
stub_application_setting(instance_statistics_visibility_private: true)
2018-11-18 11:00:15 +05:30
2020-05-24 23:13:21 +05:30
get :index
2018-11-18 11:00:15 +05:30
2020-05-24 23:13:21 +05:30
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when admin mode enabled', :enable_admin_mode do
it 'allows access when the feature is not available publicly' do
stub_application_setting(instance_statistics_visibility_private: true)
get :index
expect(response).to have_gitlab_http_status(:success)
end
2018-11-18 11:00:15 +05:30
end
end
end
end