diff options
author | Rémy Coutable <remy@rymai.me> | 2018-05-24 19:23:13 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-05-24 19:23:13 +0300 |
commit | 0279a72752e17d773c81c46c602204c318fd1ecd (patch) | |
tree | ddf3acb6fb6fdd296481c83f262bced2168a7621 /spec/services/projects | |
parent | 6d2a6139721df93c633c58c24ed9a88ac59a080b (diff) | |
parent | aee2b235499f9ea179aed82d6beb8ea955986aa3 (diff) |
Merge branch 'issue_38418' into 'master'
Fix sidebar issue count
Closes #38418
See merge request gitlab-org/gitlab-ce!19022
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/open_issues_count_service_spec.rb | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/spec/services/projects/open_issues_count_service_spec.rb b/spec/services/projects/open_issues_count_service_spec.rb index f964f9972cd..06b470849b3 100644 --- a/spec/services/projects/open_issues_count_service_spec.rb +++ b/spec/services/projects/open_issues_count_service_spec.rb @@ -2,20 +2,53 @@ require 'spec_helper' describe Projects::OpenIssuesCountService do describe '#count' do - it 'returns the number of open issues' do - project = create(:project) - create(:issue, :opened, project: project) + let(:project) { create(:project) } - expect(described_class.new(project).count).to eq(1) + context 'when user is nil' do + it 'does not include confidential issues in the issue count' do + create(:issue, :opened, project: project) + create(:issue, :opened, confidential: true, project: project) + + expect(described_class.new(project).count).to eq(1) + end end - it 'does not include confidential issues in the issue count' do - project = create(:project) + context 'when user is provided' do + let(:user) { create(:user) } + + context 'when user can read confidential issues' do + before do + project.add_reporter(user) + end + + it 'returns the right count with confidential issues' do + create(:issue, :opened, project: project) + create(:issue, :opened, confidential: true, project: project) + + expect(described_class.new(project, user).count).to eq(2) + end + + it 'uses total_open_issues_count cache key' do + expect(described_class.new(project, user).cache_key_name).to eq('total_open_issues_count') + end + end + + context 'when user cannot read confidential issues' do + before do + project.add_guest(user) + end + + it 'does not include confidential issues' do + create(:issue, :opened, project: project) + create(:issue, :opened, confidential: true, project: project) - create(:issue, :opened, project: project) - create(:issue, :opened, confidential: true, project: project) + expect(described_class.new(project, user).count).to eq(1) + end - expect(described_class.new(project).count).to eq(1) + it 'uses public_open_issues_count cache key' do + expect(described_class.new(project, user).cache_key_name).to eq('public_open_issues_count') + end + end end end end |