Commit 3d13096f authored by Lucas Deschamps's avatar Lucas Deschamps

Refactor issuables_counter_spec.

parent 7fa36610
require 'spec_helper' require 'spec_helper'
describe 'Navigation bar counter', feature: true, js: true do describe 'Navigation bar counter', feature: true, js: true, caching: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:empty_project, namespace: user.namespace) } let(:project) { create(:empty_project, namespace: user.namespace) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do before do
issue.update(assignee: user)
merge_request.update(assignee: user)
login_as(user) login_as(user)
end end
it 'reflects dashboard issues count' do it 'reflects dashboard issues count' do
issue = create(:issue, project: project, assignee: user)
visit issues_dashboard_path visit issues_dashboard_path
dashboard_count = find('li.active span.badge') expect_counters('issues', '1')
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 issue.update(assignee: nil)
visit issues_dashboard_path visit issues_dashboard_path
dashboard_count = find('li.active span.badge') expect_counters('issues', '1')
nav_count = find('.dashboard-shortcuts-issues span.count')
expect(nav_count).to have_content('1')
expect(dashboard_count).to have_content('1')
end end
it 'reflects dashboard merge requests count' do it 'reflects dashboard merge requests count' do
merge_request = create(:merge_request, source_project: project, assignee: user)
visit merge_requests_dashboard_path visit merge_requests_dashboard_path
dashboard_count = find('li.active span.badge') expect_counters('merge_requests', '1')
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 merge_request.update(assignee: nil)
visit merge_requests_dashboard_path visit merge_requests_dashboard_path
expect_counters('merge_requests', '1')
end
def expect_counters(issuable_type, count)
dashboard_count = find('li.active span.badge') dashboard_count = find('li.active span.badge')
nav_count = find('.dashboard-shortcuts-merge_requests span.count') nav_count = find(".dashboard-shortcuts-#{issuable_type} span.count")
expect(nav_count).to have_content('1') expect(nav_count).to have_content(count)
expect(dashboard_count).to have_content('1') expect(dashboard_count).to have_content(count)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment