|
|
|
|
@ -1443,7 +1443,6 @@ RSpec.describe LocationsController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "#reactivate" do |
|
|
|
|
context "when not signed in" do |
|
|
|
|
it "redirects to the sign in page" do |
|
|
|
|
@ -1471,7 +1470,6 @@ RSpec.describe LocationsController, type: :request do
|
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
|
let(:deactivation_date) { Time.zone.local(2022, 10, 10) } |
|
|
|
|
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location:, scheme:, startdate:, owning_organisation: user.organisation) } |
|
|
|
|
let(:startdate) { Time.utc(2022, 10, 11) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
@ -1522,6 +1520,60 @@ RSpec.describe LocationsController, type: :request do
|
|
|
|
|
expect(location.location_deactivation_periods.first.reactivation_date).to eq(Time.zone.local(2022, 10, 14)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the date is not selected" do |
|
|
|
|
let(:params) { { location: { "reactivation_date": "" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when invalid date is entered" do |
|
|
|
|
let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "10", "reactivation_date(2i)": "44", "reactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the date is entered is before the beginning of current collection window" do |
|
|
|
|
let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "10", "reactivation_date(2i)": "4", "reactivation_date(1i)": "2020" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the day is not entered" do |
|
|
|
|
let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "", "reactivation_date(2i)": "2", "reactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the month is not entered" do |
|
|
|
|
let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "2", "reactivation_date(2i)": "", "reactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the year is not entered" do |
|
|
|
|
let(:params) { { location: { reactivation_date_type: "other", "reactivation_date(3i)": "2", "reactivation_date(2i)": "2", "reactivation_date(1i)": "" } } } |
|
|
|
|
|
|
|
|
|
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")) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|