diff --git a/app/views/reports/_learning_times.html.slim b/app/views/reports/_learning_times.html.slim index 894fba8e7db..306771f4699 100644 --- a/app/views/reports/_learning_times.html.slim +++ b/app/views/reports/_learning_times.html.slim @@ -10,4 +10,4 @@ ul.learning-times__items - @report.learning_times.each do |learning_time| li.learning-times__item - | #{l learning_time.started_at, format: :time_only} 〜 #{'(翌日)' if learning_time.started_at.day < learning_time.finished_at.day}#{l learning_time.finished_at, format: :time_only} + | #{l learning_time.started_at, format: :time_only} 〜 #{'(翌日)' if learning_time.started_at.to_date < learning_time.finished_at.to_date}#{l learning_time.finished_at, format: :time_only} diff --git a/test/system/reports_test.rb b/test/system/reports_test.rb index 4091521e40e..1d4659b1661 100644 --- a/test/system/reports_test.rb +++ b/test/system/reports_test.rb @@ -277,6 +277,23 @@ class ReportsTest < ApplicationSystemTestCase assert_text '00:30 〜 02:30' end + test 'learning times when carrying over next month' do + visit_with_auth '/reports/new', 'komagata' + fill_in 'report_title', with: 'テスト日報' + fill_in 'report_description', with: '学習時間が月を跨いでいるパターン' + fill_in 'report_reported_on', with: Date.new(2024, 1, 31) + + all('.learning-time')[0].all('.learning-time__started-at select')[0].select('22') + all('.learning-time')[0].all('.learning-time__started-at select')[1].select('00') + all('.learning-time')[0].all('.learning-time__finished-at select')[0].select('00') + all('.learning-time')[0].all('.learning-time__finished-at select')[1].select('00') + + click_button '提出' + + assert_text "2時間\n" + assert_text '22:00 〜 (翌日)00:00' + end + test 'learning times order' do visit_with_auth '/reports/new', 'komagata' fill_in 'report_title', with: 'テスト日報'