debian-mirror-gitlab/spec/features/dashboard/instance_statistics_spec.rb

65 lines
1.4 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-03-13 15:44:24 +05:30
describe 'Showing analytics' do
2018-11-18 11:00:15 +05:30
before do
sign_in user if user
end
# Using a path that is publicly accessible
subject { visit explore_projects_path }
context 'for unauthenticated users' do
let(:user) { nil }
2020-03-13 15:44:24 +05:30
it 'does not show the Analytics link' do
2018-11-18 11:00:15 +05:30
subject
2020-03-13 15:44:24 +05:30
expect(page).not_to have_link('Analytics')
2018-11-18 11:00:15 +05:30
end
end
context 'for regular users' do
let(:user) { create(:user) }
context 'when instance statistics are publicly available' do
before do
stub_application_setting(instance_statistics_visibility_private: false)
end
2020-03-13 15:44:24 +05:30
it 'shows the analytics link' do
2018-11-18 11:00:15 +05:30
subject
2020-03-13 15:44:24 +05:30
expect(page).to have_link('Analytics')
2018-11-18 11:00:15 +05:30
end
end
context 'when instance statistics are not publicly available' do
before do
stub_application_setting(instance_statistics_visibility_private: true)
end
2020-03-13 15:44:24 +05:30
it 'does not show the analytics link' do
2018-11-18 11:00:15 +05:30
subject
2020-03-13 15:44:24 +05:30
# Skipping this test on EE as there is an EE specifc spec for this functionality
# ee/spec/features/dashboards/analytics_spec.rb
skip if Gitlab.ee?
expect(page).not_to have_link('Analytics')
2018-11-18 11:00:15 +05:30
end
end
end
context 'for admins' do
let(:user) { create(:admin) }
2020-03-13 15:44:24 +05:30
it 'shows the analytics link' do
2018-11-18 11:00:15 +05:30
subject
2020-03-13 15:44:24 +05:30
expect(page).to have_link('Analytics')
2018-11-18 11:00:15 +05:30
end
end
end