Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kagemaru committed Sep 17, 2024
1 parent ec61ab2 commit 8d881f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions app/controllers/concerns/worktimes_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,10 +37,9 @@ def worktimes_csv(worktimes)
end
end

def currency(value)
format(
'%<amount>0.02f',
amount: value,
)
def amount(time)
return '-' unless time.respond_to?(:amount)

format('%<amount>0.02f', amount: time.amount)
end
end
8 changes: 4 additions & 4 deletions test/controllers/evaluator_controller_test.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8d881f0

Please sign in to comment.