From 81291bb25eada75c0c54119288f9006a6ea3a5b9 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 4 Dec 2024 01:58:51 +0000 Subject: [PATCH] Fix: Spent time CSV report returning `hours` as Rational instead of Float (#41895). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23351 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 2 +- test/functional/timelog_controller_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index d2991fd25..708a8acfb 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -309,7 +309,7 @@ module QueriesHelper else format_object(value, html: false) do |value| case value.class.name - when 'Float' + when 'Float', 'Rational' sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator)) when 'IssueRelation' value.to_s(object) diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index cd26f1b13..93b4c271b 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -1740,6 +1740,16 @@ class TimelogControllerTest < Redmine::ControllerTest get :index, :params => {:format => 'csv'} assert_response :success assert_equal 'text/csv; header=present', response.media_type + + parsed_csv = CSV.parse(response.body) + assert_equal %w[Project Date User Activity Issue Comment Hours], parsed_csv.first + assert_equal( + [ + 'eCookbook', '03/12/2007', 'Redmine Admin', 'Design', + 'Bug #1: Cannot print recipes', '', '150.00' + ], + parsed_csv.last + ) end end