Commit c89d94e5 authored by Nick Thomas's avatar Nick Thomas

Merge branch '291170-issue-mr-list-tabs-icons-sometimes-display-as' into 'master'

Resolve "Issue/MR list tabs - Icons sometimes display as ?"

See merge request gitlab-org/gitlab!52698
parents 752a9ca3 6c8bab8f
......@@ -215,24 +215,12 @@ module IssuablesHelper
state_title = titles[state] || state.to_s.humanize
html = content_tag(:span, state_title)
if display_count
count = issuables_count_for_state(issuable_type, state)
tag =
if count == -1
tooltip = _("Couldn't calculate number of %{issuables}.") % { issuables: issuable_type.to_s.humanize(capitalize: false) }
content_tag(
:span,
'?',
class: 'badge badge-pill has-tooltip',
aria: { label: tooltip },
title: tooltip
)
else
content_tag(:span, number_with_delimiter(count), class: 'badge badge-pill')
end
html << " " << tag
return html.html_safe unless display_count
count = issuables_count_for_state(issuable_type, state)
if count != -1
html << " " << content_tag(:span, number_with_delimiter(count), class: 'badge badge-pill')
end
html.html_safe
......
---
title: Remove MR List counts if they cannot be generated
merge_request: 52698
author:
type: fixed
......@@ -8195,9 +8195,6 @@ msgstr ""
msgid "Could not upload your designs as one or more files uploaded are not supported."
msgstr ""
msgid "Couldn't calculate number of %{issuables}."
msgstr ""
msgid "Country"
msgstr ""
......
......@@ -53,7 +53,7 @@ RSpec.describe 'issuable list', :js do
visit_issuable_list(:issue)
expect(page).to have_text('Open ? Closed ? All ?')
expect(page).to have_text('Open Closed All')
end
it "counts merge requests closing issues icons for each issue" do
......
......@@ -72,28 +72,38 @@ RSpec.describe IssuablesHelper do
let(:user) { create(:user) }
describe 'state text' do
before do
allow(helper).to receive(:issuables_count_for_state).and_return(42)
end
it 'returns "Open" when state is :opened' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span> <span class="badge badge-pill">42</span>')
end
context 'when number of issuables can be generated' do
before do
allow(helper).to receive(:issuables_count_for_state).and_return(42)
end
it 'returns "Closed" when state is :closed' do
expect(helper.issuables_state_counter_text(:issues, :closed, true))
.to eq('<span>Closed</span> <span class="badge badge-pill">42</span>')
it 'returns navigation with badges' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span> <span class="badge badge-pill">42</span>')
expect(helper.issuables_state_counter_text(:issues, :closed, true))
.to eq('<span>Closed</span> <span class="badge badge-pill">42</span>')
expect(helper.issuables_state_counter_text(:merge_requests, :merged, true))
.to eq('<span>Merged</span> <span class="badge badge-pill">42</span>')
expect(helper.issuables_state_counter_text(:merge_requests, :all, true))
.to eq('<span>All</span> <span class="badge badge-pill">42</span>')
end
end
it 'returns "Merged" when state is :merged' do
expect(helper.issuables_state_counter_text(:merge_requests, :merged, true))
.to eq('<span>Merged</span> <span class="badge badge-pill">42</span>')
end
context 'when count cannot be generated' do
before do
allow(helper).to receive(:issuables_count_for_state).and_return(-1)
end
it 'returns "All" when state is :all' do
expect(helper.issuables_state_counter_text(:merge_requests, :all, true))
.to eq('<span>All</span> <span class="badge badge-pill">42</span>')
it 'returns avigation without badges' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span>')
expect(helper.issuables_state_counter_text(:issues, :closed, true))
.to eq('<span>Closed</span>')
expect(helper.issuables_state_counter_text(:merge_requests, :merged, true))
.to eq('<span>Merged</span>')
expect(helper.issuables_state_counter_text(:merge_requests, :all, true))
.to eq('<span>All</span>')
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