From 8a9a29cba1d9b5635c09f164c77bf8ed30508858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Tue, 20 Feb 2024 09:24:58 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=E6=96=B0=E8=A6=8F=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=99=82=E9=96=93=E5=B8=AF=E3=82=92=E7=A9=BA?= =?UTF-8?q?=E6=AC=84=E3=81=AB=E3=81=99=E3=82=8B=E3=81=A8=E3=80=81=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=20(#603)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: 新規登録可能時間帯を空欄にすると、画面が表示できなくなる問題 * リファクタリング * Fix test --- app/helpers/registration_limitation_helper.rb | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/helpers/registration_limitation_helper.rb b/app/helpers/registration_limitation_helper.rb index 65e295720c..4ac04450aa 100644 --- a/app/helpers/registration_limitation_helper.rb +++ b/app/helpers/registration_limitation_helper.rb @@ -32,20 +32,22 @@ module RegistrationLimitationHelper end def registrations_in_time? - start_hour = Setting.registrations_start_hour || 0 - end_hour = Setting.registrations_end_hour || 24 - secondary_start_hour = Setting.registrations_secondary_start_hour || 0 - secondary_end_hour = Setting.registrations_secondary_end_hour || 0 + start_hour = Setting.registrations_start_hour + end_hour = Setting.registrations_end_hour + secondary_start_hour = Setting.registrations_secondary_start_hour + secondary_end_hour = Setting.registrations_secondary_end_hour + + start_hour = 0 unless start_hour.is_a?(Integer) + end_hour = 0 unless end_hour.is_a?(Integer) + secondary_start_hour = 0 unless secondary_start_hour.is_a?(Integer) + secondary_end_hour = 0 unless secondary_end_hour.is_a?(Integer) return true if start_hour >= end_hour && secondary_start_hour >= secondary_end_hour current_hour = Time.now.utc.hour - primary_permitted = false - primary_permitted = start_hour <= current_hour && current_hour < end_hour if start_hour < end_hour && end_hour.positive? - secondary_permitted = false - secondary_permitted = secondary_start_hour <= current_hour && current_hour < secondary_end_hour if secondary_start_hour < secondary_end_hour && secondary_end_hour.positive? - primary_permitted || secondary_permitted + (start_hour < end_hour && end_hour.positive? && current_hour.between?(start_hour, end_hour - 1)) || + (secondary_start_hour < secondary_end_hour && secondary_end_hour.positive? && current_hour.between?(secondary_start_hour, secondary_end_hour - 1)) end def reset_registration_limit_caches!