Browse Source

lint

pull/1007/head
Kat 4 years ago
parent
commit
c2101b10ed
  1. 10
      app/models/location.rb
  2. 4
      spec/requests/locations_controller_spec.rb

10
app/models/location.rb

@ -447,12 +447,10 @@ class Location < ApplicationRecord
elsif reactivation_date_type == "other" elsif reactivation_date_type == "other"
errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.invalid")) errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.invalid"))
end end
else elsif !reactivation_date.between?(available_from, Time.zone.local(2200, 1, 1))
if !reactivation_date.between?(available_from, Time.zone.local(2200, 1, 1)) errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.out_of_range", date: available_from.to_formatted_s(:govuk_date)))
errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.out_of_range", date: available_from.to_formatted_s(:govuk_date))) elsif reactivation_date < recent_deactivation.deactivation_date
elsif reactivation_date < recent_deactivation.deactivation_date errors.add(:reactivation_date, message: I18n.t("validations.location.reactivation.before_deactivation", date: recent_deactivation.deactivation_date.to_formatted_s(:govuk_date)))
errors.add(:reactivation_date, message: I18n.t("validations.location.reactivation.before_deactivation", date: recent_deactivation.deactivation_date.to_formatted_s(:govuk_date)))
end
end end
end end

4
spec/requests/locations_controller_spec.rb

@ -1241,14 +1241,14 @@ RSpec.describe LocationsController, type: :request do
let!(:location) { FactoryBot.create(:location, scheme:, startdate: nil, created_at: Time.zone.local(2022, 4, 1)) } let!(:location) { FactoryBot.create(:location, scheme:, startdate: nil, created_at: Time.zone.local(2022, 4, 1)) }
let(:deactivation_date) { Time.utc(2022, 10, 10) } let(:deactivation_date) { Time.utc(2022, 10, 10) }
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location:, scheme:, startdate:, owning_organisation: user.organisation) } let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location:, scheme:, startdate:, owning_organisation: user.organisation) }
let(:startdate) { Time.utc(2022, 10, 11) } let(:startdate) { Time.utc(2022, 10, 11) }
let(:add_deactivations) { nil } let(:add_deactivations) { nil }
before do before do
Timecop.freeze(Time.utc(2022, 10, 10)) Timecop.freeze(Time.utc(2022, 10, 10))
sign_in user sign_in user
add_deactivations add_deactivations
location.save location.save!
patch "/schemes/#{scheme.id}/locations/#{location.id}/new-deactivation", params: patch "/schemes/#{scheme.id}/locations/#{location.id}/new-deactivation", params:
end end

Loading…
Cancel
Save