gitlab-org--gitlab-foss/spec/features/dashboard/issuables_counter_spec.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe 'Navigation bar counter', feature: true, caching: true do
let(:user) { create(:user) }
2016-11-09 17:15:29 -05:00
let(:project) { create(:empty_project, namespace: user.namespace) }
2016-11-15 03:05:19 -05:00
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
issue.assignees = [user]
2016-11-15 03:05:19 -05:00
merge_request.update(assignee: user)
login_as(user)
end
it 'reflects dashboard issues count' do
visit issues_path
2016-11-15 03:05:19 -05:00
expect_counters('issues', '1')
issue.assignees = []
user.update_cache_counts
Timecop.travel(3.minutes.from_now) do
visit issues_path
expect_counters('issues', '0')
end
end
it 'reflects dashboard merge requests count' do
visit merge_requests_path
2016-11-15 03:05:19 -05:00
expect_counters('merge_requests', '1')
2016-11-15 03:05:19 -05:00
merge_request.update(assignee: nil)
Timecop.travel(3.minutes.from_now) do
visit merge_requests_path
expect_counters('merge_requests', '0')
end
end
def issues_path
issues_dashboard_path(assignee_id: user.id)
end
def merge_requests_path
merge_requests_dashboard_path(assignee_id: user.id)
2016-11-15 03:05:19 -05:00
end
def expect_counters(issuable_type, count)
dashboard_count = find('.nav-links li.active')
2017-02-17 15:23:29 -05:00
nav_count = find(".dashboard-shortcuts-#{issuable_type}")
header_count = find(".header-content .#{issuable_type.tr('_', '-')}-count")
2016-11-15 03:05:19 -05:00
expect(dashboard_count).to have_content(count)
expect(nav_count).to have_content(count)
expect(header_count).to have_content(count)
end
end