summaryrefslogtreecommitdiff
path: root/spec/features/dashboard/issuables_counter_spec.rb
blob: 1960552b41118350f27283a7fa200cf388672d2b (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
47
48
49
50
require 'spec_helper'

describe 'Navigation bar counter', feature: true, js: true do
  let(:user) { create(:user) }
  let(:project) { create(:empty_project, namespace: user.namespace) }

  before do
    login_as(user)
  end

  it 'reflects dashboard issues count' do
    issue = create(:issue, project: project, assignee: user)
    visit issues_dashboard_path

    dashboard_count = find('li.active span.badge')
    nav_count = find('.dashboard-shortcuts-issues span.count')

    expect(nav_count).to have_content('1')
    expect(dashboard_count).to have_content('1')

    issue.assignee = nil
    visit issues_dashboard_path

    dashboard_count = find('li.active span.badge')
    nav_count = find('.dashboard-shortcuts-issues span.count')

    expect(nav_count).to have_content('1')
    expect(dashboard_count).to have_content('1')
  end

  it 'reflects dashboard merge requests count' do
    merge_request = create(:merge_request, source_project: project, assignee: user)
    visit merge_requests_dashboard_path

    dashboard_count = find('li.active span.badge')
    nav_count = find('.dashboard-shortcuts-merge_requests span.count')

    expect(nav_count).to have_content('1')
    expect(dashboard_count).to have_content('1')

    merge_request.assignee = nil
    visit merge_requests_dashboard_path

    dashboard_count = find('li.active span.badge')
    nav_count = find('.dashboard-shortcuts-merge_requests span.count')

    expect(nav_count).to have_content('1')
    expect(dashboard_count).to have_content('1')
  end
end