diff --git a/db/schema.rb b/db/schema.rb
index 8bce8e09e..ceeab8122 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -270,6 +270,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do
t.integer "irproduct"
t.string "old_id"
t.integer "joint"
+ t.bigint "assigned_to_id"
t.integer "retirement_value_check"
t.integer "tshortfall_known"
t.integer "sheltered"
@@ -319,7 +320,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do
t.string "la_as_entered"
t.integer "partner_under_16_value_check"
t.integer "multiple_partners_value_check"
- t.bigint "assigned_to_id"
t.bigint "created_by_id"
t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id"
@@ -497,6 +497,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "owning_organisation_id"
+ t.bigint "assigned_to_id"
t.string "purchid"
t.integer "type"
t.integer "ownershipsch"
@@ -687,7 +688,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do
t.string "la_as_entered"
t.integer "partner_under_16_value_check"
t.integer "multiple_partners_value_check"
- t.bigint "assigned_to_id"
t.bigint "created_by_id"
t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
@@ -767,8 +767,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.boolean "initial_confirmation_sent"
- t.datetime "discarded_at"
t.boolean "reactivate_with_organisation"
+ t.datetime "discarded_at"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["encrypted_otp_secret_key"], name: "index_users_on_encrypted_otp_secret_key", unique: true
diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb
index ebf94230e..eb7f8e5eb 100644
--- a/spec/factories/lettings_log.rb
+++ b/spec/factories/lettings_log.rb
@@ -87,7 +87,7 @@ FactoryBot.define do
rsnvac { 6 }
unittype_gn { 7 }
beds { 3 }
- voiddate { 2.days.ago }
+ voiddate { startdate - 2.days }
offered { 2 }
wchair { 1 }
earnings { 268 }
@@ -102,7 +102,7 @@ FactoryBot.define do
layear { 2 }
waityear { 7 }
postcode_known { 1 }
- postcode_full { Faker::Address.postcode }
+ postcode_full { "SW1A 1AA" }
reasonpref { 1 }
cbl { 0 }
chr { 1 }
@@ -154,7 +154,7 @@ FactoryBot.define do
hbrentshortfall { 1 }
tshortfall { 12 }
property_relet { 0 }
- mrcdate { 1.day.ago }
+ mrcdate { startdate - 1.day }
incref { 0 }
armedforces { 1 }
builtype { 1 }
@@ -166,11 +166,19 @@ FactoryBot.define do
referral { 2 }
uprn_known { 0 }
joint { 3 }
- address_line1 { "fake address" }
+ address_line1 { "Address line 1" }
town_or_city { "London" }
ppcodenk { 1 }
tshortfall_known { 1 }
end
+ trait :completed2024 do
+ completed
+ address_line1_input { address_line1 }
+ postcode_full_input { postcode_full }
+ nationality_all_group { 826 }
+ uprn { 1 }
+ uprn_selection { 1 }
+ end
trait :export do
tenancycode { "987654" }
ppostcode_full { "LE5 1QP" }
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index f0cea588f..94347c6f1 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -154,6 +154,15 @@ FactoryBot.define do
buy2living { 3 }
proplen_asked { 1 }
end
+ trait :completed2024 do
+ completed
+ address_line1_input { address_line1 }
+ postcode_full_input { postcode_full }
+ nationality_all_group { 826 }
+ nationality_all_buyer2_group { 826 }
+ uprn { 1 }
+ uprn_selection { 1 }
+ end
trait :with_uprn do
uprn { rand(999_999_999_999).to_s }
uprn_known { 1 }
diff --git a/spec/factories/user.rb b/spec/factories/user.rb
index 935bd30f6..22b93d2d6 100644
--- a/spec/factories/user.rb
+++ b/spec/factories/user.rb
@@ -1,11 +1,14 @@
FactoryBot.define do
factory :user do
- sequence(:email) { |i| "test#{i}@example.com" }
+ sequence(:email) { "test#{SecureRandom.hex}@example.com" }
name { "Danny Rojas" }
password { "pAssword1" }
organisation
role { "data_provider" }
phone { "1234512345123" }
+ trait :data_provider do
+ role { "data_provider" }
+ end
trait :data_coordinator do
role { "data_coordinator" }
end
diff --git a/spec/features/form/tasklist_page_spec.rb b/spec/features/form/tasklist_page_spec.rb
index a532478c1..6c87d074e 100644
--- a/spec/features/form/tasklist_page_spec.rb
+++ b/spec/features/form/tasklist_page_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "Task List" do
expect(page).to have_content("This log has not been started.")
end
- context "when testing completed subsection count" do
+ describe "completed subsection count" do
let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json") }
before do
diff --git a/spec/features/home_page_spec.rb b/spec/features/home_page_spec.rb
deleted file mode 100644
index 782542300..000000000
--- a/spec/features/home_page_spec.rb
+++ /dev/null
@@ -1,332 +0,0 @@
-require "rails_helper"
-require_relative "form/helpers"
-
-RSpec.describe "Home Page Features" do
- include Helpers
-
- context "when there are notifications" do
- let!(:user) { FactoryBot.create(:user) }
-
- context "when the notifications are currently active" do
- before do
- create(:notification, title: "Notification title 1")
- create(:notification, title: "Notification title 2")
- create(:notification, title: "Notification title 3")
- sign_in user
- visit(root_path)
- end
-
- it "shows the latest notification with count and dismiss link" do
- expect(page).to have_content("Notification 1 of 3")
- expect(page).to have_content("Notification title 3")
- expect(page).to have_link("Dismiss")
- expect(page).to have_link("Link text")
- end
-
- context "when the user clicks a notification link" do
- before do
- click_link("Link text")
- end
-
- it "takes them to the notification details page" do
- expect(page).to have_current_path(notifications_path)
- expect(page).to have_content("Notification title 3")
- expect(page).to have_content("Some html content")
- expect(page).to have_link("Back to Home")
- end
-
- context "when they return" do
- before do
- click_link("Back to Home")
- end
-
- it "the notification has not been dismissed" do
- expect(page).to have_current_path(root_path)
- expect(page).to have_content("Notification 1 of 3")
- expect(page).to have_content("Notification title 3")
- expect(page).to have_link("Dismiss")
- expect(page).to have_link("Link text")
- end
- end
- end
-
- context "when the user clicks a dismiss link" do
- before do
- click_link("Dismiss")
- end
-
- it "dismisses the notification and takes them back" do
- expect(page).to have_current_path(root_path)
- expect(page).to have_content("Notification 1 of 2")
- expect(page).to have_content("Notification title 2")
- expect(page).to have_link("Dismiss")
- expect(page).to have_link("Link text")
- end
-
- context "when the user dismisses the penultimate notification" do
- before do
- click_link("Dismiss")
- end
-
- it "no longer displays the count" do
- expect(page).to have_current_path(root_path)
- expect(page).not_to have_content("Notification 1 of")
- expect(page).to have_content("Notification title 1")
- end
-
- context "when the user dismisses the final notification" do
- before do
- click_link("Dismiss")
- end
-
- it "no longer displays any notification" do
- expect(page).to have_current_path(root_path)
- expect(page).not_to have_content("Notification")
- expect(page).not_to have_link("Dismiss")
- expect(page).not_to have_link("Link_text")
- end
- end
- end
- end
-
- context "when another user has dismissed all their notifications" do
- before do
- other_user = create(:user)
- Notification.mark_as_read! :all, for: other_user
- visit(root_path)
- end
-
- it "the first user can still see the notifications" do
- expect(page).to have_content("Notification 1 of 3")
- expect(page).to have_content("Notification title 3")
- expect(page).to have_link("Dismiss")
- expect(page).to have_link("Link text")
- end
- end
- end
-
- context "when the notifications are not currently active" do
- before do
- create(:notification, end_date: Time.zone.yesterday, title: "Notification title 1")
- create(:notification, start_date: Time.zone.tomorrow, title: "Notification title 2")
- sign_in user
- visit(root_path)
- end
-
- it "does not show any notifications" do
- expect(page).not_to have_content("Notification title")
- expect(page).not_to have_content("Notification 1 of")
- expect(page).not_to have_link("Dismiss")
- expect(page).not_to have_link("Link text")
- end
- end
- end
-
- context "when the user is a data provider" do
- let(:user) { FactoryBot.create(:user, name: "Provider") }
-
- before do
- Timecop.freeze(Time.zone.local(2024, 1, 1))
- Singleton.__init__(FormHandler)
- create_list(:lettings_log, 6, :in_progress, owning_organisation: user.organisation, assigned_to: user)
- create_list(:lettings_log, 2, :in_progress, owning_organisation: user.organisation)
- create_list(:lettings_log, 4, :completed, owning_organisation: user.organisation, assigned_to: user)
- create_list(:lettings_log, 2, :completed)
- create_list(:lettings_log, 2, :not_started)
- sign_in user
- visit(root_path)
- end
-
- after do
- Timecop.return
- Singleton.__init__(FormHandler)
- end
-
- it "displays the correct welcome text" do
- expect(page).to have_current_path("/")
- expect(page).to have_content("Welcome back, Provider")
- expect(page).to have_content("Complete your logs")
- end
-
- context "when their organisation has submitted sales logs" do
- before do
- create_list(:sales_log, 5, :in_progress, owning_organisation: user.organisation, assigned_to: user)
- create_list(:sales_log, 3, :completed, owning_organisation: user.organisation, assigned_to: user)
- create_list(:sales_log, 2, :not_started)
- visit(root_path)
- end
-
- context "and it is not a crossover" do
- before do
- closed_period_in_progress_log = build(:lettings_log, :in_progress, owning_organisation: user.organisation, assigned_to: user, startdate: Time.zone.local(2022, 4, 1))
- closed_period_in_progress_log.save!(validate: false)
- visit(root_path)
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-half")
- expect(data_boxes.count).to eq(2)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["6", "Your lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["5", "Your sales in progress", "View all sales"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([sales_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), sales_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "sales_logs")])
- end
- end
-
- context "and it is a crossover" do
- before do
- Timecop.freeze(Time.zone.local(2024, 4, 1))
- Singleton.__init__(FormHandler)
- closed_period_in_progress_log = build(:lettings_log, :in_progress, owning_organisation: user.organisation, assigned_to: user, startdate: Time.zone.local(2022, 4, 1))
- closed_period_in_progress_log.save!(validate: false)
- sign_in user
- visit(root_path)
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-half")
-
- expect(data_boxes.count).to eq(2)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["6", "Your lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2024 2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2024 2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["5", "Your sales in progress", "View all sales"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([sales_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2024 2023], owning_organisation_select: "all", managing_organisation_select: "all"), sales_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2024 2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "sales_logs")])
- end
- end
- end
-
- context "when their organisation has never submitted sales logs" do
- before do
- visit(root_path)
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-half")
- expect(data_boxes.count).to eq(2)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["6", "Your lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "you", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["4", "Your completed lettings", "View all schemes"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: [:completed], assigned_to: "you", years: [""], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: [:completed], assigned_to: "you", years: [""], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "schemes")])
- end
- end
- end
-
- context "when the user is a data coordinator" do
- before do
- Timecop.freeze(Time.zone.local(2024, 3, 1))
- Singleton.__init__(FormHandler)
- create_list(:lettings_log, 6, :in_progress, owning_organisation: user.organisation)
- create_list(:lettings_log, 2, :in_progress, owning_organisation: user.organisation, assigned_to: user)
- create_list(:lettings_log, 4, :completed, owning_organisation: user.organisation)
- create_list(:lettings_log, 2, :completed)
- create_list(:lettings_log, 2, :not_started)
- create_list(:scheme, 1, :incomplete, owning_organisation: user.organisation)
- sign_in user
- visit(root_path)
- end
-
- after do
- Timecop.return
- Singleton.__init__(FormHandler)
- end
-
- let(:user) { FactoryBot.create(:user, :data_coordinator, name: "Coordinator") }
-
- it "displays the correct welcome text" do
- expect(page).to have_current_path("/")
- expect(page).to have_content("Welcome back, Coordinator")
- expect(page).to have_content("Manage your data")
- end
-
- context "when their organisation has submitted sales logs" do
- before do
- create_list(:sales_log, 5, :in_progress, owning_organisation: user.organisation)
- create_list(:sales_log, 3, :completed, owning_organisation: user.organisation)
- create_list(:sales_log, 2, :not_started)
- visit(root_path)
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-third")
- expect(data_boxes.count).to eq(3)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["8", "Lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["5", "Sales in progress", "View all sales"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([sales_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), sales_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "sales_logs")])
- expect(data_boxes[2].all("a").map(&:text)).to eq(["1", "Incomplete schemes", "View all schemes"])
- expect(data_boxes[2].all("a").map { |line| line["href"] }).to eq([schemes_path(status: [:incomplete], owning_organisation_select: "all"), schemes_path(status: [:incomplete], owning_organisation_select: "all"), clear_filters_path(filter_type: "schemes")])
- end
- end
-
- context "when their organisation has never submitted sales logs" do
- before do
- visit(root_path)
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-half")
- expect(data_boxes.count).to eq(2)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["8", "Lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["1", "Incomplete schemes", "View all schemes"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([schemes_path(status: [:incomplete], owning_organisation_select: "all"), schemes_path(status: [:incomplete], owning_organisation_select: "all"), clear_filters_path(filter_type: "schemes")])
- end
- end
- end
-
- context "when the user is a support user" do
- let(:support_user) { FactoryBot.create(:user, :support, name: "Support") }
- let(:notify_client) { instance_double(Notifications::Client) }
- let(:confirmation_token) { "MCDH5y6Km-U7CFPgAMVS" }
- let(:devise_notify_mailer) { DeviseNotifyMailer.new }
- let(:otp) { "999111" }
-
- before do
- Timecop.freeze(Time.zone.local(2024, 3, 1))
- Singleton.__init__(FormHandler)
- create_list(:lettings_log, 2, :in_progress)
- create_list(:lettings_log, 1, :completed)
- create_list(:lettings_log, 2, :not_started)
- create_list(:sales_log, 3, :in_progress)
- create_list(:sales_log, 1, :completed)
- create_list(:sales_log, 2, :not_started)
- create_list(:scheme, 1, :incomplete)
- completed_scheme = create(:scheme)
- create(:location, scheme: completed_scheme)
- allow(DeviseNotifyMailer).to receive(:new).and_return(devise_notify_mailer)
- allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
- allow(Devise).to receive(:friendly_token).and_return(confirmation_token)
- allow(notify_client).to receive(:send_email).and_return(true)
- allow(SecureRandom).to receive(:random_number).and_return(otp)
- visit("/lettings-logs")
- fill_in("user[email]", with: support_user.email)
- fill_in("user[password]", with: support_user.password)
- click_button("Sign in")
- fill_in("code", with: otp)
- click_button("Submit")
- visit(root_path)
- end
-
- after do
- Timecop.return
- Singleton.__init__(FormHandler)
- end
-
- it "displays the correct welcome text" do
- expect(page).to have_current_path("/")
- expect(page).to have_content("Welcome back, Support")
- expect(page).to have_content("Manage all data")
- end
-
- it "displays correct data boxes, counts and links" do
- data_boxes = page.find_all(class: "app-data-box-one-third")
- expect(data_boxes.count).to eq(3)
- expect(data_boxes[0].all("a").map(&:text)).to eq(["2", "Lettings in progress", "View all lettings"])
- expect(data_boxes[0].all("a").map { |line| line["href"] }).to eq([lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), lettings_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "lettings_logs")])
- expect(data_boxes[1].all("a").map(&:text)).to eq(["3", "Sales in progress", "View all sales"])
- expect(data_boxes[1].all("a").map { |line| line["href"] }).to eq([sales_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), sales_logs_path(status: %i[in_progress], assigned_to: "all", years: %w[2023], owning_organisation_select: "all", managing_organisation_select: "all"), clear_filters_path(filter_type: "sales_logs")])
- expect(data_boxes[2].all("a").map(&:text)).to eq(["1", "Incomplete schemes", "View all schemes"])
- expect(data_boxes[2].all("a").map { |line| line["href"] }).to eq([schemes_path(status: [:incomplete], owning_organisation_select: "all"), schemes_path(status: [:incomplete], owning_organisation_select: "all"), clear_filters_path(filter_type: "schemes")])
- end
- end
-end
diff --git a/spec/fixtures/exports/general_needs_log.csv b/spec/fixtures/exports/general_needs_log.csv
index eddab177f..3f50e0c25 100644
--- a/spec/fixtures/exports/general_needs_log.csv
+++ b/spec/fixtures/exports/general_needs_log.csv
@@ -1,2 +1,2 @@
status,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,irproduct_other,reason,propcode,la,prevloc,hb,hbrentshortfall,mrcdate,incref,startdate,armedforces,unitletas,builtype,voiddate,renttype,needstype,lettype,totchild,totelder,totadult,nocharge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,ppcodenk,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,hhtype,new_old,vacdays,uprn,uprn_known,uprn_confirmed,address_line1,address_line2,town_or_city,county,formid,owningorgid,owningorgname,hcnum,maningorgid,maningorgname,manhcnum,createddate,uploaddate
-2,BZ737,35,F,2,13,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,4,4,1,1,2,1,5,4,SE2 6RT,6,7,3,2,1,68,1,1,2,2,7,NW1 5TY,1,2,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49+01:00,0,2022-02-02T10:36:49+00:00,1,2,1,2019-11-03T00:00:00+00:00,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,3,,4,2,638,,0,,fake address,,London,,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-05-01T00:00:00+01:00,2022-05-01T00:00:00+01:00
+2,BZ737,35,F,2,13,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,4,4,1,1,2,1,5,4,SE2 6RT,6,7,3,2,1,68,1,1,2,2,7,NW1 5TY,1,2,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49+01:00,0,2022-02-02T10:36:49+00:00,1,2,1,2019-11-03T00:00:00+00:00,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,3,,4,2,638,,0,,Address line 1,,London,,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-05-01T00:00:00+01:00,2022-05-01T00:00:00+01:00
diff --git a/spec/fixtures/exports/general_needs_log.xml b/spec/fixtures/exports/general_needs_log.xml
index c712c3041..98abfc438 100644
--- a/spec/fixtures/exports/general_needs_log.xml
+++ b/spec/fixtures/exports/general_needs_log.xml
@@ -138,7 +138,7 @@
0
-
fake address
+
Address line 1
London
diff --git a/spec/fixtures/exports/general_needs_log_24_25.xml b/spec/fixtures/exports/general_needs_log_24_25.xml
index b696cbc04..a5211e35d 100644
--- a/spec/fixtures/exports/general_needs_log_24_25.xml
+++ b/spec/fixtures/exports/general_needs_log_24_25.xml
@@ -140,7 +140,7 @@
0
-
fake address
+
Address line 1
London
diff --git a/spec/fixtures/files/lettings_log_csv_export_codes_23.csv b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv
index 02f99618b..ca482e070 100644
--- a/spec/fixtures/files/lettings_log_csv_export_codes_23.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,13,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,
+,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,,Address line 1,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,13,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv
index 7a8ad5bb1..e21817cb3 100644
--- a/spec/fixtures/files/lettings_log_csv_export_codes_24.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,uprn_known,uprn_selection,address_search_value_check,address_line1_input,postcode_full_input,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,2023,,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,0,2,6,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,4,,1,4,0,0,2,35,,F,0,2,,0,0,P,,,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,0,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,
+,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,2023,,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,,Address line 1,,London,,NW9 5LL,false,Barnet,E09000003,0,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,0,2,6,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,4,,1,4,0,0,2,35,,F,0,2,,0,0,P,,,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,0,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_labels_23.csv b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv
index d14d782d8..d7a2d58bf 100644
--- a/spec/fixtures/files/lettings_log_csv_export_labels_23.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,
+,completed,,s.port@jeemayle.com,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,,Address line 1,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv
index 8121fffe0..78e85dad1 100644
--- a/spec/fixtures/files/lettings_log_csv_export_labels_24.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,uprn_known,uprn_selection,address_search_value_check,address_line1_input,postcode_full_input,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,in_progress,,s.port@jeemayle.com,s.port@jeemayle.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,,,No,HIJKLMN,ABCDEFG,Yes,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,,,Yes,2024-03-31,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,Australia,Other,Yes,Partner,,,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,
+,in_progress,,s.port@jeemayle.com,s.port@jeemayle.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,,,No,HIJKLMN,ABCDEFG,Yes,,Address line 1,,London,,NW9 5LL,No,Barnet,E09000003,No,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,,,Yes,2024-03-31,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,Australia,Other,Yes,Partner,,,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv
index 280af9787..e4cd2fbc4 100644
--- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,0,2,6,2,2,7,1,1,3,2023-11-24,1,1,2023-11-25,3,1,4,,2,,1,4,1,35,F,0,2,13,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,0,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,
+,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,Address line 1,,London,,NW9 5LL,Barnet,0,2,6,2,2,7,1,1,3,2023-11-24,1,1,2023-11-25,3,1,4,,2,,1,4,1,35,F,0,2,13,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,0,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv
index 6af4c949b..21e1c1414 100644
--- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,1,2024,,DLUHC,DLUHC,1,7,0,2024-04-01,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,fake address,,London,,NW9 5LL,Barnet,0,2,6,2,7,1,1,3,2024-03-30,0,1,2024-03-31,3,1,4,,2,,4,1,35,F,0,2,,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,0,,2,0,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,
+,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,1,2024,,DLUHC,DLUHC,1,7,0,2024-04-01,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,Address line 1,,London,,NW9 5LL,Barnet,0,2,6,2,7,1,1,3,2024-03-30,0,1,2024-03-31,3,1,4,,2,,4,1,35,F,0,2,,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,0,,2,0,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv
index 5af82bdd8..ead1815e7 100644
--- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,Yes,2023-11-25,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,Yes,12.0,,,,,,,,,,,,,,,,,,,,
+,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,Address line 1,,London,,NW9 5LL,Barnet,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,Yes,2023-11-25,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,Yes,12.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv
index 9e0872512..c53147b26 100644
--- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv
+++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv
@@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
-,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,fake address,,London,,NW9 5LL,Barnet,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,0,Yes,2024-03-31,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,Yes,35,Female,White,Irish,,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,Yes,12.0,,,,,,,,,,,,,,,,,,,,
+,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,Address line 1,,London,,NW9 5LL,Barnet,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,0,Yes,2024-03-31,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,Yes,35,Female,White,Irish,,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,200.0,50.0,40.0,35.0,325.0,Yes,12.0,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb
index 28fd9babf..a0281af45 100644
--- a/spec/models/lettings_log_spec.rb
+++ b/spec/models/lettings_log_spec.rb
@@ -2762,6 +2762,7 @@ RSpec.describe LettingsLog do
describe "scopes" do
let!(:lettings_log_1) { create(:lettings_log, :in_progress, startdate: Time.utc(2021, 5, 3), mrcdate: Time.utc(2021, 5, 3), voiddate: Time.utc(2021, 5, 3), assigned_to: assigned_to_user) }
let!(:lettings_log_2) { create(:lettings_log, :completed, startdate: Time.utc(2021, 5, 3), mrcdate: Time.utc(2021, 5, 3), voiddate: Time.utc(2021, 5, 3), assigned_to: assigned_to_user) }
+ let(:postcode_to_search) { "SW1A 0AA" }
before do
Timecop.freeze(Time.utc(2022, 6, 3))
@@ -2824,21 +2825,27 @@ RSpec.describe LettingsLog do
end
describe "#filter_by_postcode" do
- it "allows searching by a Property Postcode" do
- result = described_class.filter_by_postcode(lettings_log_to_search.postcode_full)
- expect(result.count).to eq(1)
- expect(result.first.id).to eq lettings_log_to_search.id
+ context "when not associated with a location" do
+ before do
+ lettings_log_to_search.update!(postcode_full: postcode_to_search)
+ end
+
+ it "allows searching by a Property Postcode" do
+ result = described_class.filter_by_postcode(postcode_to_search)
+ expect(result.count).to eq(1)
+ expect(result.first.id).to eq lettings_log_to_search.id
+ end
end
context "when lettings log is supported housing" do
- let(:location) { create(:location, postcode: "W6 0ST") }
+ let(:location) { create(:location, postcode: postcode_to_search) }
before do
lettings_log_to_search.update!(needstype: 2, location:)
end
it "allows searching by a Property Postcode" do
- result = described_class.filter_by_location_postcode("W6 0ST")
+ result = described_class.filter_by_location_postcode(postcode_to_search)
expect(result.count).to eq(1)
expect(result.first.id).to eq lettings_log_to_search.id
end
@@ -2865,7 +2872,8 @@ RSpec.describe LettingsLog do
end
it "allows searching by a Property Postcode" do
- result = described_class.search_by(lettings_log_to_search.postcode_full)
+ lettings_log_to_search.update!(postcode_full: postcode_to_search)
+ result = described_class.search_by(postcode_to_search)
expect(result.count).to eq(1)
expect(result.first.id).to eq lettings_log_to_search.id
end
@@ -2897,10 +2905,10 @@ RSpec.describe LettingsLog do
end
context "when postcode has spaces and lower case letters" do
- let(:matching_postcode_lower_case_with_spaces) { lettings_log_to_search.postcode_full.downcase.chars.insert(3, " ").join }
-
it "allows searching by a Property Postcode" do
- result = described_class.search_by(matching_postcode_lower_case_with_spaces)
+ lettings_log_to_search.update!(postcode_full: postcode_to_search)
+ unformatted_postcode = postcode_to_search.downcase.chars.join(" ")
+ result = described_class.search_by(unformatted_postcode)
expect(result.count).to eq(1)
expect(result.first.id).to eq lettings_log_to_search.id
end
diff --git a/spec/presenters/homepage_presenter_spec.rb b/spec/presenters/homepage_presenter_spec.rb
new file mode 100644
index 000000000..bcb3e2fc4
--- /dev/null
+++ b/spec/presenters/homepage_presenter_spec.rb
@@ -0,0 +1,312 @@
+require "rails_helper"
+
+RSpec.describe HomepagePresenter do
+ let(:organisation) { create(:organisation) }
+ let(:user) { create(:user, organisation:) }
+ let(:in_crossover_period) { true }
+ let(:presenter) { described_class.new(user) }
+ let(:date_this_year) { Time.zone.today }
+ let(:date_last_year) { Time.zone.today - 1.year }
+ let(:expected_count) { rand 1..10 }
+
+ before do
+ allow(FormHandler.instance).to receive(:in_crossover_period?).and_return(in_crossover_period)
+ end
+
+ context "when the user is support" do
+ let(:user) { create(:user, :support) }
+
+ it "sets the correct title" do
+ expect(presenter.title_text_for_user).to eq "Manage all data"
+ end
+
+ it "returns that schemes should be displayed" do
+ expect(presenter.display_schemes?).to be true
+ end
+
+ it "returns that sales logs should be displayed" do
+ expect(presenter.display_sales?).to be true
+ end
+ end
+
+ context "when the user is a data coordinator" do
+ let(:user) { create(:user, :data_coordinator) }
+
+ it "sets the correct title" do
+ expect(presenter.title_text_for_user).to eq "Manage your organisation's logs"
+ end
+
+ it "returns that schemes should be displayed" do
+ expect(presenter.display_schemes?).to be true
+ end
+ end
+
+ context "when the user is a data provider" do
+ let(:user) { create(:user, :data_provider) }
+
+ it "sets the correct title" do
+ expect(presenter.title_text_for_user).to eq "Manage logs assigned to you"
+ end
+
+ it "returns that schemes should not be displayed" do
+ expect(presenter.display_schemes?).to be false
+ end
+ end
+
+ context "when the user's organisation has never submitted sales logs" do
+ it "shows the user's organisation does not log sales" do
+ expect(presenter.display_sales?).to be false
+ end
+
+ context "when in the crossover period" do
+ let(:in_crossover_period) { true }
+
+ it "leaves all sales related data as nil" do
+ sales_data = [
+ presenter.current_year_in_progress_sales_data,
+ presenter.current_year_completed_sales_data,
+ presenter.last_year_in_progress_sales_data,
+ presenter.last_year_completed_sales_data,
+ ]
+ expect(sales_data).to all be nil
+ end
+ end
+
+ context "when not in the crossover period" do
+ let(:in_crossover_period) { false }
+
+ it "leaves all sales related data as nil" do
+ sales_data = [
+ presenter.current_year_in_progress_sales_data,
+ presenter.current_year_completed_sales_data,
+ presenter.last_year_in_progress_sales_data,
+ presenter.last_year_completed_sales_data,
+ ]
+ expect(sales_data).to all be nil
+ end
+ end
+ end
+
+ context "when the user's organisation has submitted sales logs" do
+ before do
+ create(:sales_log, assigned_to: user)
+ end
+
+ it "shows the user's organisation logs sales" do
+ expect(presenter.display_sales?).to be true
+ end
+
+ context "when in the crossover period" do
+ let(:in_crossover_period) { true }
+
+ it "populates all sales related data" do
+ sales_data = [
+ presenter.current_year_in_progress_sales_data,
+ presenter.current_year_completed_sales_data,
+ presenter.last_year_in_progress_sales_data,
+ presenter.last_year_completed_sales_data,
+ ]
+ expect(sales_data).to all be_an_instance_of(Hash)
+ end
+ end
+
+ context "when not in the crossover period" do
+ let(:in_crossover_period) { false }
+
+ it "populates all relevant sales related data" do
+ sales_data = [
+ presenter.current_year_in_progress_sales_data,
+ presenter.current_year_completed_sales_data,
+ presenter.last_year_completed_sales_data,
+ ]
+ expect(sales_data).to all be_an_instance_of(Hash)
+ end
+
+ it "does not populate data for last year's in progress logs" do
+ last_year_in_progress_data = [
+ presenter.last_year_in_progress_lettings_data,
+ presenter.last_year_in_progress_sales_data,
+ ]
+ expect(last_year_in_progress_data).to all be nil
+ end
+ end
+ end
+
+ context "when in the crossover period" do
+ let(:in_crossover_period) { true }
+
+ it "returns that we are in the crossover period" do
+ expect(presenter.in_crossover_period?).to be true
+ end
+ end
+
+ context "when not in the crossover period" do
+ let(:in_crossover_period) { false }
+
+ it "returns that we are in the crossover period" do
+ expect(presenter.in_crossover_period?).to be false
+ end
+ end
+
+ describe "the data collected and exposed by the presenter" do
+ context "with lettings logs" do
+ let(:type) { :lettings_log }
+
+ context "with in progress status" do
+ let(:status) { :in_progress }
+
+ context "and the current year" do
+ let(:startdate) { date_this_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, startdate:)
+ data = presenter.current_year_in_progress_lettings_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Lettings in progress"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_this_year.year.to_s]
+ end
+ end
+
+ context "and the last year" do
+ let(:startdate) { date_last_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, startdate:)
+ data = presenter.last_year_in_progress_lettings_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Lettings in progress"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_last_year.year.to_s]
+ end
+ end
+ end
+
+ context "with completed status" do
+ let(:status) { :completed }
+
+ context "and the current year" do
+ let(:startdate) { date_this_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, :completed2024, assigned_to: user, startdate:)
+ data = presenter.current_year_completed_lettings_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Completed lettings"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_this_year.year.to_s]
+ end
+ end
+
+ context "and the last year" do
+ let(:startdate) { date_last_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, startdate:)
+ data = presenter.last_year_completed_lettings_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Completed lettings"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_last_year.year.to_s]
+ end
+ end
+ end
+ end
+
+ context "with sales logs" do
+ let(:type) { :sales_log }
+
+ context "with in progress status" do
+ let(:status) { :in_progress }
+
+ context "and the current year" do
+ let(:saledate) { date_this_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, saledate:)
+ data = presenter.current_year_in_progress_sales_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Sales in progress"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_this_year.year.to_s]
+ end
+ end
+
+ context "and the last year" do
+ let(:saledate) { date_last_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, saledate:)
+ data = presenter.last_year_in_progress_sales_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Sales in progress"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_last_year.year.to_s]
+ end
+ end
+ end
+
+ context "with completed status" do
+ let(:status) { :completed }
+
+ context "and the current year" do
+ let(:saledate) { date_this_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, :completed2024, assigned_to: user, saledate:)
+ data = presenter.current_year_completed_sales_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Completed sales"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_this_year.year.to_s]
+ end
+ end
+
+ context "and the last year" do
+ let(:saledate) { date_last_year }
+
+ it "exposes the correct data for the data box" do
+ create_list(type, expected_count, status, assigned_to: user, saledate:)
+ data = presenter.last_year_completed_sales_data
+
+ expect(data[:count]).to be expected_count
+ expect(data[:text]).to eq "Completed sales"
+ uri = URI.parse(data[:path])
+ expect(uri.path).to eq "/#{type.to_s.dasherize}s"
+ query_params = CGI.parse(uri.query)
+ expect(query_params["status[]"]).to eq [status.to_s]
+ expect(query_params["years[]"]).to eq [date_last_year.year.to_s]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/request_helper.rb b/spec/request_helper.rb
index 8c5759bec..ee38568a7 100644
--- a/spec/request_helper.rb
+++ b/spec/request_helper.rb
@@ -83,6 +83,9 @@ module RequestHelper
WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=1234567890123")
.to_return(status: 404, body: "", headers: {})
+
+ WebMock.stub_request(:get, "https://api.os.uk/search/places/v1/find?key=OS_DATA_KEY&maxresults=10&minmatch=0.4&query=Address%20line%201,%20SW1A%201AA")
+ .to_return(status: 200, body: { results: [{ DPA: { MATCH: 0.9, BUILDING_NAME: "result address line 1", POST_TOWN: "result town or city", POSTCODE: "AA1 1AA", UPRN: "1" } }] }.to_json, headers: {})
end
def self.real_http_requests
diff --git a/spec/requests/start_controller_spec.rb b/spec/requests/start_controller_spec.rb
index 190c343bc..128325184 100644
--- a/spec/requests/start_controller_spec.rb
+++ b/spec/requests/start_controller_spec.rb
@@ -2,7 +2,6 @@ require "rails_helper"
RSpec.describe StartController, type: :request do
let(:user) { create(:user) }
- let(:headers) { { "Accept" => "text/html" } }
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
@@ -16,7 +15,7 @@ RSpec.describe StartController, type: :request do
describe "GET" do
context "when the user is not signed in" do
it "routes user to the start page" do
- get "/", headers: headers, params: {}
+ get root_path
expect(path).to eq("/")
expect(page).to have_content("Start now")
end
@@ -24,21 +23,293 @@ RSpec.describe StartController, type: :request do
context "when the user is signed in" do
before do
+ allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
it "routes user to the home page" do
- get "/", headers:, params: {}
+ get root_path
expect(page).to have_content("Welcome back")
end
+ describe "the data displayed at the top of the home page" do
+ let(:current_year) { FormHandler.instance.current_collection_start_year }
+ let(:in_crossover_period) { false }
+
+ before do
+ allow(FormHandler.instance).to receive(:in_crossover_period?).and_return in_crossover_period
+ end
+
+ context "when in the crossover period" do
+ let(:in_crossover_period) { true }
+
+ it "shows both open collection years with last year first" do
+ get root_path
+
+ logs_headers = page.find_all("h2").map(&:text).select { |header| header.include? "Logs" }
+
+ expected_headers = [
+ "#{current_year - 1} to #{current_year} Logs",
+ "#{current_year} to #{current_year + 1} Logs",
+ ]
+
+ expect(logs_headers).to eq expected_headers
+ end
+ end
+
+ context "when not in the crossover period" do
+ let(:in_crossover_period) { false }
+
+ it "shows this year first, with last year's after marked as closed" do
+ get root_path
+
+ logs_headers = page.find_all("h2").map(&:text).select { |header| header.include? "Logs" }
+
+ expected_headers = [
+ "#{current_year} to #{current_year + 1} Logs",
+ "#{current_year - 1} to #{current_year} Logs (Closed collection year)",
+ ]
+
+ expect(logs_headers).to eq expected_headers
+ end
+ end
+
+ context "when the user's org has never submitted sales" do
+ it "does not display data related to sales" do
+ get root_path
+
+ databox_texts = page.find_all(".app-data-box__upper").map(&:text)
+ any_sales_boxes = databox_texts.map(&:downcase).any? { |text| text.include? "sales" }
+
+ expect(any_sales_boxes).to be false
+ end
+ end
+
+ context "when the user's org has submitted sales logs" do
+ before do
+ create(:sales_log, assigned_to: user)
+ end
+
+ it "displays data related to sales" do
+ get root_path
+
+ databox_texts = page.find_all(".app-data-box__upper").map(&:text)
+ any_sales_boxes = databox_texts.map(&:downcase).any? { |text| text.include? "sales" }
+
+ expect(any_sales_boxes).to be true
+ end
+ end
+
+ context "when the user is a data provider" do
+ let(:user) { create(:user, :data_provider) }
+
+ it "does not display data related to schemes" do
+ get root_path
+
+ databox_texts = page.find_all(".app-data-box__upper").map(&:text)
+ any_schemes_boxes = databox_texts.map(&:downcase).any? { |text| text.include? "schemes" }
+
+ expect(any_schemes_boxes).to be false
+ end
+ end
+
+ context "when the user is a data coordinator" do
+ let(:user) { create(:user, :data_coordinator) }
+
+ it "does display data related to schemes" do
+ get root_path
+
+ databox_texts = page.find_all(".app-data-box__upper").map(&:text)
+ any_schemes_boxes = databox_texts.map(&:downcase).any? { |text| text.include? "schemes" }
+
+ expect(any_schemes_boxes).to be true
+ end
+ end
+
+ context "when the user is a support user" do
+ let(:user) { create(:user, :support) }
+
+ it "does display data related to schemes" do
+ get root_path
+
+ databox_texts = page.find_all(".app-data-box__upper").map(&:text)
+ any_schemes_boxes = databox_texts.map(&:downcase).any? { |text| text.include? "schemes" }
+
+ expect(any_schemes_boxes).to be true
+ end
+ end
+
+ describe "the links in the data boxes" do
+ let(:user) { create(:user, :data_coordinator) }
+ let(:in_crossover_period) { true }
+
+ before do
+ create(:sales_log, assigned_to: user)
+ get root_path
+ end
+
+ [
+ { type: "lettings", status: "in_progress" },
+ { type: "lettings", status: "completed" },
+ { type: "sales", status: "in_progress" },
+ { type: "sales", status: "completed" },
+ ].each do |test_case|
+ it "shows the correct links for #{test_case[:status]} #{test_case[:type]}" do
+ databoxes = all_databoxes(test_case[:type], test_case[:status])
+
+ expect(databoxes.count).to be 2
+
+ links = databoxes.map { |databox| link_from_databox databox }
+
+ expect(links.map(&:path)).to all eq send("#{test_case[:type]}_logs_path")
+
+ params = links.map { |link| CGI.parse(link.query) }
+
+ expect(params.map { |prms| prms["status[]"] }).to all eq [test_case[:status]]
+ expect(params.first["years[]"]).to eq [(current_year - 1).to_s]
+ expect(params.second["years[]"]).to eq [current_year.to_s]
+ end
+ end
+
+ it "shows the correct links for incomplete schemes" do
+ type = "schemes"
+ status = "incomplete"
+ databoxes = all_databoxes(type, status)
+
+ expect(databoxes.count).to be 1
+
+ link = databoxes.map { |databox| link_from_databox databox }.first
+
+ expect(link.path).to eq schemes_path
+
+ params = CGI.parse(link.query)
+
+ expect(params["status[]"]).to eq [status]
+ end
+ end
+
+ describe "the counts displayed" do
+ let(:in_crossover_period) { true }
+ let(:org_1) { create(:organisation) }
+ let(:org_2) { create(:organisation) }
+ let(:provider_1) { create(:user, :data_provider, organisation: org_1) }
+ let(:provider_2) { create(:user, :data_provider, organisation: org_2) }
+ let(:coordinator) { create(:user, :data_coordinator, organisation: org_1) }
+ let(:support_user) { create(:user, :support) }
+
+ context "and logged in as a provider" do
+ let(:user) { provider_1 }
+
+ it "shows the correct counts of logs created by them" do
+ last_year_in_progress_count = 2
+ this_year_in_progress_count = 3
+ create_list(:lettings_log, last_year_in_progress_count, :in_progress, assigned_to: provider_1, startdate: Time.zone.today - 1.year)
+ create_list(:lettings_log, this_year_in_progress_count, :in_progress, assigned_to: provider_1, startdate: Time.zone.today)
+
+ get root_path
+
+ type = "lettings"
+ status = "in_progress"
+ databoxes = all_databoxes(type, status)
+ counts = databoxes.map { |databox| count_from_databox databox }
+
+ expect(counts).to eq [last_year_in_progress_count, this_year_in_progress_count]
+ end
+
+ it "does not include logs created by other users in the count, whether in their organisation or not" do
+ create(:lettings_log, :in_progress, assigned_to: coordinator, startdate: Time.zone.today - 1.year)
+ create(:lettings_log, :in_progress, assigned_to: provider_2, startdate: Time.zone.today)
+
+ get root_path
+
+ type = "lettings"
+ status = "in_progress"
+ databoxes = all_databoxes(type, status)
+ counts = databoxes.map { |databox| count_from_databox databox }
+
+ expect(counts).to eq [0, 0]
+ end
+ end
+
+ context "and logged in as a coordinator" do
+ let(:user) { coordinator }
+
+ it "shows the correct counts of logs created by all users in their organisation" do
+ last_year_in_progress_count = 2
+ this_year_in_progress_count = 3
+ create_list(:lettings_log, last_year_in_progress_count, :in_progress, assigned_to: provider_1, startdate: Time.zone.today - 1.year)
+ create_list(:lettings_log, this_year_in_progress_count, :in_progress, assigned_to: coordinator, startdate: Time.zone.today)
+
+ get root_path
+
+ type = "lettings"
+ status = "in_progress"
+ databoxes = all_databoxes(type, status)
+ counts = databoxes.map { |databox| count_from_databox databox }
+
+ expect(counts).to eq [last_year_in_progress_count, this_year_in_progress_count]
+ end
+
+ it "does not include logs created by users from other organisations in the count" do
+ create(:lettings_log, :in_progress, assigned_to: provider_2, startdate: Time.zone.today)
+
+ get root_path
+
+ type = "lettings"
+ status = "in_progress"
+ databoxes = all_databoxes(type, status)
+
+ counts = databoxes.map { |databox| count_from_databox databox }
+ expect(counts).to eq [0, 0]
+ end
+ end
+
+ context "and logged in as a support user" do
+ let(:user) { support_user }
+
+ it "shows the correct counts of all logs from all orgs" do
+ provider_1_lettings_last_year_in_progress_count = 2
+ coordinator_lettings_this_year_in_progress_count = 3
+ provider_2_lettings_last_year_in_progress_count = 2
+ provider_2_sales_this_year_in_progress_count = 3
+ create_list(:lettings_log, provider_1_lettings_last_year_in_progress_count, :in_progress, assigned_to: provider_1, startdate: Time.zone.today - 1.year)
+ create_list(:lettings_log, coordinator_lettings_this_year_in_progress_count, :in_progress, assigned_to: coordinator, startdate: Time.zone.today)
+ create_list(:lettings_log, provider_2_lettings_last_year_in_progress_count, :in_progress, assigned_to: provider_2, startdate: Time.zone.today - 1.year)
+ create_list(:sales_log, provider_2_sales_this_year_in_progress_count, :in_progress, assigned_to: provider_2, saledate: Time.zone.today)
+
+ get root_path
+
+ type = "lettings"
+ status = "in_progress"
+ lettings_databoxes = all_databoxes(type, status)
+ lettings_counts = lettings_databoxes.map { |databox| count_from_databox databox }
+
+ expect(lettings_counts).to eq [
+ provider_1_lettings_last_year_in_progress_count + provider_2_lettings_last_year_in_progress_count,
+ coordinator_lettings_this_year_in_progress_count,
+ ]
+
+ type = "sales"
+ status = "in_progress"
+ sales_databoxes = all_databoxes(type, status)
+ sales_counts = sales_databoxes.map { |databox| count_from_databox databox }
+
+ expect(sales_counts).to eq [
+ 0,
+ provider_2_sales_this_year_in_progress_count,
+ ]
+ end
+ end
+ end
+ end
+
context "and 2023 collection window is open for editing" do
before do
allow(Time).to receive(:now).and_return(Time.zone.local(2024, 1, 1))
end
it "displays correct resources for 2023/24 and 2024/25 collection years" do
- get "/", headers: headers, params: {}
+ get root_path
expect(page).to have_content("Lettings 24/25")
expect(page).to have_content("Lettings 23/24")
expect(page).to have_content("Lettings 2024 to 2025")
@@ -56,7 +327,7 @@ RSpec.describe StartController, type: :request do
end
it "displays correct resources for 2023/24 and 2024/25 collection years" do
- get "/", headers: headers, params: {}
+ get root_path
expect(page).to have_content("Lettings 24/25")
expect(page).not_to have_content("Lettings 23/24")
expect(page).to have_content("Lettings 2024 to 2025")
@@ -69,12 +340,12 @@ RSpec.describe StartController, type: :request do
end
it "shows guidance link" do
- get "/", headers: headers, params: {}
+ get root_path
expect(page).to have_content("Guidance for submitting social housing lettings and sales data (CORE)")
end
it "displays About this service section" do
- get "/", headers:, params: {}
+ get root_path
expect(page).to have_content("About this service")
end
end
@@ -83,7 +354,7 @@ RSpec.describe StartController, type: :request do
describe "guidance page" do
context "when the user is not signed in" do
it "routes user to the guidance page" do
- get "/guidance", headers:, params: {}
+ get guidance_path
expect(page).to have_content("Guidance for submitting social housing lettings and sales data")
end
end
@@ -94,9 +365,27 @@ RSpec.describe StartController, type: :request do
end
it "routes user to the guidance page" do
- get "/guidance", headers:, params: {}
+ get guidance_path
expect(page).to have_content("Guidance for submitting social housing lettings and sales data")
end
end
end
+
+private
+
+ def all_databoxes(type, status)
+ databoxes = page.find_all(".app-data-box__upper")
+ databoxes.select do |box|
+ box.text.downcase.include?(type) &&
+ box.text.downcase.include?(status.humanize.downcase)
+ end
+ end
+
+ def link_from_databox(databox)
+ URI.parse(databox.first("a")[:href])
+ end
+
+ def count_from_databox(databox)
+ databox.first("a").text.to_i
+ end
end
diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
index ca17041ff..0c394b9c0 100644
--- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
+++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end
end
- context "when testing valid/invalid attributes" do
+ describe "valid/invalid attributes" do
let(:valid_attributes) do
{
bulk_upload:,
diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
index 712e7a817..2c4d475ee 100644
--- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
+++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
@@ -125,7 +125,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
- context "when testing valid/invalid attributes" do
+ describe "valid/invalid attributes" do
let(:valid_attributes) do
{
bulk_upload:,