summaryrefslogtreecommitdiff
path: root/spec/features/dashboard/active_tab_spec.rb
blob: 92d0c0c92603918aa5f457a5914ae1cf7c9541d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Dashboard Active Tab', :js do
  before do
    sign_in(create(:user))
  end

  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
    it_behaves_like 'page has active tab', 'Projects' do
      subject { visit dashboard_projects_path }
    end
  end

  context 'on dashboard groups' do
    it_behaves_like 'page has active tab', 'Groups' do
      subject { visit dashboard_groups_path }
    end
  end

  context 'on activity projects' do
    it_behaves_like 'page has active tab', 'Activity' do
      subject { visit activity_dashboard_path }
    end
  end

  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