debian-mirror-gitlab/spec/features/dashboard/issuables_counter_spec.rb

65 lines
1.6 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace) }
2017-08-17 22:00:37 +05:30
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
issue.assignees = [user]
merge_request.update(assignee: user)
2017-09-10 17:25:29 +05:30
sign_in(user)
2017-08-17 22:00:37 +05:30
end
it 'reflects dashboard issues count' do
visit issues_path
expect_counters('issues', '1')
issue.assignees = []
user.invalidate_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
expect_counters('merge_requests', '1')
merge_request.update(assignee: nil)
user.invalidate_cache_counts
Timecop.travel(3.minutes.from_now) do
visit merge_requests_path
expect_counters('merge_requests', '0')
end
end
def issues_path
2018-12-23 12:14:25 +05:30
issues_dashboard_path(assignee_username: user.username)
2017-08-17 22:00:37 +05:30
end
def merge_requests_path
2018-12-23 12:14:25 +05:30
merge_requests_dashboard_path(assignee_username: user.username)
2017-08-17 22:00:37 +05:30
end
def expect_counters(issuable_type, count)
dashboard_count = find('.nav-links li.active')
nav_count = find(".dashboard-shortcuts-#{issuable_type}")
header_count = find(".header-content .#{issuable_type.tr('_', '-')}-count")
expect(dashboard_count).to have_content(count)
expect(nav_count).to have_content(count)
expect(header_count).to have_content(count)
end
end