active_tab_spec.rb 1.04 KB
Newer Older
1 2
require 'spec_helper'

3
RSpec.describe 'Dashboard Active Tab', js: true, feature: true do
4 5 6 7 8 9
  before do
    login_as :user
  end

  shared_examples 'page has active tab' do |title|
    it "#{title} tab" do
10 11 12
      find('.global-dropdown-toggle').trigger('click')
      expect(page).to have_selector('.global-dropdown-menu li.active', count: 1)
      expect(find('.global-dropdown-menu li.active')).to have_content(title)
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 47
    end
  end

  context 'on dashboard projects' do
    before do
      visit dashboard_projects_path
    end

    it_behaves_like 'page has active tab', 'Projects'
  end

  context 'on dashboard issues' do
    before do
      visit issues_dashboard_path
    end

    it_behaves_like 'page has active tab', 'Issues'
  end

  context 'on dashboard merge requests' do
    before do
      visit merge_requests_dashboard_path
    end

    it_behaves_like 'page has active tab', 'Merge Requests'
  end

  context 'on dashboard groups' do
    before do
      visit dashboard_groups_path
    end

    it_behaves_like 'page has active tab', 'Groups'
  end
end