From 295894aa3517ab6444d3e95e5b34fd9f654c9252 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Fri, 22 Jul 2022 16:02:51 +0100 Subject: [PATCH] CLDC-1389: Export LA if derived from scheme location (#777) * Export LA if derived from scheme location * Fix intermittent spec failure --- app/models/case_log.rb | 2 +- spec/factories/location.rb | 2 ++ spec/fixtures/files/case_logs_download.csv | 2 +- spec/models/case_log_spec.rb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 93e3a4cc4..e23d12f03 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -414,7 +414,7 @@ class CaseLog < ApplicationRecord csv << attribute_names + %w[unittype_sh] all.find_each do |record| - csv << record.attributes.merge({ "unittype_sh" => record.unittype_sh }).map do |att, val| + csv << record.attributes.merge({ "unittype_sh" => record.unittype_sh, "la" => record.la }).map do |att, val| record.form.get_question(att, record)&.label_from_value(val) || val end end diff --git a/spec/factories/location.rb b/spec/factories/location.rb index 08a43c1f8..4041fe337 100644 --- a/spec/factories/location.rb +++ b/spec/factories/location.rb @@ -6,6 +6,8 @@ FactoryBot.define do units { [1, 2, 3, 4, 6, 7].sample } type_of_building { "Purpose built" } mobility_type { %w[A M N W X].sample } + location_code { "E09000033" } + location_admin_district { "Westminster" } scheme trait :export do postcode { "SW1A 2AA" } diff --git a/spec/fixtures/files/case_logs_download.csv b/spec/fixtures/files/case_logs_download.csv index 0f7c45365..e55978624 100644 --- a/spec/fixtures/files/case_logs_download.csv +++ b/spec/fixtures/files/case_logs_download.csv @@ -1,2 +1,2 @@ id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,owning_organisation_id,managing_organisation_id,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,created_by_id,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,unittype_sh -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,DLUHC,{owning_org_id},,Supported housing,,,false,0,0,0,,0,,,,,,,,,,,,,,false,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,Danny Rojas,,,,,,9,,,{scheme_id},SE11TE,6 +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,DLUHC,{owning_org_id},,Supported housing,,,false,0,0,0,,0,,,,,,,,,,,,,,false,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,Danny Rojas,,,,,,9,,,{scheme_id},SE11TE,6 diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 81da18de9..097aa89ce 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -2261,7 +2261,7 @@ RSpec.describe CaseLog do describe "csv download" do let(:csv_export_file) { File.open("spec/fixtures/files/case_logs_download.csv", "r:UTF-8") } let(:scheme) { FactoryBot.create(:scheme) } - let(:location) { FactoryBot.create(:location, scheme:, type_of_unit: 6, postcode: "SE11TE") } + let(:location) { FactoryBot.create(:location, :export, scheme:, type_of_unit: 6, postcode: "SE11TE") } let(:user) { FactoryBot.create(:user, organisation: location.scheme.owning_organisation) } before do