From 769cc2e998ba5d912e6ccf8c06cc4e8fb6a4e215 Mon Sep 17 00:00:00 2001 From: Seiei Miyagi Date: Thu, 23 Jul 2020 15:49:44 +0900 Subject: [PATCH] Fix csv format of hours --- app/helpers/queries_helper.rb | 2 ++ test/helpers/queries_helper_test.rb | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index a9d8cff6f..72c36d1e4 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -264,6 +264,8 @@ def csv_value(column, object, value) case column.name when :attachments value.to_a.map {|a| a.filename}.join("\n") + when :hours, :estimated_hours, :total_estimated_hours, :spent_hours, :total_spent_hours + format_hours(value) else format_object(value, false) do |value| case value.class.name diff --git a/test/helpers/queries_helper_test.rb b/test/helpers/queries_helper_test.rb index 944c4f42a..3260c791b 100644 --- a/test/helpers/queries_helper_test.rb +++ b/test/helpers/queries_helper_test.rb @@ -95,4 +95,28 @@ def test_query_to_csv_should_translate_boolean_custom_field_values assert_include "Non", csv end end + + def test_csv_value + c_hours = QueryColumn.new(:hours) + c_estimated_hours = QueryColumn.new(:estimated_hours) + c_hourtotal_estimated_s = QueryColumn.new(:total_estimated_hours) + c_spent_hours = QueryColumn.new(:spent_hours) + c_total_spent_hours = QueryColumn.new(:total_spent_hours) + + with_settings timespan_format: 'minutes' do + assert_equal "0:30", csv_value(c_hours, Issue.find(1), 0.5) + assert_equal "0:30", csv_value(c_estimated_hours, Issue.find(1), 0.5) + assert_equal "0:30", csv_value(c_hourtotal_estimated_s, Issue.find(1), 0.5) + assert_equal "0:30", csv_value(c_spent_hours, Issue.find(1), 0.5) + assert_equal "0:30", csv_value(c_total_spent_hours, Issue.find(1), 0.5) + end + + with_settings timespan_format: 'decimal' do + assert_equal "0.50", csv_value(c_hours, Issue.find(1), 0.5) + assert_equal "0.50", csv_value(c_estimated_hours, Issue.find(1), 0.5) + assert_equal "0.50", csv_value(c_hourtotal_estimated_s, Issue.find(1), 0.5) + assert_equal "0.50", csv_value(c_spent_hours, Issue.find(1), 0.5) + assert_equal "0.50", csv_value(c_total_spent_hours, Issue.find(1), 0.5) + end + end end -- 2.27.0