|
|
|
@ -1240,7 +1240,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
let(:startdate) { Time.utc(2021, 1, 2) } |
|
|
|
let(:startdate) { Time.utc(2021, 1, 2) } |
|
|
|
let(:deactivation_date) { Time.new(2022, 10, 10) } |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 10) } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
@ -1248,8 +1248,8 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
patch "/schemes/#{scheme.id}/locations/#{location.id}/deactivate", params: |
|
|
|
patch "/schemes/#{scheme.id}/locations/#{location.id}/deactivate", params: |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "default date" do |
|
|
|
context "with default date" do |
|
|
|
let(:params) { {location:{ deactivation_date: deactivation_date } } } |
|
|
|
let(:params) { { location: { deactivation_date: } } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders the confirmation page" do |
|
|
|
it "renders the confirmation page" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
@ -1257,8 +1257,8 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "other date" do |
|
|
|
context "with other date" do |
|
|
|
let(:params) { {location:{ deactivation_date: "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "10", "deactivation_date(1i)": "2022"} }} |
|
|
|
let(:params) { { location: { deactivation_date: "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "10", "deactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders the confirmation page" do |
|
|
|
it "renders the confirmation page" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
@ -1267,7 +1267,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when confirming deactivation" do |
|
|
|
context "when confirming deactivation" do |
|
|
|
let(:params) { {location:{ deactivation_date: Time.new(2022, 10, 10), confirm: true } } } |
|
|
|
let(:params) { { location: { deactivation_date: Time.utc(2022, 10, 10), confirm: true } } } |
|
|
|
|
|
|
|
|
|
|
|
it "updates existing location with valid deactivation date and renders location page" do |
|
|
|
it "updates existing location with valid deactivation date and renders location page" do |
|
|
|
follow_redirect! |
|
|
|
follow_redirect! |
|
|
|
@ -1279,7 +1279,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the date is not selected" do |
|
|
|
context "when the date is not selected" do |
|
|
|
let(:params) { { location: { "deactivation_date": "" } }} |
|
|
|
let(:params) { { location: { "deactivation_date": "" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays the new page with an error message" do |
|
|
|
it "displays the new page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
@ -1288,7 +1288,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when invalid date is entered" do |
|
|
|
context "when invalid date is entered" do |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "44", "deactivation_date(1i)": "2022"} }} |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "44", "deactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays the new page with an error message" do |
|
|
|
it "displays the new page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
@ -1297,7 +1297,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the date is entered is before the beginning of current collection window" do |
|
|
|
context "when the date is entered is before the beginning of current collection window" do |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "4", "deactivation_date(1i)": "2020"} }} |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "4", "deactivation_date(1i)": "2020" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays the new page with an error message" do |
|
|
|
it "displays the new page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
@ -1306,7 +1306,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the day is not entered" do |
|
|
|
context "when the day is not entered" do |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "", "deactivation_date(2i)": "2", "deactivation_date(1i)": "2022"} }} |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "", "deactivation_date(2i)": "2", "deactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays page with an error message" do |
|
|
|
it "displays page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
@ -1315,7 +1315,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the month is not entered" do |
|
|
|
context "when the month is not entered" do |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "2", "deactivation_date(2i)": "", "deactivation_date(1i)": "2022"} }} |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "2", "deactivation_date(2i)": "", "deactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays page with an error message" do |
|
|
|
it "displays page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
@ -1324,7 +1324,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the year is not entered" do |
|
|
|
context "when the year is not entered" do |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "2", "deactivation_date(2i)": "2", "deactivation_date(1i)": ""} }} |
|
|
|
let(:params) { { location: { "deactivation_date": "other", "deactivation_date(3i)": "2", "deactivation_date(2i)": "2", "deactivation_date(1i)": "" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "displays page with an error message" do |
|
|
|
it "displays page with an error message" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
|