diff options
author | Go MAEDA <maeda@farend.jp> | 2024-12-04 01:58:51 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-12-04 01:58:51 +0000 |
commit | 81291bb25eada75c0c54119288f9006a6ea3a5b9 (patch) | |
tree | ef483422ebc5e8c8044a7f49849e62477dc88c98 | |
parent | 2f5d5432342aa80b4bde06f965740df33dfc904d (diff) | |
download | redmine-81291bb25eada75c0c54119288f9006a6ea3a5b9.tar.gz redmine-81291bb25eada75c0c54119288f9006a6ea3a5b9.zip |
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
-rw-r--r-- | app/helpers/queries_helper.rb | 2 | ||||
-rw-r--r-- | test/functional/timelog_controller_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
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 |