|
|
|
|
@ -1932,6 +1932,11 @@ RSpec.describe LocationsController, type: :request do
|
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).not_to have_link("Delete this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/delete-confirmation") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not render informative text about deleting the location" do |
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).not_to have_content("This location was active in an open or editable collection year, and cannot be deleted.") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with deactivated location" do |
|
|
|
|
@ -1941,6 +1946,23 @@ RSpec.describe LocationsController, type: :request do
|
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).to have_link("Delete this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/delete-confirmation") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "and associated logs in editable collection period" do |
|
|
|
|
before do |
|
|
|
|
create(:lettings_log, :sh, location:, scheme:, startdate: Time.zone.local(2022, 9, 9), owning_organisation: user.organisation) |
|
|
|
|
get "/schemes/#{scheme.id}/locations/#{location.id}" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not render delete this location" do |
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).not_to have_link("Delete this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/delete-confirmation") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "adds informative text about deleting the location" do |
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).to have_content("This location was active in an open or editable collection year, and cannot be deleted.") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with incomplete location" do |
|
|
|
|
|