From d511150cdbe91ce35c368038f1dc42dd53775ec5 Mon Sep 17 00:00:00 2001 From: Daniel Bengl Date: Tue, 14 Jan 2025 16:52:09 +0100 Subject: [PATCH] Review --- app/helpers/timer_sessions_helper.rb | 13 +++++++++---- test/unit/timer_sessions_helper_test.rb | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/helpers/timer_sessions_helper.rb b/app/helpers/timer_sessions_helper.rb index 740e71f..551c066 100644 --- a/app/helpers/timer_sessions_helper.rb +++ b/app/helpers/timer_sessions_helper.rb @@ -56,16 +56,21 @@ def sum_work_hours(timer_sessions) def issue_information(issue) subject = issue.subject - issue_information = issue.id.to_s - - truncated_subject = subject[0..(MAX_SUBJECT_LENGTH - issue.project.name.length - issue_information.length)] [ - issue_information, + issue_information(issue), "[#{issue.project.name}] #{truncated_subject}#{subject_label_trail(subject)}" ].join(': ') end + def issue_information(issue) + "[#{issue.project.name}] #{issue.id.to_s}" + end + + def truncated_subject(subject) + subject[0..(MAX_SUBJECT_LENGTH - subject.length)] + end + def subject_label_trail(subject) '...' if subject.length > MAX_SUBJECT_LENGTH end diff --git a/test/unit/timer_sessions_helper_test.rb b/test/unit/timer_sessions_helper_test.rb index 983ab77..4485dc3 100644 --- a/test/unit/timer_sessions_helper_test.rb +++ b/test/unit/timer_sessions_helper_test.rb @@ -44,6 +44,6 @@ class TimerSessionsHelperTest < ActionView::TestCase end test '#issue_link_list' do - assert_equal ['1: [eCookbook] Cannot print recipes'], issue_link_list([Issue.first]) + assert_equal ['[eCookbook] 1: Cannot print recipes'], issue_link_list([Issue.first]) end end