Browse Source

Do not exclude schemes deactivating soon in active status scope of locations

pull/2605/head
Manny Dinssa 2 years ago
parent
commit
206967f972
  1. 2
      app/models/location.rb
  2. 12
      spec/requests/schemes_controller_spec.rb

2
app/models/location.rb

@ -113,8 +113,6 @@ class Location < ApplicationRecord
.where.not(id: joins(scheme: [:scheme_deactivation_periods]).merge(Location.deactivated_by_scheme(date)).pluck(:id)) .where.not(id: joins(scheme: [:scheme_deactivation_periods]).merge(Location.deactivated_by_scheme(date)).pluck(:id))
.where.not(id: joins(scheme: [:owning_organisation]).merge(Location.deactivated_by_organisation).pluck(:id)) .where.not(id: joins(scheme: [:owning_organisation]).merge(Location.deactivated_by_organisation).pluck(:id))
.where.not(id: incomplete.pluck(:id)) .where.not(id: incomplete.pluck(:id))
.where.not(id: joins(:location_deactivation_periods).merge(Location.deactivating_soon_directly(date)).pluck(:id))
.where.not(id: joins(scheme: %i[owning_organisation scheme_deactivation_periods]).merge(Location.deactivating_soon_by_scheme(date)).pluck(:id))
.where.not(id: activating_soon(date).pluck(:id)) .where.not(id: activating_soon(date).pluck(:id))
} }

12
spec/requests/schemes_controller_spec.rb

@ -612,9 +612,9 @@ RSpec.describe SchemesController, type: :request do
context "with scheme that's deactivating soon" do context "with scheme that's deactivating soon" do
let(:scheme_deactivation_period) { create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 12), scheme:) } let(:scheme_deactivation_period) { create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 12), scheme:) }
it "does not render toggle scheme link" do it "does render the reactivate this scheme button" do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).not_to have_link("Reactivate this scheme") expect(page).to have_link("Reactivate this scheme")
expect(page).not_to have_link("Deactivate this scheme") expect(page).not_to have_link("Deactivate this scheme")
end end
end end
@ -680,9 +680,9 @@ RSpec.describe SchemesController, type: :request do
context "with scheme that's deactivating soon" do context "with scheme that's deactivating soon" do
let(:scheme_deactivation_period) { create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 12), scheme: specific_scheme) } let(:scheme_deactivation_period) { create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 12), scheme: specific_scheme) }
it "does not render toggle scheme link" do it "does render the reactivate this scheme button" do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).not_to have_link("Reactivate this scheme") expect(page).to have_link("Reactivate this scheme")
expect(page).not_to have_link("Deactivate this scheme") expect(page).not_to have_link("Deactivate this scheme")
end end
end end
@ -748,7 +748,7 @@ RSpec.describe SchemesController, type: :request do
let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period } let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period }
before do before do
create(:location, scheme:, startdate: Time.utc(2022, 9, 9)) create(:location, scheme:)
Timecop.freeze(Time.utc(2022, 10, 10)) Timecop.freeze(Time.utc(2022, 10, 10))
sign_in user sign_in user
add_deactivations add_deactivations
@ -784,7 +784,7 @@ RSpec.describe SchemesController, type: :request do
context "and associated logs in editable collection period" do context "and associated logs in editable collection period" do
before do before do
create(:location, scheme:, startdate: Time.zone.local(2022, 9, 9)) create(:location, scheme:)
create(:lettings_log, :sh, scheme:, startdate: Time.zone.local(2022, 9, 9), owning_organisation: user.organisation) create(:lettings_log, :sh, scheme:, startdate: Time.zone.local(2022, 9, 9), owning_organisation: user.organisation)
get "/schemes/#{scheme.id}" get "/schemes/#{scheme.id}"
end end

Loading…
Cancel
Save