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 ...@@ -41,16 +41,13 @@ module Epics
def issues_count def issues_count
strong_memoize(:issue_counts) do 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
end end
def accessible_epics def accessible_epics
strong_memoize(:epics) do strong_memoize(:epics) do
epics = epic.base_and_descendants 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)
end end
end end
end end
......
...@@ -15,10 +15,14 @@ describe Epics::DescendantCountService do ...@@ -15,10 +15,14 @@ describe Epics::DescendantCountService do
let_it_be(:issue2) { create(:issue, project: project, state: :closed) } let_it_be(:issue2) { create(:issue, project: project, state: :closed) }
let_it_be(:issue3) { create(:issue, project: project, state: :opened) } let_it_be(:issue3) { create(:issue, project: project, state: :opened) }
let_it_be(:issue4) { create(:issue, project: project, state: :closed) } 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_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_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_issue3) { create(:epic_issue, epic: epic1, issue: issue3) }
let_it_be(:epic_issue4) { create(:epic_issue, epic: epic2, issue: issue4) } 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) } subject { described_class.new(parent_epic, user) }
...@@ -27,19 +31,8 @@ describe Epics::DescendantCountService do ...@@ -27,19 +31,8 @@ describe Epics::DescendantCountService do
stub_licensed_features(epics: true) stub_licensed_features(epics: true)
end end
it 'does not count inaccessible epics' do it 'includes inaccessible epics' do
expect(subject.public_send(method)).to eq 0 expect(subject.public_send(method)).to eq expected_count
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
end end
end end
...@@ -52,10 +45,10 @@ describe Epics::DescendantCountService do ...@@ -52,10 +45,10 @@ describe Epics::DescendantCountService do
end end
describe '#opened_issues' do describe '#opened_issues' do
it_behaves_like 'descendants state count', :opened_issues, 2 it_behaves_like 'descendants state count', :opened_issues, 3
end end
describe '#closed_issues' do describe '#closed_issues' do
it_behaves_like 'descendants state count', :closed_issues, 2 it_behaves_like 'descendants state count', :closed_issues, 3
end end
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