Project

General

Profile

Defect #42342 » 0001-Fix-thousands-separator-for-integer-float-custom-field-totals.patch

Katsuya HIDAKA, 2025-03-01 09:46

View differences:

app/helpers/queries_helper.rb
192 192
    value =
193 193
      if [:hours, :spent_hours, :total_spent_hours, :estimated_hours, :total_estimated_hours, :estimated_remaining_hours].include? column.name
194 194
        format_hours(value)
195
      elsif column.is_a?(QueryCustomFieldColumn)
196
        format_object(value, thousands_delimiter: column.custom_field.thousands_delimiter?)
195 197
      else
196 198
        format_object(value)
197 199
      end
test/functional/issues_controller_test.rb
2003 2003

  
2004 2004
  def test_index_with_int_custom_field_total
2005 2005
    field = IssueCustomField.generate!(:field_format => 'int', :is_for_all => true)
2006
    CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '2')
2007
    CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '7')
2008
    get(:index, :params => {:t => ["cf_#{field.id}"]})
2006
    CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '9800')
2007
    CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '10')
2008

  
2009
    field_with_delimiter = IssueCustomField.generate!(:field_format => 'int', :thousands_delimiter => '1', :is_for_all => true)
2010
    CustomValue.create!(:customized => Issue.find(1), :custom_field => field_with_delimiter, :value => '9800')
2011
    CustomValue.create!(:customized => Issue.find(2), :custom_field => field_with_delimiter, :value => '10')
2012

  
2013
    get(:index, :params => {:t => ["cf_#{field.id}", "cf_#{field_with_delimiter.id}"]})
2014
    assert_response :success
2015
    assert_select '.query-totals'
2016
    assert_select ".total-for-cf-#{field.id} span.value", :text => '9810'
2017
    assert_select ".total-for-cf-#{field_with_delimiter.id} span.value", :text => '9,810'
2018
  end
2019

  
2020
  def test_index_with_float_custom_field_total
2021
    field = IssueCustomField.generate!(field_format: 'float', is_for_all: true)
2022
    CustomValue.create!(customized: Issue.find(1), custom_field: field, value: '1000000.01')
2023
    CustomValue.create!(customized: Issue.find(2), custom_field: field, value: '99.01')
2024

  
2025
    field_with_delimiter = IssueCustomField.generate!(field_format: 'float', thousands_delimiter: '1', is_for_all: true)
2026
    CustomValue.create!(customized: Issue.find(1), custom_field: field_with_delimiter, value: '1000000.01')
2027
    CustomValue.create!(customized: Issue.find(2), custom_field: field_with_delimiter, value: '99.01')
2028

  
2029
    get(:index, params: {t: ["cf_#{field.id}", "cf_#{field_with_delimiter.id}"]})
2009 2030
    assert_response :success
2010 2031
    assert_select '.query-totals'
2011
    assert_select ".total-for-cf-#{field.id} span.value", :text => '9'
2032
    assert_select ".total-for-cf-#{field.id} span.value", text: '1000099.02'
2033
    assert_select ".total-for-cf-#{field_with_delimiter.id} span.value", text: '1,000,099.02'
2012 2034
  end
2013 2035

  
2014 2036
  def test_index_with_spent_time_total_should_sum_visible_spent_time_only
(2-2/5)