Browse Source

Mark log as impacted by deactivation when location is deactivated

pull/1035/head
Kat 4 years ago
parent
commit
898e36c184
  1. 2
      app/controllers/locations_controller.rb
  2. 7
      db/migrate/20221125102013_add_impacted_by_deactivation_column.rb
  3. 1
      db/schema.rb
  4. 12
      spec/requests/locations_controller_spec.rb

2
app/controllers/locations_controller.rb

@ -219,7 +219,7 @@ private
end end
def reset_location_and_scheme_for_logs! def reset_location_and_scheme_for_logs!
@location.lettings_logs.filter_by_before_startdate(params[:deactivation_date].to_time).update!(location: nil, scheme: nil) @location.lettings_logs.filter_by_before_startdate(params[:deactivation_date].to_time).update!(location: nil, scheme: nil, impacted_by_deactivation: true)
end end
def toggle_date(key) def toggle_date(key)

7
db/migrate/20221125102013_add_impacted_by_deactivation_column.rb

@ -0,0 +1,7 @@
class AddImpactedByDeactivationColumn < ActiveRecord::Migration[7.0]
def change
change_table :lettings_logs, bulk: true do |t|
t.column :impacted_by_deactivation, :boolean
end
end
end

1
db/schema.rb

@ -237,6 +237,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_11_25_142847) do
t.integer "void_date_value_check" t.integer "void_date_value_check"
t.integer "housingneeds_type" t.integer "housingneeds_type"
t.integer "housingneeds_other" t.integer "housingneeds_other"
t.boolean "impacted_by_deactivation"
t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id" t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id"
t.index ["location_id"], name: "index_lettings_logs_on_location_id" t.index ["location_id"], name: "index_lettings_logs_on_location_id"
t.index ["managing_organisation_id"], name: "index_lettings_logs_on_managing_organisation_id" t.index ["managing_organisation_id"], name: "index_lettings_logs_on_managing_organisation_id"

12
spec/requests/locations_controller_spec.rb

@ -1364,6 +1364,12 @@ RSpec.describe LocationsController, type: :request do
expect(lettings_log.location).to eq(nil) expect(lettings_log.location).to eq(nil)
expect(lettings_log.scheme).to eq(nil) expect(lettings_log.scheme).to eq(nil)
end end
it "marks log as needing attention" do
expect(lettings_log.impacted_by_deactivation).to eq(nil)
lettings_log.reload
expect(lettings_log.impacted_by_deactivation).to eq(true)
end
end end
context "and a log startdate is before location deactivation date" do context "and a log startdate is before location deactivation date" do
@ -1376,6 +1382,12 @@ RSpec.describe LocationsController, type: :request do
expect(lettings_log.location).to eq(location) expect(lettings_log.location).to eq(location)
expect(lettings_log.scheme).to eq(scheme) expect(lettings_log.scheme).to eq(scheme)
end end
it "does not mark log as needing attention" do
expect(lettings_log.impacted_by_deactivation).to eq(nil)
lettings_log.reload
expect(lettings_log.impacted_by_deactivation).to eq(nil)
end
end end
end end

Loading…
Cancel
Save