Browse Source

ensure the correct number of beds is calculated if the log is for a bedsit and the beds attribute has been temporarily cleared

pull/2465/head
Arthur Campbell 2 years ago
parent
commit
daed805f4f
  1. 4
      app/models/lettings_log.rb
  2. 8
      spec/models/lettings_log_spec.rb

4
app/models/lettings_log.rb

@ -533,7 +533,9 @@ class LettingsLog < Log
def beds_for_la_rent_range
return 0 if is_supported_housing?
beds.nil? ? nil : [beds, LaRentRange::MAX_BEDS].min
real_beds = beds || (1 if is_bedsit?)
real_beds.nil? ? nil : [real_beds, LaRentRange::MAX_BEDS].min
end
def soft_min_for_period

8
spec/models/lettings_log_spec.rb

@ -1834,6 +1834,14 @@ RSpec.describe LettingsLog do
expect(lettings_log.beds_for_la_rent_range).to eq(4)
end
end
context "when the log is for a bedsit, beds is not routed to and is not yet re-derived" do
let(:lettings_log) { build(:lettings_log, unittype_gn: 2, beds: nil) }
it "returns 1" do
expect(lettings_log.beds_for_la_rent_range).to eq(1)
end
end
end
describe "#collection_period_open?" do

Loading…
Cancel
Save