Project

General

Profile

Defect #31637 » 0001-Fix-csv-format-of-hours.patch

Seiei Miyagi, 2020-07-23 09:22

View differences:

app/helpers/queries_helper.rb
264 264
    case column.name
265 265
    when :attachments
266 266
      value.to_a.map {|a| a.filename}.join("\n")
267
    when :hours, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours
268
      format_hours(value)
267 269
    else
268 270
      format_object(value, false) do |value|
269 271
        case value.class.name
test/helpers/queries_helper_test.rb
95 95
      assert_include "Non", csv
96 96
    end
97 97
  end
98

  
99
  def test_csv_value
100
    c_hours = QueryColumn.new(:hours)
101
    c_estimated_hours = QueryColumn.new(:estimated_hours)
102
    c_hourtotal_estimated_s = QueryColumn.new(:total_estimated_hours)
103
    c_spent_hours = QueryColumn.new(:spent_hours)
104
    c_total_spent_hours = QueryColumn.new(:total_spent_hours)
105

  
106
    with_settings timespan_format: 'minutes' do
107
      assert_equal "0:30", csv_value(c_hours, Issue.find(1), 0.5)
108
      assert_equal "0:30", csv_value(c_estimated_hours, Issue.find(1), 0.5)
109
      assert_equal "0:30", csv_value(c_hourtotal_estimated_s, Issue.find(1), 0.5)
110
      assert_equal "0:30", csv_value(c_spent_hours, Issue.find(1), 0.5)
111
      assert_equal "0:30", csv_value(c_total_spent_hours, Issue.find(1), 0.5)
112
    end
113

  
114
    with_settings timespan_format: 'decimal' do
115
      assert_equal "0.50", csv_value(c_hours, Issue.find(1), 0.5)
116
      assert_equal "0.50", csv_value(c_estimated_hours, Issue.find(1), 0.5)
117
      assert_equal "0.50", csv_value(c_hourtotal_estimated_s, Issue.find(1), 0.5)
118
      assert_equal "0.50", csv_value(c_spent_hours, Issue.find(1), 0.5)
119
      assert_equal "0.50", csv_value(c_total_spent_hours, Issue.find(1), 0.5)
120
    end
121
  end
98 122
end
(1-1/2)