From ea62284f7805946b88ec44535c02325d2e2077cc Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 15 Nov 2022 15:58:52 +0000 Subject: [PATCH] lint --- app/controllers/locations_controller.rb | 2 +- app/models/location.rb | 2 +- app/models/location_deactivation.rb | 2 +- spec/models/location_spec.rb | 2 +- spec/requests/locations_controller_spec.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index bf36ed974..15ba38d25 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -185,7 +185,7 @@ private when :deactivated "#{@location.name} has been deactivated" when :deactivating_soon - "#{@location.name} will deactivate on #{@location.deactivation_date.to_formatted_s(:govuk_date)}" + "#{@location.name} will deactivate on #{params[:location][:deactivation_date].to_formatted_s(:govuk_date)}" end end diff --git a/app/models/location.rb b/app/models/location.rb index ea4764bd7..656145fd9 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -376,7 +376,7 @@ class Location < ApplicationRecord def status recent_deactivation = location_deactivations.deactivations_without_reactivation.first - return :active unless recent_deactivation.present? + return :active if recent_deactivation.blank? return :deactivating_soon if Time.zone.now < recent_deactivation.deactivation_date :deactivated diff --git a/app/models/location_deactivation.rb b/app/models/location_deactivation.rb index 590921400..9b9780b0a 100644 --- a/app/models/location_deactivation.rb +++ b/app/models/location_deactivation.rb @@ -1,3 +1,3 @@ class LocationDeactivation < ApplicationRecord - scope :deactivations_without_reactivation, ->() { where(reactivation_date: nil) } + scope :deactivations_without_reactivation, -> { where(reactivation_date: nil) } end diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index 57849b1d7..4828fcae7 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -157,7 +157,7 @@ RSpec.describe Location, type: :model do location.save! expect(location.status).to eq(:deactivating_soon) end - + it "returns deactivated if deactivation_date is in the past" do location.location_deactivations << LocationDeactivation.create(deactivation_date: Time.zone.local(2022, 6, 6), reactivation_date: nil) location.save! diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index ea054ab6d..16bd4f8b2 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -1399,7 +1399,7 @@ RSpec.describe LocationsController, type: :request do end context "with active location" do - let(:add_deactivations) { } + let(:add_deactivations) {} it "renders deactivate this location" do expect(response).to have_http_status(:ok)