Commit 1cf0dcb2 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '196718-remove-filter-epic-counts' into 'master'

Remove filter from DescendantCountService

See merge request gitlab-org/gitlab!25975
parents cae084f7 b5d11e60
---
title: Remove visibility check from epic descendant counts
merge_request: 25975
author:
type: changed
......@@ -41,16 +41,13 @@ module Epics
def issues_count
strong_memoize(:issue_counts) do
IssuesFinder.new(current_user).execute.in_epics(accessible_epics).counts_by_state
Issue.in_epics(accessible_epics).counts_by_state
end
end
def accessible_epics
strong_memoize(:epics) do
epics = epic.base_and_descendants
epic_groups = Group.for_epics(epics)
groups = Group.groups_user_can_read_epics(epic_groups, current_user, same_root: true)
epics.in_selected_groups(groups)
epic.base_and_descendants
end
end
end
......
......@@ -15,10 +15,14 @@ describe Epics::DescendantCountService do
let_it_be(:issue2) { create(:issue, project: project, state: :closed) }
let_it_be(:issue3) { create(:issue, project: project, state: :opened) }
let_it_be(:issue4) { create(:issue, project: project, state: :closed) }
let_it_be(:issue5) { create(:issue, :confidential, project: project, state: :opened) }
let_it_be(:issue6) { create(:issue, :confidential, project: project, state: :closed) }
let_it_be(:epic_issue1) { create(:epic_issue, epic: parent_epic, issue: issue1) }
let_it_be(:epic_issue2) { create(:epic_issue, epic: parent_epic, issue: issue2) }
let_it_be(:epic_issue3) { create(:epic_issue, epic: epic1, issue: issue3) }
let_it_be(:epic_issue4) { create(:epic_issue, epic: epic2, issue: issue4) }
let_it_be(:epic_issue5) { create(:epic_issue, epic: epic1, issue: issue5) }
let_it_be(:epic_issue6) { create(:epic_issue, epic: epic2, issue: issue6) }
subject { described_class.new(parent_epic, user) }
......@@ -27,19 +31,8 @@ describe Epics::DescendantCountService do
stub_licensed_features(epics: true)
end
it 'does not count inaccessible epics' do
expect(subject.public_send(method)).to eq 0
end
context 'when authorized' do
before do
subgroup.add_developer(user)
project.add_developer(user)
end
it 'returns correct number of epics' do
expect(subject.public_send(method)).to eq expected_count
end
it 'includes inaccessible epics' do
expect(subject.public_send(method)).to eq expected_count
end
end
......@@ -52,10 +45,10 @@ describe Epics::DescendantCountService do
end
describe '#opened_issues' do
it_behaves_like 'descendants state count', :opened_issues, 2
it_behaves_like 'descendants state count', :opened_issues, 3
end
describe '#closed_issues' do
it_behaves_like 'descendants state count', :closed_issues, 2
it_behaves_like 'descendants state count', :closed_issues, 3
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