Change issue count logic from (n-1)+ to n+
This commit is contained in:
parent
fff98f2afb
commit
963b8f43f1
3 changed files with 33 additions and 3 deletions
|
@ -28,7 +28,7 @@ module IssuesHelper
|
||||||
def open_issues_count
|
def open_issues_count
|
||||||
count = Issue.visible_to(current_user).open.limit(Settings.max_issues_count).size
|
count = Issue.visible_to(current_user).open.limit(Settings.max_issues_count).size
|
||||||
if count >= Settings.max_issues_count
|
if count >= Settings.max_issues_count
|
||||||
tag.span("#{Settings.max_issues_count - 1}+", :class => "badge count-number")
|
tag.span("#{Settings.max_issues_count}+", :class => "badge count-number")
|
||||||
elsif count.positive?
|
elsif count.positive?
|
||||||
tag.span(count, :class => "badge count-number")
|
tag.span(count, :class => "badge count-number")
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,8 +43,8 @@ max_note_request_area: 25
|
||||||
default_note_query_limit: 100
|
default_note_query_limit: 100
|
||||||
# Maximum limit on the number of notes returned by the note search api method
|
# Maximum limit on the number of notes returned by the note search api method
|
||||||
max_note_query_limit: 10000
|
max_note_query_limit: 10000
|
||||||
# Maximum value of open issues counter for moderators, anything equal or over this value "n" is shown as "(n-1)+"
|
# Maximum value of open issues counter for moderators, anything equal or greater to this value "n" is shown as "n+"
|
||||||
max_issues_count: 100
|
max_issues_count: 99
|
||||||
# Zoom level to use for postcode results from the geocoder
|
# Zoom level to use for postcode results from the geocoder
|
||||||
postcode_zoom: 15
|
postcode_zoom: 15
|
||||||
# Timeout for API calls in seconds
|
# Timeout for API calls in seconds
|
||||||
|
|
30
test/helpers/issues_helper_test.rb
Normal file
30
test/helpers/issues_helper_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class IssuesHelperTest < ActionView::TestCase
|
||||||
|
attr_accessor :current_user
|
||||||
|
|
||||||
|
def test_issues_count
|
||||||
|
target_user = create(:user)
|
||||||
|
self.current_user = create(:moderator_user)
|
||||||
|
|
||||||
|
n = (Settings.max_issues_count - 1)
|
||||||
|
n.times do
|
||||||
|
create(:note_with_comments) do |note|
|
||||||
|
create(:issue, :reportable => note, :reported_user => target_user, :assigned_role => "moderator")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expected = <<~HTML.delete("\n")
|
||||||
|
<span class="badge count-number">#{n}</span>
|
||||||
|
HTML
|
||||||
|
assert_dom_equal expected, open_issues_count
|
||||||
|
|
||||||
|
n += 1
|
||||||
|
create(:note_with_comments) do |note|
|
||||||
|
create(:issue, :reportable => note, :reported_user => target_user, :assigned_role => "moderator")
|
||||||
|
end
|
||||||
|
expected = <<~HTML.delete("\n")
|
||||||
|
<span class="badge count-number">#{n}+</span>
|
||||||
|
HTML
|
||||||
|
assert_dom_equal expected, open_issues_count
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue