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:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-07-25 18:36:08 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-07-27 15:14:47 +0300
commit61b0e8ca0b2a1c50aeee318c7e42c40fd0816108 (patch)
treee8ee1bf5900919792526c04cf55e2b9647eb917b /spec/features
parentfb6375a57633ba633760e5542739c544bf5595aa (diff)
Spec instance statistics
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/dashboard/active_tab_spec.rb28
-rw-r--r--spec/features/dashboard/instance_statistics_spec.rb60
2 files changed, 77 insertions, 11 deletions
diff --git a/spec/features/dashboard/active_tab_spec.rb b/spec/features/dashboard/active_tab_spec.rb
index 8bab501134b..f4d0f82d248 100644
--- a/spec/features/dashboard/active_tab_spec.rb
+++ b/spec/features/dashboard/active_tab_spec.rb
@@ -7,32 +7,38 @@ RSpec.describe 'Dashboard Active Tab', :js do
shared_examples 'page has active tab' do |title|
it "#{title} tab" do
+ subject
+
expect(page).to have_selector('.navbar-sub-nav li.active', count: 1)
expect(find('.navbar-sub-nav li.active')).to have_content(title)
end
end
context 'on dashboard projects' do
- before do
- visit dashboard_projects_path
+ it_behaves_like 'page has active tab', 'Projects' do
+ subject { visit dashboard_projects_path }
end
-
- it_behaves_like 'page has active tab', 'Projects'
end
context 'on dashboard groups' do
- before do
- visit dashboard_groups_path
+ it_behaves_like 'page has active tab', 'Groups' do
+ subject { visit dashboard_groups_path }
end
-
- it_behaves_like 'page has active tab', 'Groups'
end
context 'on activity projects' do
- before do
- visit activity_dashboard_path
+ it_behaves_like 'page has active tab', 'Activity' do
+ subject { visit activity_dashboard_path }
end
+ end
- it_behaves_like 'page has active tab', 'Activity'
+ context 'on instance statistics' do
+ subject { visit instance_statistics_root_path }
+
+ it 'shows Instance Statistics` as active' do
+ subject
+
+ expect(find('.navbar-sub-nav li.active')).to have_link('Instance Statistics')
+ end
end
end
diff --git a/spec/features/dashboard/instance_statistics_spec.rb b/spec/features/dashboard/instance_statistics_spec.rb
new file mode 100644
index 00000000000..21ee2796bd8
--- /dev/null
+++ b/spec/features/dashboard/instance_statistics_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Showing instance statistics' do
+ 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 }
+
+ it 'does not show the instance statistics link' do
+ subject
+
+ expect(page).not_to have_link('Instance Statistics')
+ 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
+
+ it 'shows the instance statistics link' do
+ subject
+
+ expect(page).to have_link('Instance Statistics')
+ end
+ end
+
+ context 'when instance statistics are not publicly available' do
+ before do
+ stub_application_setting(instance_statistics_visibility_private: true)
+ end
+
+ it 'shows the instance statistics link' do
+ subject
+
+ expect(page).not_to have_link('Instance Statistics')
+ end
+ end
+ end
+
+ context 'for admins' do
+ let(:user) { create(:admin) }
+
+ it 'shows the instance statistics link' do
+ subject
+
+ expect(page).to have_link('Instance Statistics')
+ end
+ end
+end