|
|
@ -1245,29 +1245,37 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
before do |
|
|
|
before do |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
patch "/schemes/#{scheme.id}/locations/#{location.id}/deactivate", params: |
|
|
|
patch "/schemes/#{scheme.id}/locations/#{location.id}/new-deactivation", params: |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with default date" do |
|
|
|
context "with default date" do |
|
|
|
let(:params) { { location: { deactivation_date_type: "default" } } } |
|
|
|
let(:params) { { location: { deactivation_date_type: "default", deactivation_date_type: "default", deactivation_date: } } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders the confirmation page" do |
|
|
|
it "redirects to the confirmation page" do |
|
|
|
|
|
|
|
follow_redirect! |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(page).to have_content("This change will affect #{location.lettings_logs.count} logs") |
|
|
|
expect(page).to have_content("This change will affect #{location.lettings_logs.count} logs") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with 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_type: "other", "deactivation_date(3i)": "10", "deactivation_date(2i)": "10", "deactivation_date(1i)": "2022" } } } |
|
|
|
|
|
|
|
|
|
|
|
it "renders the confirmation page" do |
|
|
|
it "redirects to the confirmation page" do |
|
|
|
|
|
|
|
follow_redirect! |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(page).to have_content("This change will affect #{location.lettings_logs.count} logs") |
|
|
|
expect(page).to have_content("This change will affect #{location.lettings_logs.count} logs") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when confirming deactivation" do |
|
|
|
context "when confirming deactivation" do |
|
|
|
let(:params) { { location: { deactivation_date:, confirm: true } } } |
|
|
|
let(:params) { { location: { deactivation_date:, confirm: true, deactivation_date_type: "other" } } } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
|
|
|
|
sign_in user |
|
|
|
|
|
|
|
patch "/schemes/#{scheme.id}/locations/#{location.id}/deactivate", params: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
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! |
|
|
@ -1365,21 +1373,24 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
location.deactivation_date = deactivation_date |
|
|
|
location.deactivation_date = deactivation_date |
|
|
|
|
|
|
|
location.deactivation_date_type = deactivation_date_type |
|
|
|
location.save! |
|
|
|
location.save! |
|
|
|
get "/schemes/#{scheme.id}/locations/#{location.id}" |
|
|
|
get "/schemes/#{scheme.id}/locations/#{location.id}" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with active location" do |
|
|
|
context "with active location" do |
|
|
|
let(:deactivation_date) { nil } |
|
|
|
let(:deactivation_date) { nil } |
|
|
|
|
|
|
|
let(:deactivation_date_type) { nil } |
|
|
|
|
|
|
|
|
|
|
|
it "renders deactivate this location" do |
|
|
|
it "renders deactivate this location" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(page).to have_link("Deactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/deactivate") |
|
|
|
expect(page).to have_link("Deactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-deactivation") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with deactivated location" do |
|
|
|
context "with deactivated location" do |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 9) } |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 9) } |
|
|
|
|
|
|
|
let(:deactivation_date_type) { "other" } |
|
|
|
|
|
|
|
|
|
|
|
it "renders reactivate this location" do |
|
|
|
it "renders reactivate this location" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
@ -1389,6 +1400,7 @@ RSpec.describe LocationsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
context "with location that's deactivating soon" do |
|
|
|
context "with location that's deactivating soon" do |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 12) } |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 12) } |
|
|
|
|
|
|
|
let(:deactivation_date_type) { "other" } |
|
|
|
|
|
|
|
|
|
|
|
it "renders reactivate this location" do |
|
|
|
it "renders reactivate this location" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|