Commit 26b65d06 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '8465-fix-epics-count' into 'master'

Fix epics count in sidebar

See merge request gitlab-org/gitlab-ee!15459
parents 01e53caa 2cc84b5c
......@@ -4,6 +4,13 @@ module EE
module GroupsHelper
extend ::Gitlab::Utils::Override
def group_epics_count(state:)
EpicsFinder
.new(current_user, group_id: @group.id, state: state)
.execute
.count
end
override :group_overview_nav_link_paths
def group_overview_nav_link_paths
super + %w[
......
- return unless group_sidebar_link?(:epics)
- epics = EpicsFinder.new(current_user, group_id: @group.id).execute
- epics_count = group_epics_count(state: 'opened')
- epics_items = ['epics#show', 'epics#index', 'roadmap#show']
= nav_link(path: epics_items) do
......@@ -8,13 +8,13 @@
.nav-icon-container
= sprite_icon('epic')
%span.nav-item-name
Epics
%span.badge.badge-pill.count= number_with_delimiter(epics.count)
= _('Epics')
%span.badge.badge-pill.count= number_with_delimiter(epics_count)
%ul.sidebar-sub-level-items
= nav_link(path: epics_items, html_options: { class: "fly-out-top-item" } ) do
= link_to group_epics_path(group) do
%strong.fly-out-top-item-name= _('Epics')
%span.badge.badge-pill.count.epic_counter.fly-out-badge= number_with_delimiter(epics.count)
%span.badge.badge-pill.count.epic_counter.fly-out-badge= number_with_delimiter(epics_count)
%li.divider.fly-out-top-item
= nav_link(path: 'epics#index', html_options: { class: 'home' }) do
= link_to group_epics_path(group), title: 'List' do
......
---
title: Change epics count in sidebar to only count open epics
merge_request: 15459
author:
type: fixed
require 'spec_helper'
describe GroupsHelper do
let(:user) { create(:user, group_view: :security_dashboard) }
let(:group) { create(:group, :private) }
before do
allow(helper).to receive(:current_user) { user }
helper.instance_variable_set(:@group, group)
group.add_owner(user)
end
let(:user) { create(:user, group_view: :security_dashboard) }
let(:group) { create(:group, :private) }
describe '#group_epics_count' do
before do
stub_licensed_features(epics: true)
create_list(:epic, 3, :opened, group: group)
create_list(:epic, 2, :closed, group: group)
end
it 'returns open epics count' do
expect(helper.group_epics_count(state: 'opened')).to eq(3)
end
it 'returns closed epics count' do
expect(helper.group_epics_count(state: 'closed')).to eq(2)
end
end
describe '#group_sidebar_links' do
before do
group.add_owner(user)
helper.instance_variable_set(:@group, group)
allow(helper).to receive(:can?) { |*args| Ability.allowed?(*args) }
allow(helper).to receive(:show_promotions?) { false }
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