Browse Source

lint

pull/996/head
Kat 4 years ago
parent
commit
ea62284f78
  1. 2
      app/controllers/locations_controller.rb
  2. 2
      app/models/location.rb
  3. 2
      app/models/location_deactivation.rb
  4. 2
      spec/models/location_spec.rb
  5. 2
      spec/requests/locations_controller_spec.rb

2
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

2
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

2
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

2
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!

2
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)

Loading…
Cancel
Save