2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-09 01:59:51 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
|
2016-11-09 01:59:51 -05:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(: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) }
|
2016-11-09 01:59:51 -05:00
|
|
|
|
|
|
|
before do
|
2017-05-04 08:11:15 -04:00
|
|
|
issue.assignees = [user]
|
2021-04-06 02:09:00 -04:00
|
|
|
merge_request.update!(assignees: [user])
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-11-09 01:59:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'reflects dashboard issues count' do
|
2017-04-06 14:17:07 -04:00
|
|
|
visit issues_path
|
2016-11-10 17:41:25 -05:00
|
|
|
|
2016-11-15 03:05:19 -05:00
|
|
|
expect_counters('issues', '1')
|
2016-11-10 17:41:25 -05:00
|
|
|
|
2017-05-04 08:11:15 -04:00
|
|
|
issue.assignees = []
|
2016-11-09 01:59:51 -05:00
|
|
|
|
2017-05-10 16:54:10 -04:00
|
|
|
user.invalidate_cache_counts
|
2017-05-05 06:41:35 -04:00
|
|
|
|
2020-10-19 17:09:06 -04:00
|
|
|
travel_to(3.minutes.from_now) do
|
2017-04-06 14:17:07 -04:00
|
|
|
visit issues_path
|
|
|
|
|
|
|
|
expect_counters('issues', '0')
|
|
|
|
end
|
2016-11-09 01:59:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'reflects dashboard merge requests count' do
|
2017-04-06 14:17:07 -04:00
|
|
|
visit merge_requests_path
|
2016-11-10 17:41:25 -05:00
|
|
|
|
2016-11-15 03:05:19 -05:00
|
|
|
expect_counters('merge_requests', '1')
|
2016-11-10 17:41:25 -05:00
|
|
|
|
2021-04-06 02:09:00 -04:00
|
|
|
merge_request.update!(assignees: [])
|
2016-11-09 01:59:51 -05:00
|
|
|
|
2017-05-10 16:54:10 -04:00
|
|
|
user.invalidate_cache_counts
|
|
|
|
|
2020-10-19 17:09:06 -04:00
|
|
|
travel_to(3.minutes.from_now) do
|
2017-04-06 14:17:07 -04:00
|
|
|
visit merge_requests_path
|
|
|
|
|
|
|
|
expect_counters('merge_requests', '0')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def issues_path
|
2018-10-28 23:03:43 -04:00
|
|
|
issues_dashboard_path(assignee_username: user.username)
|
2017-04-06 14:17:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def merge_requests_path
|
2018-10-28 23:03:43 -04:00
|
|
|
merge_requests_dashboard_path(assignee_username: user.username)
|
2016-11-15 03:05:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def expect_counters(issuable_type, count)
|
2017-04-06 14:17:07 -04:00
|
|
|
dashboard_count = find('.nav-links li.active')
|
2017-02-17 15:23:29 -05:00
|
|
|
nav_count = find(".dashboard-shortcuts-#{issuable_type}")
|
2017-04-06 14:17:07 -04:00
|
|
|
header_count = find(".header-content .#{issuable_type.tr('_', '-')}-count")
|
2016-11-09 01:59:51 -05:00
|
|
|
|
2016-11-15 03:05:19 -05:00
|
|
|
expect(dashboard_count).to have_content(count)
|
2017-04-06 14:17:07 -04:00
|
|
|
expect(nav_count).to have_content(count)
|
|
|
|
expect(header_count).to have_content(count)
|
2016-11-09 01:59:51 -05:00
|
|
|
end
|
|
|
|
end
|