diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 7bc64cb839..55bd0952f7 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -26,9 +26,9 @@ def reportable_title(reportable) end def open_issues_count - count = Issue.visible_to(current_user).open.limit(100).size - if count > 99 - tag.span("99+", :class => "badge count-number") + count = Issue.visible_to(current_user).open.limit(Settings.max_issues_count).size + if count >= Settings.max_issues_count + tag.span(I18n.t("count.at_least_pattern", :count => Settings.max_issues_count), :class => "badge count-number") elsif count.positive? tag.span(count, :class => "badge count-number") end diff --git a/config/initializers/config.rb b/config/initializers/config.rb index 983f022666..c1cc522a5e 100644 --- a/config/initializers/config.rb +++ b/config/initializers/config.rb @@ -77,6 +77,7 @@ required(:tracepoints_per_page).filled(:int?) required(:max_number_of_way_nodes).filled(:int?) required(:max_number_of_relation_members).filled(:int?) + required(:max_issues_count).filled(:int?) required(:api_timeout).filled(:int?) required(:imagery_blacklist).maybe(:array?) required(:status).filled(:str?, :included_in? => ALLOWED_STATUS) diff --git a/config/locales/en.yml b/config/locales/en.yml index 530dad2079..da346e8e89 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,8 @@ en: formats: friendly: "%e %B %Y at %H:%M" blog: "%e %B %Y" + count: + at_least_pattern: "%{count}+" helpers: file: prompt: Choose file diff --git a/config/settings.yml b/config/settings.yml index e228247e03..214f8a284e 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -43,6 +43,8 @@ max_note_request_area: 25 default_note_query_limit: 100 # Maximum limit on the number of notes returned by the note search api method max_note_query_limit: 10000 +# Maximum value of open issues counter for moderators, anything equal or greater to this value "n" is shown as "n+" +max_issues_count: 99 # Zoom level to use for postcode results from the geocoder postcode_zoom: 15 # Timeout for API calls in seconds diff --git a/test/helpers/issues_helper_test.rb b/test/helpers/issues_helper_test.rb new file mode 100644 index 0000000000..f0b7c884aa --- /dev/null +++ b/test/helpers/issues_helper_test.rb @@ -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") + #{n} + 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") + #{n}+ + HTML + assert_dom_equal expected, open_issues_count + end +end