diff --git a/app/models/location.rb b/app/models/location.rb index f5114d5e1..e77aca12e 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -403,14 +403,14 @@ class Location < ApplicationRecord if deactivation_date.blank? if deactivation_date_type.blank? - errors.add(:deactivation_date_type, message: I18n.t("validations.location.deactivation_date.not_selected")) + errors.add(:deactivation_date_type, message: I18n.t("validations.location.toggle_date.not_selected")) elsif deactivation_date_type == "other" - errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.invalid")) + errors.add(:deactivation_date, message: I18n.t("validations.location.toggle_date.invalid")) end else collection_start_date = FormHandler.instance.current_collection_start_date unless deactivation_date.between?(collection_start_date, Time.zone.local(2200, 1, 1)) - errors.add(:deactivation_date, message: I18n.t("validations.location.deactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) + errors.add(:deactivation_date, message: I18n.t("validations.location.toggle_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) end end end @@ -424,14 +424,14 @@ class Location < ApplicationRecord if reactivation_date.blank? if reactivation_date_type.blank? - errors.add(:reactivation_date_type, message: I18n.t("validations.location.reactivation_date.not_selected")) + errors.add(:reactivation_date_type, message: I18n.t("validations.location.toggle_date.not_selected")) elsif reactivation_date_type == "other" - errors.add(:reactivation_date, message: I18n.t("validations.location.reactivation_date.invalid")) + errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.invalid")) end else collection_start_date = FormHandler.instance.current_collection_start_date unless reactivation_date.between?(collection_start_date, Time.zone.local(2200, 1, 1)) - errors.add(:reactivation_date, message: I18n.t("validations.location.reactivation_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) + errors.add(:reactivation_date, message: I18n.t("validations.location.toggle_date.out_of_range", date: collection_start_date.to_formatted_s(:govuk_date))) end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 585c1d56b..99d93f930 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -319,7 +319,7 @@ en: out_of_range: "The date must be on or after the %{date}" location: - deactivation_date: + toggle_date: not_selected: "Select one of the options" invalid: "Enter a valid day, month and year" out_of_range: "The date must be on or after the %{date}" diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index f18084e20..d984a8133 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -1323,7 +1323,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.not_selected")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.not_selected")) end end @@ -1332,7 +1332,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1341,7 +1341,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.out_of_range", date: "1 April 2022")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.out_of_range", date: "1 April 2022")) end end @@ -1350,7 +1350,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1359,7 +1359,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1368,7 +1368,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.deactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end end @@ -1526,7 +1526,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.not_selected")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.not_selected")) end end @@ -1535,7 +1535,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1544,7 +1544,7 @@ RSpec.describe LocationsController, type: :request do it "displays the new page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.out_of_range", date: "1 April 2022")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.out_of_range", date: "1 April 2022")) end end @@ -1553,7 +1553,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1562,7 +1562,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end @@ -1571,7 +1571,7 @@ RSpec.describe LocationsController, type: :request do it "displays page with an error message" do expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("validations.location.reactivation_date.invalid")) + expect(page).to have_content(I18n.t("validations.location.toggle_date.invalid")) end end end