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