From 45ee7c8c06ea19fab3f7d14b37d20efa474e6a09 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Tue, 6 Nov 2018 16:44:40 +0000 Subject: [PATCH] Fix CodeClimate Cognitive Complexity issue --- .../can_change_registration_status.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/waste_carriers_engine/can_change_registration_status.rb b/app/models/concerns/waste_carriers_engine/can_change_registration_status.rb index 77b9f3465..ed1ff710a 100644 --- a/app/models/concerns/waste_carriers_engine/can_change_registration_status.rb +++ b/app/models/concerns/waste_carriers_engine/can_change_registration_status.rb @@ -77,13 +77,17 @@ def log_status_change def renewal_allowed? return false unless %w[ACTIVE EXPIRED].include?(status) return true if renewal_application_submitted? + return true if renew_expired_registration? + + close_to_expiry_date? && should_not_be_expired? + end + + def renew_expired_registration? return true if in_expiry_grace_window? # The only time an expired registration can be renewed is if the application has previously been submitted, # or it is withion the grace window - otherwise expiry is an automatic no return false if EXPIRED? - - close_to_expiry_date? && should_not_be_expired? end def renewal_application_submitted?