Browse Source

Derive landlord from owning org provider type

pull/447/head
baarkerlounger 4 years ago
parent
commit
8dce3cef5c
  1. 2
      app/models/case_log.rb
  2. 2
      spec/fixtures/complete_case_log.json
  3. 18
      spec/models/case_log_spec.rb

2
app/models/case_log.rb

@ -416,6 +416,8 @@ private
self["ecstat#{idx}"] = nil
end
end
self.landlord = 1 if owning_organisation.provider_type == "LA"
self.landlord = 2 if owning_organisation.provider_type == "PRP"
end
def process_postcode_changes!

2
spec/fixtures/complete_case_log.json vendored

@ -53,7 +53,7 @@
"startertenancy": 0,
"tenancylength": 5,
"tenancy": 3,
"landlord": "This landlord",
"landlord": 1,
"la": "Barnet",
"postcode_full": "NW1 5TY",
"property_relet": 0,

18
spec/models/case_log_spec.rb

@ -258,6 +258,24 @@ RSpec.describe CaseLog do
expect(record_from_db["renttype"]).to eq(3)
end
context "when the owning organisation is a PRP" do
it "correctly derives and saves landlord based on owning_organisation provider_type" do
record_from_db = ActiveRecord::Base.connection.execute("select landlord from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.landlord).to eq(2)
expect(record_from_db["landlord"]).to eq(2)
end
end
context "when the owning organisation is an LA" do
let(:organisation) { FactoryBot.create(:organisation) }
it "correctly derives and saves landlord based on owning_organisation provider_type" do
record_from_db = ActiveRecord::Base.connection.execute("select landlord from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.landlord).to eq(1)
expect(record_from_db["landlord"]).to eq(1)
end
end
context "when deriving lettype" do
context "when the owning organisation is a PRP" do
context "when the rent type is intermediate rent and supported housing" do

Loading…
Cancel
Save