CLDC 3899 fix deactivation period edge case bugs (#2995)
* rename variable for clarity
* remove unused variable
* make reactivating_soon message refer to the soonest, not most recently created
* status check all deactivation periods instead of just one
* handle no open period to reactivate
* test deactivation period related behaviour
* fix reactivation message variable syntax
* use before do instead of let for unreferenced variables
* fix reactivation message syntax for location
* fix test indentation
* remove unused variable - part 2
* lint
* handle edge case of overlapping periods
* end unclosed Timecop freeze causing flaky tests
* remove unused around blocks superseded by befores
* tidying up
* reinstate setup needed to test default date
* fix typo
* explain deactivation period validation logic
* fix setup to test default date
---------
Co-authored-by: Carolyn <carolyn.barker@softwire.com>
Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
# The LocationsController validates deactivation periods in three places:
# 1. new_deactivation builds a temporary location_deactivation_period object using the open deactivation if it starts in over six months, or otherwise builds a new period, and validates this (want validate_deactivation)
# 2. `deactivate` takes the open deactivation if present (any start date) and update!s it with the deactivation date, or else create!s a new deactivation with the deactivation date (want validate_deactivation)
# 3. `reactivate` takes the open deactivation (any start date) and update!s it with the reactivation date (want validate_reactivation)
# In toggle_location_link in the LocationsHelper, we display a link to one or neither of new_deactivation and new_reactivation depending on status now, status in six months, and scheme status.
# The SchemesController validates deactivation periods in three places:
# 1. new_deactivation builds a temporary scheme_deactivation_period object using the open deactivation if it starts in over six months, or otherwise builds a new period, and validates this (want validate_deactivation)
# 2. `deactivate` takes the open deactivation if present (any start date) and update!s it with the deactivation date, or else create!s a new deactivation with the deactivation date (want validate_deactivation)
# 3. `reactivate` takes the open deactivation (any start date) and update!s it with the reactivation date (want validate_reactivation)
# In toggle_scheme_link in SchemesHelper, we display a link to one or neither of new_deactivation and new_reactivation depending on status now and status in six months.