diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 0ff78bfe3..2983a1305 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -203,7 +203,12 @@ private end def reactivate_success_notice - "#{@location.name} has been reactivated" + case @location.status + when :active + "#{@location.name} has been reactivated" + when :reactivating_soon + "#{@location.name} will reactivate on #{reactivation_date.to_time.to_formatted_s(:govuk_date)}" + end end def update_affected_logs diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index 662c1b301..4b3093e10 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -1513,7 +1513,7 @@ RSpec.describe LocationsController, type: :request do end context "with other date" do - let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "14", "reactivation_date(2i)": "10", "reactivation_date(1i)": "2022" } } } + let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "10", "reactivation_date(2i)": "10", "reactivation_date(1i)": "2022" } } } it "redirects to the location page and displays a success banner" do expect(response).to redirect_to("/schemes/#{scheme.id}/locations/#{location.id}") @@ -1526,7 +1526,18 @@ RSpec.describe LocationsController, type: :request do follow_redirect! location.reload expect(location.location_deactivation_periods.count).to eq(1) - expect(location.location_deactivation_periods.first.reactivation_date).to eq(Time.zone.local(2022, 10, 14)) + expect(location.location_deactivation_periods.first.reactivation_date).to eq(Time.zone.local(2022, 10, 10)) + end + end + + context "with other future date" do + let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "14", "reactivation_date(2i)": "12", "reactivation_date(1i)": "2022" } } } + + it "redirects to the location page and displays a success banner" do + expect(response).to redirect_to("/schemes/#{scheme.id}/locations/#{location.id}") + follow_redirect! + expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") + expect(page).to have_content("#{location.name} will reactivate on 14 December 2022") end end