From 8d881f013c97efaf4aff683309c5da6fb9962132 Mon Sep 17 00:00:00 2001 From: Thomas Burkhalter Date: Tue, 17 Sep 2024 11:29:04 +0200 Subject: [PATCH] Fix tests --- app/controllers/concerns/worktimes_csv.rb | 11 +++++------ test/controllers/evaluator_controller_test.rb | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/concerns/worktimes_csv.rb b/app/controllers/concerns/worktimes_csv.rb index 11e58c96..2fc2cd10 100644 --- a/app/controllers/concerns/worktimes_csv.rb +++ b/app/controllers/concerns/worktimes_csv.rb @@ -26,7 +26,7 @@ def worktimes_csv(worktimes) time.hours, (time.start_stop? ? I18n.l(time.from_start_time, format: :time) : ''), (time.start_stop? && time.to_end_time? ? I18n.l(time.to_end_time, format: :time) : ''), - currency(time.amount), + amount(time), time.report_type, time.billable, time.employee.label, @@ -37,10 +37,9 @@ def worktimes_csv(worktimes) end end - def currency(value) - format( - '%0.02f', - amount: value, - ) + def amount(time) + return '-' unless time.respond_to?(:amount) + + format('%0.02f', amount: time.amount) end end diff --git a/test/controllers/evaluator_controller_test.rb b/test/controllers/evaluator_controller_test.rb index 33ae6878..0a385022 100644 --- a/test/controllers/evaluator_controller_test.rb +++ b/test/controllers/evaluator_controller_test.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# Copyright (c) 2006-2017, Puzzle ITC GmbH. This file is part of +# Copyright (c) 2006-2024, Puzzle ITC GmbH. This file is part of # PuzzleTime and licensed under the Affero General Public License version 3 # or later. See the COPYING file at the top-level directory or at # https://github.com/puzzle/puzzletime. @@ -31,7 +31,7 @@ class EvaluatorControllerTest < ActionController::TestCase assert_match expected_csv_header, csv_header assert_equal 3, csv_data_lines.size - assert_match '06.12.2006,5.0,"","",absolute_day,true,Waber Mark,PITC-AL: Allgemein,,', csv_data_lines.first + assert_match '06.12.2006,5.0,"","",0.00,absolute_day,true,Waber Mark,PITC-AL: Allgemein,,', csv_data_lines.first end test 'GET index employees' do @@ -70,7 +70,7 @@ class EvaluatorControllerTest < ActionController::TestCase assert_csv_http_headers('puzzletime.csv') assert_match expected_csv_header, csv_header assert_equal 9, csv_data_lines.size - assert_match '29.11.2006,1.0,"","",absolute_day,true,Zumkehr Pascal,PITC-AL: Allgemein,,', csv_data_lines.first + assert_match '29.11.2006,1.0,"","",0.00,absolute_day,true,Zumkehr Pascal,PITC-AL: Allgemein,,', csv_data_lines.first end end @@ -133,7 +133,7 @@ class EvaluatorControllerTest < ActionController::TestCase private def expected_csv_header - 'Datum,Stunden,Von Zeit,Bis Zeit,Reporttyp,Verrechenbar,Member,Position,Ticket,Bemerkungen' + 'Datum,Stunden,Von Zeit,Bis Zeit,Stundenansatz CHF,Reporttyp,Verrechenbar,Member,Position,Ticket,Bemerkungen' end def csv_header