Browse Source

Cldc 3114 enable support control of rent periods per organisation (#2442)

* write helper method to support having the correct rent period checkboxes checked

* update new and create in organisations controller and view to enable creation of relevant organisation rent periods
write tests for this

* small changes to models

* enable editing rent period in the UI
display change button on org details page
display rent periods question on edit page

* enable updating org rent periods
update logic in #update
related tests

* alter redirect after support user creates an organisation

* adjust various UI elements: ordering of rows, copy changes, label size and associated tests

* rework the #rent_period_labels method to return All under the correct conditions, rework tests related to that. + fix assorted tests that were either flakey or breaking due to addition of rent periods logic to create and update

* amend failing tests and resolve linting complaints

* changes following review

* disable checkboxes for rent periods if they are in use so that users are not able to make existing logs invalid
hint text added to the question to explain this
I have also added all rent periods to a hidden field to remove the need to fetch them again form the db in the update method

* update validation to reflect the fact that an org having no associated rent periods no longer means they accept all rent periods
update tests adding both cases and removing unnecessary additional db additions

* rake task to create rent period associations for orgs that have none

* revert mistaken copy changes in designs

* create rent periods in factories as default, with an option to skip. skip automatic creation in tests specifically related to rent periods

* stub api call for factory value, update csv tests and fixtures accordingly

* extract a good chunk of tests out of lettings_log_spec and into a dedicated derived fields spec file. in many cases refactor tests

* remove before(:context) and associated patterns.
use assign_attributes in various places for cleaner code

* escape . in regex for API call stubs to satisfy codeQL
remove destroy_all call at the start of a test that was dealing with leftover modesl in the test db

* further refactoring of various tests to reduce database interactions and improve speed

* remove outdated distinction between unitletas mappings from before 23/24

* remove tests that seem to be testing active record and/or ruby Date class
pull/2444/head^2
Arthur Campbell 7 months ago committed by GitHub
parent
commit
a24bafe5df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 31
      app/controllers/organisations_controller.rb
  2. 11
      app/helpers/organisations_helper.rb
  3. 12
      app/models/derived_variables/lettings_log_variables.rb
  4. 9
      app/models/organisation.rb
  5. 2
      app/models/organisation_rent_period.rb
  6. 5
      app/models/validations/financial_validations.rb
  7. 25
      app/views/organisations/edit.html.erb
  8. 14
      app/views/organisations/new.html.erb
  9. 33
      app/views/organisations/show.html.erb
  10. 1
      config/locales/en.yml
  11. 12
      spec/factories/organisation.rb
  12. 2
      spec/features/form/page_routing_spec.rb
  13. 2
      spec/fixtures/files/sales_logs_csv_export_codes_23.csv
  14. 2
      spec/fixtures/files/sales_logs_csv_export_codes_24.csv
  15. 2
      spec/fixtures/files/sales_logs_csv_export_labels_23.csv
  16. 2
      spec/fixtures/files/sales_logs_csv_export_labels_24.csv
  17. 2
      spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
  18. 44
      spec/helpers/organisations_helper_spec.rb
  19. 1144
      spec/models/lettings_log_derived_fields_spec.rb
  20. 1942
      spec/models/lettings_log_spec.rb
  21. 2
      spec/models/location_spec.rb
  22. 67
      spec/models/organisation_spec.rb
  23. 4
      spec/models/sales_log_spec.rb
  24. 29
      spec/models/validations/financial_validations_spec.rb
  25. 4
      spec/request_helper.rb
  26. 119
      spec/requests/OrganisationsController/organisations_controller_rent_periods_spec.rb
  27. 2
      spec/requests/lettings_logs_controller_spec.rb
  28. 36
      spec/requests/organisations_controller_spec.rb
  29. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  30. 2
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
  31. 8
      spec/services/csv/sales_log_csv_service_spec.rb
  32. 6
      spec/services/merge/merge_organisations_service_spec.rb
  33. 5
      spec/views/organisations/show.html.erb_spec.rb

31
app/controllers/organisations_controller.rb

@ -73,21 +73,31 @@ class OrganisationsController < ApplicationController
end
def new
@resource = Organisation.new
@organisation = Organisation.new
@rent_periods = helpers.rent_periods_with_checked_attr
render "new", layout: "application"
end
def create
@resource = Organisation.new(org_params)
if @resource.save
redirect_to organisations_path
selected_rent_periods = rent_period_params[:rent_periods].compact_blank
@organisation = Organisation.new(org_params)
if @organisation.save
OrganisationRentPeriod.transaction do
selected_rent_periods.each { |period| OrganisationRentPeriod.create!(organisation: @organisation, rent_period: period) }
end
flash[:notice] = I18n.t("organisation.created", organisation: @organisation.name)
redirect_to organisation_path @organisation
else
@rent_periods = helpers.rent_periods_with_checked_attr(checked_periods: selected_rent_periods)
render :new, status: :unprocessable_entity
end
end
def edit
if current_user.data_coordinator? || current_user.support?
current_allowed_rent_periods = @organisation.organisation_rent_periods.pluck(:rent_period).map(&:to_s)
@used_rent_periods = @organisation.lettings_logs.pluck(:period).uniq.compact.map(&:to_s)
@rent_periods = helpers.rent_periods_with_checked_attr(checked_periods: current_allowed_rent_periods)
render "edit", layout: "application"
else
head :unauthorized
@ -107,6 +117,7 @@ class OrganisationsController < ApplicationController
end
def update
selected_rent_periods = rent_period_params[:rent_periods].compact_blank
if (current_user.data_coordinator? && org_params[:active].nil?) || current_user.support?
if @organisation.update(org_params)
case org_params[:active]
@ -125,7 +136,15 @@ class OrganisationsController < ApplicationController
else
flash[:notice] = I18n.t("organisation.updated")
end
rent_periods_to_delete = rent_period_params[:all_rent_periods] - selected_rent_periods
OrganisationRentPeriod.transaction do
selected_rent_periods.each { |period| OrganisationRentPeriod.create(organisation: @organisation, rent_period: period) }
OrganisationRentPeriod.where(organisation: @organisation, rent_period: rent_periods_to_delete).destroy_all
end
redirect_to details_organisation_path(@organisation)
else
@rent_periods = helpers.rent_periods_with_checked_attr(checked_periods: selected_rent_periods)
render :edit, status: :unprocessable_entity
end
else
head :unauthorized
@ -273,6 +292,10 @@ private
params.require(:organisation).permit(:name, :address_line1, :address_line2, :postcode, :phone, :holds_own_stock, :provider_type, :housing_registration_no, :active)
end
def rent_period_params
params.require(:organisation).permit(rent_periods: [], all_rent_periods: [])
end
def codes_only_export?
params.require(:codes_only) == "true"
end

11
app/helpers/organisations_helper.rb

@ -14,10 +14,11 @@ module OrganisationsHelper
{ name: "Organisation ID", value: "ORG#{organisation.id}", editable: false },
{ name: "Address", value: organisation.address_string, editable: true },
{ name: "Telephone number", value: organisation.phone, editable: true },
{ name: "Type of provider", value: organisation.display_provider_type, editable: false },
{ name: "Registration number", value: organisation.housing_registration_no || "", editable: false },
{ name: "Rent periods", value: organisation.rent_period_labels, editable: false, format: :bullet },
{ name: "Type of provider", value: organisation.display_provider_type, editable: false },
{ name: "Owns housing stock", value: organisation.holds_own_stock ? "Yes" : "No", editable: false },
{ name: "Rent periods", value: organisation.rent_period_labels, editable: true, format: :bullet },
{ name: "Data Sharing Agreement" },
{ name: "Status", value: status_tag(organisation.status), editable: false },
]
end
@ -37,4 +38,10 @@ module OrganisationsHelper
end
end
end
def rent_periods_with_checked_attr(checked_periods: nil)
RentPeriod.rent_period_mappings.each_with_object({}) do |(period_code, period_value), result|
result[period_code] = period_value.merge(checked: checked_periods.nil? || checked_periods.include?(period_code))
end
end
end

12
app/models/derived_variables/lettings_log_variables.rb

@ -1,7 +1,6 @@
module DerivedVariables::LettingsLogVariables
include DerivedVariables::SharedLogic
# renttype and unitletas values are different for intermediate rent (3 for renttype and 4 for unitletas)
RENT_TYPE_MAPPING = {
0 => 1, # "Social Rent" => "Social Rent"
1 => 2, # "Affordable Rent" => "Affordable Rent"
@ -12,15 +11,6 @@ module DerivedVariables::LettingsLogVariables
}.freeze
UNITLETAS_MAPPING = {
0 => 1, # "Social Rent" => "Social Rent basis"
1 => 2, # "Affordable Rent" => "Affordable Rent basis"
2 => 2, # "London Affordable Rent" => "Affordable Rent basis"
3 => 4, # "Rent to Buy" => "Intermediate Rent basis"
4 => 4, # "London Living Rent" => "Intermediate Rent basis"
5 => 4, # "Other intermediate rent product" => "Intermediate Rent basis"
}.freeze
UNITLETAS_MAPPING_23_24 = {
0 => 1, # "Social Rent" => "Social Rent basis"
1 => 2, # "Affordable Rent" => "Affordable Rent basis"
2 => 5, # "London Affordable Rent" => "London Affordable Rent basis"
@ -120,7 +110,7 @@ module DerivedVariables::LettingsLogVariables
if is_renewal?
self.underoccupation_benefitcap = 2 if collection_start_year == 2021
self.voiddate = startdate
self.unitletas = form.start_date.year >= 2023 ? UNITLETAS_MAPPING_23_24[rent_type] : UNITLETAS_MAPPING[rent_type]
self.unitletas = UNITLETAS_MAPPING[rent_type]
if is_general_needs?
self.prevten = 32 if owning_organisation&.provider_type == "PRP"
self.prevten = 30 if owning_organisation&.provider_type == "LA"

9
app/models/organisation.rb

@ -2,7 +2,7 @@ class Organisation < ApplicationRecord
has_many :users, dependent: :delete_all
has_many :data_protection_officers, -> { where(is_dpo: true) }, class_name: "User"
has_one :data_protection_confirmation
has_many :organisation_rent_periods
has_many :organisation_rent_periods, dependent: :destroy
has_many :owned_schemes, class_name: "Scheme", foreign_key: "owning_organisation_id", dependent: :delete_all
has_many :parent_organisation_relationships, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship"
has_many :parent_organisations, through: :parent_organisation_relationships
@ -108,8 +108,11 @@ class Organisation < ApplicationRecord
end
def rent_period_labels
labels = rent_periods.map { |period| RentPeriod.rent_period_mappings.dig(period.to_s, "value") }
labels.compact.presence || %w[All]
rent_period_ids = rent_periods
mappings = RentPeriod.rent_period_mappings
return %w[All] if (mappings.keys.map(&:to_i) - rent_period_ids).empty?
rent_period_ids.map { |id| mappings.dig(id.to_s, "value") }.compact
end
def data_protection_confirmed?

2
app/models/organisation_rent_period.rb

@ -1,3 +1,5 @@
class OrganisationRentPeriod < ApplicationRecord
belongs_to :organisation
validates :organisation_id, uniqueness: { scope: :rent_period } # rubocop:disable Rails/UniqueValidationWithoutIndex
end

5
app/models/validations/financial_validations.rb

@ -145,8 +145,9 @@ module Validations::FinancialValidations
end
def validate_rent_period(record)
if record.managing_organisation.present? && record.managing_organisation.rent_periods.present? &&
record.period && !record.managing_organisation.rent_periods.include?(record.period)
return unless record.managing_organisation && record.period
unless record.managing_organisation.rent_periods.include? record.period
record.errors.add :period, :wrong_rent_period, message: I18n.t(
"validations.financial.rent_period.invalid_for_org",
org_name: record.managing_organisation.name,

25
app/views/organisations/edit.html.erb

@ -12,26 +12,43 @@
</h1>
<% if current_user.support? %>
<%= f.govuk_text_field :name, autocomplete: "name" %>
<%= f.govuk_text_field :name, autocomplete: "name", label: { size: "m" } %>
<% end %>
<%= f.govuk_text_field :address_line1,
label: { text: "Address line 1" },
label: { text: "Address line 1", size: "m" },
autocomplete: "address-line1" %>
<%= f.govuk_text_field :address_line2,
label: { text: "Address line 2" },
label: { text: "Address line 2", size: "m" },
autocomplete: "address-line2" %>
<%= f.govuk_text_field :postcode,
label: { size: "m" },
autocomplete: "postal-code",
width: 10 %>
<%= f.govuk_phone_field :phone,
label: { text: "Telephone number" },
label: { text: "Telephone number", size: "m" },
autocomplete: "tel",
width: 20 %>
<%= f.govuk_check_boxes_fieldset :rent_periods,
legend: { text: "What are the rent periods for the organisation?" },
hint: { text: "It is not possible to deselect rent periods that are used in logs" } do %>
<% @rent_periods.map do |key, period| %>
<%= f.govuk_check_box :rent_periods,
key,
label: { text: period["value"] },
checked: period[:checked],
disabled: @used_rent_periods.include?(key) %>
<% end %>
<% end %>
<% @rent_periods.keys.each do |period_key| %>
<%= f.hidden_field :all_rent_periods, value: period_key, multiple: true %>
<% end %>
<%= f.govuk_submit "Save changes" %>
</div>
</div>

14
app/views/organisations/new.html.erb

@ -4,7 +4,7 @@
<%= govuk_back_link(href: :back) %>
<% end %>
<%= form_for(@resource, as: :organisation, html: { method: :post }) do |f| %>
<%= form_for(@organisation, as: :organisation, html: { method: :post }) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
@ -48,7 +48,7 @@
:id,
:name,
label: { text: "Organisation type", size: "m" },
options: { disabled: [""], selected: @resource.provider_type || "" } %>
options: { disabled: [""], selected: @organisation.provider_type || "" } %>
<%= f.govuk_collection_radio_buttons :holds_own_stock,
[OpenStruct.new(id: true, name: "Yes"), OpenStruct.new(id: false, name: "No")],
@ -56,6 +56,16 @@
:name,
legend: { text: "Does the organisation hold its own stock?", size: "m" } %>
<%= f.govuk_check_boxes_fieldset :rent_periods,
legend: { text: "What are the rent periods for the organisation?" } do %>
<% @rent_periods.map do |key, period| %>
<%= f.govuk_check_box :rent_periods,
key,
label: { text: period["value"] },
checked: period[:checked] %>
<% end %>
<% end %>
<%= f.govuk_submit "Create organisation" %>
</div>
</div>

33
app/views/organisations/show.html.erb

@ -16,25 +16,28 @@
<%= govuk_summary_list do |summary_list| %>
<%= organisation_name_row(user: current_user, organisation: @organisation, summary_list:) %>
<% display_organisation_attributes(@organisation).each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action(
visually_hidden_text: attr[:name].to_s.humanize.downcase,
href: edit_organisation_path(@organisation),
html_attributes: { "data-qa": "change-#{attr[:name].downcase}" },
) %>
<% end %>
<% if attr[:name] == "Data Sharing Agreement" %>
<%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
<% else %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action(
visually_hidden_text: attr[:name].to_s.humanize.downcase,
href: edit_organisation_path(@organisation),
html_attributes: { "data-qa": "change-#{attr[:name].downcase}" },
) %>
<% end %>
<% else %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
<% end %>
<p>To report a merge or update your organisation details, <%= govuk_link_to "contact the helpdesk", GlobalConstants::HELPDESK_URL %>.</p>
<%= render partial: "organisations/merged_organisation_details" %>

1
config/locales/en.yml

@ -33,6 +33,7 @@ en:
service_name: "Submit social housing lettings and sales data (CORE)"
feedback_form: "https://forms.office.com/Pages/ResponsePage.aspx?id=EGg0v32c3kOociSi7zmVqC4YDsCJ3llAvEZelBFBLUBURFVUTzFDTUJPQlM4M0laTE5DTlNFSjJBQi4u"
organisation:
created: "%{organisation} was created"
updated: "Organisation details updated"
reactivated: "%{organisation} has been reactivated."
deactivated: "%{organisation} has been deactivated."

12
spec/factories/organisation.rb

@ -14,6 +14,18 @@ FactoryBot.define do
with_dsa { true }
end
transient do
skip_rent_period_creation { false }
end
after(:build) do |organisation, evaluator|
unless evaluator.skip_rent_period_creation
(1..11).each do |rent_period|
organisation.organisation_rent_periods << build(:organisation_rent_period, organisation:, rent_period:)
end
end
end
after(:create) do |org, evaluator|
if evaluator.with_dsa
create(

2
spec/features/form/page_routing_spec.rb

@ -72,7 +72,7 @@ RSpec.describe "Form Page Routing" do
end
it "does not show question if the answer could be inferred" do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
visit("/lettings-logs/#{id}/property-postcode")

2
spec/fixtures/files/sales_logs_csv_export_codes_23.csv vendored

@ -1,2 +1,2 @@
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,FORM,COLLECTIONYEAR,CREATIONMETHOD,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,BEDS,PROPTYPE,BUILTYPE,UPRN,UPRNCONFIRMED,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,PCODE1,PCODE2,LA,LANAME,WCHAIR,NOINT,PRIVACYNOTICE,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONAL,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONAL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,1,2,1,30,X,17,17,18,1,1,P,35,X,17,,13,1,1,3,C,14,X,,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,,,Address line 1,,Town or city,,SW1A,1AA,E09000033,Westminster,1,2,1,30,X,17,17,18,1,1,P,35,X,17,,13,1,1,3,C,14,X,,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0

1 ID STATUS DUPLICATESET CREATEDDATE UPLOADDATE FORM COLLECTIONYEAR CREATIONMETHOD DATAPROTECT OWNINGORGNAME MANINGORGNAME CREATEDBY USERNAME DAY MONTH YEAR PURCHID OWNERSHIP TYPE OTHTYPE COMPANY LIVEINBUYER JOINT JOINTMORE BEDS PROPTYPE BUILTYPE UPRN UPRNCONFIRMED ADDRESS1 ADDRESS2 TOWNCITY COUNTY PCODE1 PCODE2 LA LANAME WCHAIR NOINT PRIVACYNOTICE AGE1 SEX1 ETHNICGROUP1 ETHNIC NATIONAL ECSTAT1 LIVEINBUYER1 RELAT2 AGE2 SEX2 ETHNICGROUP2 ETHNIC2 NATIONAL2 ECSTAT2 LIVEINBUYER2 HHTYPE RELAT3 AGE3 SEX3 ECSTAT3 RELAT4 AGE4 SEX4 ECSTAT4 RELAT5 AGE5 SEX5 ECSTAT5 RELAT6 AGE6 SEX6 ECSTAT6 PREVTEN PPCODENK PPOSTC1 PPOSTC2 PREVIOUSLAKNOWN PREVLOC PREVLOCNAME PREGYRHA PREGOTHER PREGLA PREGGHB PREGBLANK BUY2LIVING PREVTEN2 HHREGRES HHREGRESSTILL ARMEDFORCESSPOUSE DISABLED WHEEL INC1NK INCOME1 INC1MORT INC2NK INCOME2 INC2MORT HB SAVINGSNK SAVINGS PREVOWN PREVSHARED PROPLEN STAIRCASE STAIRBOUGHT STAIROWNED STAIRCASETOSALE RESALE EXDAY EXMONTH EXYEAR HODAY HOMONTH HOYEAR LANOMAGR SOCTEN FROMBEDS FROMPROP SOCPREVTEN VALUE VALUE_VALUE_CHECK EQUITY MORTGAGEUSED MORTGAGE MORTGAGELENDER MORTGAGELENDEROTHER MORTLEN1 EXTRABOR DEPOSIT CASHDIS MRENT HASMSCHARGE MSCHARGE MSCHARGE_VALUE_CHECK DISCOUNT GRANT
2 completed 2023-12-08T00:00:00+00:00 2024-01-01T00:00:00+00:00 2023 1 false DLUHC DLUHC billyboy@eyeklaud.com billyboy@eyeklaud.com 8 12 2023 2 8 1 1 2 1 1 Address line 1 Town or city SW1A 1AA E09000003 E09000033 Barnet Westminster 1 2 1 30 X 17 17 18 1 1 P 35 X 17 13 1 1 3 C 14 X X -9 X 3 R -9 R 10 1 1 0 1 1 1 1 3 1 4 5 1 1 0 10000 1 0 10000 1 4 1 1 2 10 110000.0 1 20000.0 5 10 1 80000.0 1 100.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_codes_24.csv vendored

@ -1,2 +1,2 @@
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,1,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,2,8,,,,1,1,2,1,,Address line 1,,Town or city,,SW1A 1AA,false,Barnet,E09000003,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,1,1,1,30,X,17,17,,1,1,P,35,X,17,,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,0,SW1A,1AA,1,E09000003,Barnet,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,1,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,2,8,,,,1,1,2,1,,Address line 1,,Town or city,,SW1A 1AA,true,Westminster,E09000033,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,1,1,1,30,X,17,17,,1,1,P,35,X,17,,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,0,SW1A,1AA,1,E09000033,Westminster,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,,10000.0

1 ID STATUS DUPLICATESET CREATEDDATE UPLOADDATE COLLECTIONYEAR CREATIONMETHOD BULKUPLOADID DATAPROTECT OWNINGORGNAME MANINGORGNAME CREATEDBY USERNAME DAY MONTH YEAR PURCHID OWNERSHIP TYPE OTHTYPE COMPANY LIVEINBUYER JOINT JOINTMORE NOINT PRIVACYNOTICE UPRN ADDRESS1 ADDRESS2 TOWNCITY COUNTY POSTCODE ISLAINFERRED LANAME LA UPRNSELECTED ADDRESS_SEARCH_VALUE_CHECK ADDRESS1INPUT POSTCODEINPUT BULKADDRESS1 BULKADDRESS2 BULKTOWNCITY BULKCOUNTY BULKPOSTCODE BULKLA BEDS PROPTYPE BUILTYPE WCHAIR AGE1 SEX1 ETHNICGROUP1 ETHNIC NATIONALITYALL1 ECSTAT1 LIVEINBUYER1 RELAT2 AGE2 SEX2 ETHNICGROUP2 ETHNIC2 NATIONALITYALL2 ECSTAT2 LIVEINBUYER2 HHTYPE RELAT3 AGE3 SEX3 ECSTAT3 RELAT4 AGE4 SEX4 ECSTAT4 RELAT5 AGE5 SEX5 ECSTAT5 RELAT6 AGE6 SEX6 ECSTAT6 PREVTEN PPCODENK PPOSTC1 PPOSTC2 PREVIOUSLAKNOWN PREVLOC PREVLOCNAME PREGYRHA PREGOTHER PREGLA PREGGHB PREGBLANK BUY2LIVING PREVTEN2 HHREGRES HHREGRESSTILL ARMEDFORCESSPOUSE DISABLED WHEEL INC1NK INCOME1 INC1MORT INC2NK INCOME2 INC2MORT HB SAVINGSNK SAVINGS PREVOWN PREVSHARED PROPLEN STAIRCASE STAIRBOUGHT STAIROWNED STAIRCASETOSALE RESALE EXDAY EXMONTH EXYEAR HODAY HOMONTH HOYEAR LANOMAGR SOCTEN FROMBEDS FROMPROP SOCPREVTEN VALUE VALUE_VALUE_CHECK EQUITY MORTGAGEUSED MORTGAGE MORTGAGELENDER MORTGAGELENDEROTHER MORTLEN1 EXTRABOR DEPOSIT CASHDIS MRENT HASMSCHARGE MSCHARGE MSCHARGE_VALUE_CHECK DISCOUNT GRANT
2 in_progress 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 1 false DLUHC DLUHC billyboy@eyeklaud.com billyboy@eyeklaud.com 1 5 2024 2 8 1 1 2 1 Address line 1 Town or city SW1A 1AA false true Barnet Westminster E09000003 E09000033 address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered 2 1 1 1 30 X 17 17 1 1 P 35 X 17 1 1 3 C 14 X 9 X -9 X 3 R -9 R 10 1 0 SW1A 1AA 1 E09000003 E09000033 Barnet Westminster 1 1 1 1 3 1 4 5 1 1 0 10000 1 0 10000 1 4 1 1 2 10 110000.0 1 20000.0 5 10 1 80000.0 1 100.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_labels_23.csv vendored

@ -1,2 +1,2 @@
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,FORM,COLLECTIONYEAR,CREATIONMETHOD,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,BEDS,PROPTYPE,BUILTYPE,UPRN,UPRNCONFIRMED,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,PCODE1,PCODE2,LA,LANAME,WCHAIR,NOINT,PRIVACYNOTICE,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONAL,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONAL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,,,Address line 1,,Town or city,,SW1A,1AA,E09000033,Westminster,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0

1 ID STATUS DUPLICATESET CREATEDDATE UPLOADDATE FORM COLLECTIONYEAR CREATIONMETHOD DATAPROTECT OWNINGORGNAME MANINGORGNAME CREATEDBY USERNAME DAY MONTH YEAR PURCHID OWNERSHIP TYPE OTHTYPE COMPANY LIVEINBUYER JOINT JOINTMORE BEDS PROPTYPE BUILTYPE UPRN UPRNCONFIRMED ADDRESS1 ADDRESS2 TOWNCITY COUNTY PCODE1 PCODE2 LA LANAME WCHAIR NOINT PRIVACYNOTICE AGE1 SEX1 ETHNICGROUP1 ETHNIC NATIONAL ECSTAT1 LIVEINBUYER1 RELAT2 AGE2 SEX2 ETHNICGROUP2 ETHNIC2 NATIONAL2 ECSTAT2 LIVEINBUYER2 HHTYPE RELAT3 AGE3 SEX3 ECSTAT3 RELAT4 AGE4 SEX4 ECSTAT4 RELAT5 AGE5 SEX5 ECSTAT5 RELAT6 AGE6 SEX6 ECSTAT6 PREVTEN PPCODENK PPOSTC1 PPOSTC2 PREVIOUSLAKNOWN PREVLOC PREVLOCNAME PREGYRHA PREGOTHER PREGLA PREGGHB PREGBLANK BUY2LIVING PREVTEN2 HHREGRES HHREGRESSTILL ARMEDFORCESSPOUSE DISABLED WHEEL INC1NK INCOME1 INC1MORT INC2NK INCOME2 INC2MORT HB SAVINGSNK SAVINGS PREVOWN PREVSHARED PROPLEN STAIRCASE STAIRBOUGHT STAIROWNED STAIRCASETOSALE RESALE EXDAY EXMONTH EXYEAR HODAY HOMONTH HOYEAR LANOMAGR SOCTEN FROMBEDS FROMPROP SOCPREVTEN VALUE VALUE_VALUE_CHECK EQUITY MORTGAGEUSED MORTGAGE MORTGAGELENDER MORTGAGELENDEROTHER MORTLEN1 EXTRABOR DEPOSIT CASHDIS MRENT HASMSCHARGE MSCHARGE MSCHARGE_VALUE_CHECK DISCOUNT GRANT
2 completed 2023-12-08T00:00:00+00:00 2024-01-01T00:00:00+00:00 2023 single log false DLUHC DLUHC billyboy@eyeklaud.com billyboy@eyeklaud.com 8 12 2023 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes 2 Flat or maisonette Purpose built Address line 1 Town or city SW1A 1AA E09000003 E09000033 Barnet Westminster Yes Yes 1 30 Non-binary Buyer prefers not to say 17 United Kingdom Full-time - 30 hours or more Yes Partner 35 Non-binary Buyer prefers not to say Buyer prefers not to say Full-time - 30 hours or more Yes 3 Child 14 Non-binary Other Not known Non-binary In government training into work Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant No No 1 1 1 1 Don't know Yes Yes No Yes Yes Yes 10000 Yes Yes 10000 Yes Don’t know No Yes No 10 110000.0 Yes 20000.0 Cambridge Building Society 10 Yes 80000.0 Yes 100.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_labels_24.csv vendored

@ -1,2 +1,2 @@
ID,STATUS,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,Address line 1,,Town or city,,SW1A 1AA,No,Barnet,E09000003,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,Address line 1,,Town or city,,SW1A 1AA,Yes,Westminster,E09000033,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,,10000.0

1 ID STATUS DUPLICATESET CREATEDDATE UPLOADDATE COLLECTIONYEAR CREATIONMETHOD BULKUPLOADID DATAPROTECT OWNINGORGNAME MANINGORGNAME CREATEDBY USERNAME DAY MONTH YEAR PURCHID OWNERSHIP TYPE OTHTYPE COMPANY LIVEINBUYER JOINT JOINTMORE NOINT PRIVACYNOTICE UPRN ADDRESS1 ADDRESS2 TOWNCITY COUNTY POSTCODE ISLAINFERRED LANAME LA UPRNSELECTED ADDRESS_SEARCH_VALUE_CHECK ADDRESS1INPUT POSTCODEINPUT BULKADDRESS1 BULKADDRESS2 BULKTOWNCITY BULKCOUNTY BULKPOSTCODE BULKLA BEDS PROPTYPE BUILTYPE WCHAIR AGE1 SEX1 ETHNICGROUP1 ETHNIC NATIONALITYALL1 ECSTAT1 LIVEINBUYER1 RELAT2 AGE2 SEX2 ETHNICGROUP2 ETHNIC2 NATIONALITYALL2 ECSTAT2 LIVEINBUYER2 HHTYPE RELAT3 AGE3 SEX3 ECSTAT3 RELAT4 AGE4 SEX4 ECSTAT4 RELAT5 AGE5 SEX5 ECSTAT5 RELAT6 AGE6 SEX6 ECSTAT6 PREVTEN PPCODENK PPOSTC1 PPOSTC2 PREVIOUSLAKNOWN PREVLOC PREVLOCNAME PREGYRHA PREGOTHER PREGLA PREGGHB PREGBLANK BUY2LIVING PREVTEN2 HHREGRES HHREGRESSTILL ARMEDFORCESSPOUSE DISABLED WHEEL INC1NK INCOME1 INC1MORT INC2NK INCOME2 INC2MORT HB SAVINGSNK SAVINGS PREVOWN PREVSHARED PROPLEN STAIRCASE STAIRBOUGHT STAIROWNED STAIRCASETOSALE RESALE EXDAY EXMONTH EXYEAR HODAY HOMONTH HOYEAR LANOMAGR SOCTEN FROMBEDS FROMPROP SOCPREVTEN VALUE VALUE_VALUE_CHECK EQUITY MORTGAGEUSED MORTGAGE MORTGAGELENDER MORTGAGELENDEROTHER MORTLEN1 EXTRABOR DEPOSIT CASHDIS MRENT HASMSCHARGE MSCHARGE MSCHARGE_VALUE_CHECK DISCOUNT GRANT
2 in_progress 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 single log false DLUHC DLUHC billyboy@eyeklaud.com billyboy@eyeklaud.com 1 5 2024 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes Yes 1 Address line 1 Town or city SW1A 1AA No Yes Barnet Westminster E09000003 E09000033 address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered 2 Flat or maisonette Purpose built Yes 30 Non-binary Buyer prefers not to say 17 Australia Full-time - 30 hours or more Yes Partner 35 Non-binary Buyer prefers not to say Full-time - 30 hours or more Yes 3 Child 14 Non-binary Child under 16 Other Not known Non-binary In government training into work Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant Yes SW1A 1AA Yes E09000003 E09000033 Barnet Westminster 1 1 1 1 Don't know Yes Yes No Yes Yes Yes 10000 Yes Yes 10000 Yes Don’t know No Yes No 10 110000.0 Yes 20000.0 Cambridge Building Society 10 Yes 80000.0 Yes 100.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_at,updated_at,collection_start_year,creation_method,bulk_upload_id,is_dpo,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,beds,proptype,builtype,wchair,age1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,E09000033,Westminster,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,In government training into work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000033,Westminster,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,Don’t know ,No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0

1 id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo owning_organisation_name managing_organisation_name assigned_to day month year purchid ownershipsch type othtype companybuy buylivein jointpur jointmore noint privacynotice uprn uprn_confirmed address_line1_input postcode_full_input uprn_selection address_line1 address_line2 town_or_city county pcode1 pcode2 la la_label beds proptype builtype wchair age1 sex1 ethnic_group ethnic nationality_all ecstat1 buy1livein relat2 age2 sex2 ethnic_group2 ethnicbuy2 nationality_all_buyer2 ecstat2 buy2livein hholdcount relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 prevten ppcodenk ppostc1 ppostc2 previous_la_known prevloc prevloc_label pregyrha pregother pregla pregghb pregblank buy2living prevtenbuy2 hhregres hhregresstill armedforcesspouse disabled wheel income1nk income1 inc1mort income2nk income2 inc2mort hb savingsnk savings prevown prevshared proplen staircase stairbought stairowned staircasesale resale exday exmonth exyear hoday homonth hoyear lanomagr soctenant frombeds fromprop socprevten value equity mortgageused mortgage mortgagelender mortgagelenderother mortlen extrabor deposit cashdis mrent has_mscharge mscharge discount grant
2 in_progress 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 single log false DLUHC DLUHC billyboy@eyeklaud.com 1 5 2024 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes Yes 1 Address line 1 Town or city SW1A 1AA E09000003 E09000033 Barnet Westminster 2 Flat or maisonette Purpose built Yes 30 Non-binary Buyer prefers not to say 17 Australia Full-time - 30 hours or more Yes Partner 35 Non-binary Buyer prefers not to say Full-time - 30 hours or more Yes 3 Child 14 Non-binary Child under 16 Other Not known Non-binary In government training into work Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant Yes SW1A 1AA Yes E09000003 E09000033 Barnet Westminster 1 1 1 1 Don't know Yes Yes No Yes Yes Yes 10000 Yes Yes 10000 Yes Don’t know No Yes No 10 110000.0 Yes 20000.0 Cambridge Building Society 10 Yes 80000.0 Yes 100.0 10000.0

44
spec/helpers/organisations_helper_spec.rb

@ -3,21 +3,57 @@ require "rails_helper"
RSpec.describe OrganisationsHelper do
include TagHelper
describe "display_organisation_attributes" do
let(:organisation) { create(:organisation) }
let(:organisation) { create(:organisation, skip_rent_period_creation: true) }
it "does not include data protection agreement" do
it "has the correct values" do
expect(display_organisation_attributes(organisation)).to eq(
[{ editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
{ editable: true,
name: "Address",
value: "2 Marsham Street\nLondon\nSW1P 4DF" },
{ editable: true, name: "Telephone number", value: nil },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Registration number", value: "1234" },
{ editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Owns housing stock", value: "Yes" },
{ editable: true, format: :bullet, name: "Rent periods", value: [] },
{ name: "Data Sharing Agreement" },
{ editable: false, name: "Status", value: status_tag(organisation.status) }],
)
end
end
describe "rent_periods_with_checked_attr" do
let(:fake_rent_periods) do
{
"1" => { "value" => "Every minute" },
"2" => { "value" => "Every decade" },
}
end
before do
allow(RentPeriod).to receive(:rent_period_mappings).and_return fake_rent_periods
end
it "returns rent_period_mappings" do
actual = rent_periods_with_checked_attr
expect(actual.keys).to eq RentPeriod.rent_period_mappings.keys
end
context "when checked_periods is nil" do
it "returns all rent periods with checked true" do
actual = rent_periods_with_checked_attr
checked_attrs = actual.values.map { |p| p[:checked] }
expect(checked_attrs).to all be true
end
end
context "when checked_periods is not nil" do
it "returns the rent_periods with the correct values checked" do
checked_rent_period = "1"
actual = rent_periods_with_checked_attr(checked_periods: [checked_rent_period])
expect(actual[checked_rent_period][:checked]).to be true
expect(actual["2"][:checked]).to be_falsey
end
end
end
end

1144
spec/models/lettings_log_derived_fields_spec.rb

File diff suppressed because it is too large Load Diff

1942
spec/models/lettings_log_spec.rb

File diff suppressed because it is too large Load Diff

2
spec/models/location_spec.rb

@ -9,7 +9,7 @@ RSpec.describe Location, type: :model do
let(:location) { FactoryBot.build(:location) }
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
stub_request(:get, /api.postcodes.io\/postcodes\/CA101AA/)

67
spec/models/organisation_spec.rb

@ -108,32 +108,63 @@ RSpec.describe Organisation, type: :model do
end
end
context "when the organisation only uses specific rent periods" do
let(:rent_period_mappings) do
{ "2" => { "value" => "Weekly for 52 weeks" }, "3" => { "value" => "Every 2 weeks" } }
context "with associated rent periods" do
let(:organisation) { create(:organisation, skip_rent_period_creation: true) }
let(:period_1_label) { "Every minute" }
let(:fake_rent_periods) do
{
"1" => { "value" => period_1_label },
"2" => { "value" => "Every decade" },
}
end
before do
create(:organisation_rent_period, organisation:, rent_period: 2)
create(:organisation_rent_period, organisation:, rent_period: 3)
# Unmapped and ignored by `rent_period_labels`
create(:organisation_rent_period, organisation:, rent_period: 10)
allow(RentPeriod).to receive(:rent_period_mappings).and_return(rent_period_mappings)
create(:organisation_rent_period, organisation:, rent_period: 1)
allow(RentPeriod).to receive(:rent_period_mappings).and_return(fake_rent_periods)
end
it "has rent periods associated" do
expect(organisation.rent_periods).to eq([2, 3, 10])
end
context "when the org does not use all rent periods" do
it "#rent_periods returns the correct ids" do
expect(organisation.rent_periods).to eq [1]
end
it "#rent_period_labels returns the correct labels" do
expect(organisation.rent_period_labels).to eq [period_1_label]
end
context "and has organisation rent periods associated for rent periods that no longer appear in the form" do
before do
create(:organisation_rent_period, organisation:, rent_period: 3)
end
it "maps the rent periods to display values" do
expect(organisation.rent_period_labels).to eq(["Weekly for 52 weeks", "Every 2 weeks"])
it "#rent_period_labels returns the correct labels" do
expect(organisation.rent_period_labels).to eq [period_1_label]
end
end
end
end
context "when the organisation has not specified which rent periods it uses" do
it "displays `all`" do
expect(organisation.rent_period_labels).to eq(%w[All])
context "when the org uses all rent periods" do
before do
create(:organisation_rent_period, organisation:, rent_period: 2)
end
it "#rent_periods returns the correct ids" do
expect(organisation.rent_periods).to eq [1, 2]
end
it "#rent_period_labels returns All" do
expect(organisation.rent_period_labels).to eq %w[All]
end
context "and has organisation rent periods associated for rent periods that no longer appear in the form" do
before do
create(:organisation_rent_period, organisation:, rent_period: 3)
end
it "#rent_period_labels returns All" do
expect(organisation.rent_period_labels).to eq %w[All]
end
end
end
end

4
spec/models/sales_log_spec.rb

@ -535,7 +535,7 @@ RSpec.describe SalesLog, type: :model do
context "when saving addresses" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end
@ -820,7 +820,7 @@ RSpec.describe SalesLog, type: :model do
end
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end

29
spec/models/validations/financial_validations_spec.rb

@ -139,23 +139,34 @@ RSpec.describe Validations::FinancialValidations do
end
describe "rent period validations" do
let(:organisation) { FactoryBot.create(:organisation) }
let(:user) { FactoryBot.create(:user) }
let(:record) { FactoryBot.create(:lettings_log, owning_organisation: user.organisation, managing_organisation: organisation, assigned_to: user) }
let(:organisation) { create(:organisation, skip_rent_period_creation: true) }
let(:user) { create(:user, organisation:) }
let(:record) { create(:lettings_log, owning_organisation: organisation, managing_organisation: organisation, assigned_to: user) }
let(:used_period) { 2 }
before do
FactoryBot.create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: organisation)
FactoryBot.create(:organisation_rent_period, organisation:, rent_period: 2)
create(:organisation_rent_period, organisation:, rent_period: used_period)
record.period = period
end
context "when the organisation only uses specific rent periods" do
it "validates that the selected rent period is used by the managing organisation" do
record.period = 3
context "when the log uses a period that the org allows" do
let(:period) { used_period }
it "does not apply a validation" do
financial_validator.validate_rent_period(record)
expect(record.errors["period"]).to be_empty
end
end
context "when the log uses a period that the org does not allow" do
let(:period) { used_period + 1 }
it "does apply a validation" do
financial_validator.validate_rent_period(record)
expect(record.errors["period"])
.to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org",
org_name: organisation.name,
org_name: user.organisation.name,
rent_period: "every 4 weeks",
))
end

4
spec/request_helper.rb

@ -3,7 +3,7 @@ require "webmock/rspec"
module RequestHelper
def self.stub_http_requests
WebMock.disable_net_connect!(allow_localhost: true)
WebMock.stub_request(:get, /api.postcodes.io/)
WebMock.stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})
WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA11AA")
@ -14,6 +14,8 @@ module RequestHelper
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"NW1L 5DP\",\"admin_district\":\"Westminster\",\"codes\":{\"admin_district\":\"E09000033\"}}}", headers: {})
WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/ZZ11ZZ")
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"ZZ1 1ZZ\",\"admin_district\":\"Westminster\",\"codes\":{\"admin_district\":\"E09000033\"}}}", headers: {})
WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/SW1A1AA")
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"postcode\":\"ZZ1 1ZZ\",\"admin_district\":\"Westminster\",\"codes\":{\"admin_district\":\"E09000033\"}}}", headers: {})
WebMock.stub_request(:post, /api.notifications.service.gov.uk\/v2\/notifications\/email/)
.to_return(status: 200, body: "", headers: {})

119
spec/requests/OrganisationsController/organisations_controller_rent_periods_spec.rb

@ -0,0 +1,119 @@
require "rails_helper"
RSpec.describe OrganisationsController, type: :request do
let(:user) { create(:user, :support) }
let(:headers) { { "Accept" => "text/html" } }
let(:page) { Capybara::Node::Simple.new(response.body) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
describe "#new" do
before do
get new_organisation_path
end
it "displays the rent periods question" do
expect(page).to have_content "What are the rent periods for the organisation?"
end
it "the checkboxes for each rent period are checked by default" do
checkboxes = page.all "input[type='checkbox'][name='organisation[rent_periods][]']"
expect(checkboxes.count).to be > 5
expect(checkboxes.all? { |box| box[:checked] }).to be true
end
end
describe "#create" do
let(:org_name) { "abode team" }
let(:expected_rent_periods) { [1, 2, 3] }
let(:params) do
{
"organisation": {
name: org_name,
provider_type: "LA",
rent_periods: expected_rent_periods,
},
}
end
before do
post organisations_path headers:, params:
end
it "creates organisation rent periods with the correct rent period and organisation id" do
org = Organisation.includes(:organisation_rent_periods).find_by_name(org_name)
org_rent_periods = org.organisation_rent_periods
expect(org_rent_periods.count).to be expected_rent_periods.count
expect(org_rent_periods.map(&:rent_period)).to match_array expected_rent_periods
expect(org_rent_periods.map(&:organisation_id)).to all be org.id
end
end
describe "#edit" do
let(:organisation) { create(:organisation, skip_rent_period_creation: true) }
let(:fake_rent_periods) do
{
"1" => { "value" => "Every minute" },
"2" => { "value" => "Every decade" },
}
end
let(:checked_rent_period_id) { "1" }
before do
allow(RentPeriod).to receive(:rent_period_mappings).and_return fake_rent_periods
create(:organisation_rent_period, organisation:, rent_period: checked_rent_period_id)
get edit_organisation_path organisation
end
it "displays the rent periods question" do
expect(page).to have_content "What are the rent periods for the organisation?"
end
it "the checkboxes for each rent period are checked where appropriate" do
checkboxes = page.all "input[type='checkbox']"
expect(checkboxes.count).to be 2
expected_checked_checkbox = checkboxes.find { |cb| cb[:value] == checked_rent_period_id }
expect(expected_checked_checkbox[:checked]).to be true
expected_not_checked_checkbox = checkboxes.find { |cb| cb[:value] != checked_rent_period_id }
expect(expected_not_checked_checkbox[:checked]).to be false
end
end
describe "#update" do
let(:organisation) { create(:organisation, skip_rent_period_creation: true) }
let(:initially_checked_rent_period_id) { "1" }
let(:initially_unchecked_rent_period_id) { "2" }
let(:params) do
{
"organisation": {
name: organisation.name,
rent_periods: [initially_unchecked_rent_period_id],
all_rent_periods: [initially_unchecked_rent_period_id, initially_checked_rent_period_id],
},
}
end
before do
create(:organisation_rent_period, organisation:, rent_period: initially_checked_rent_period_id)
end
it "creates and destroys organisation rent periods as appropriate" do
rent_periods = Organisation.includes(:organisation_rent_periods)
.find(organisation.id)
.organisation_rent_periods
expect(rent_periods.count).to be 1
expect(rent_periods.first.rent_period.to_s).to eq initially_checked_rent_period_id
patch organisation_path(organisation, headers:, params:)
rent_periods = Organisation.includes(:organisation_rent_periods)
.find(organisation.id)
.organisation_rent_periods
expect(rent_periods.count).to be 1
expect(rent_periods.first.rent_period.to_s).to eq initially_unchecked_rent_period_id
end
end
end

2
spec/requests/lettings_logs_controller_spec.rb

@ -1319,7 +1319,7 @@ RSpec.describe LettingsLogsController, type: :request do
Singleton.__init__(FormHandler)
completed_lettings_log.update!(startdate: Time.zone.local(2021, 4, 1), voiddate: Time.zone.local(2021, 4, 1), mrcdate: Time.zone.local(2021, 4, 1))
Timecop.unfreeze
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
sign_in user
end

36
spec/requests/organisations_controller_spec.rb

@ -7,7 +7,8 @@ RSpec.describe OrganisationsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { create(:user, :data_coordinator) }
let(:new_value) { "Test Name 35" }
let(:params) { { id: organisation.id, organisation: { name: new_value } } }
let(:active) { nil }
let(:params) { { id: organisation.id, organisation: { name: new_value, active:, rent_periods: [], all_rent_periods: [] } } }
before do
Timecop.freeze(Time.zone.local(2024, 3, 1))
@ -581,12 +582,7 @@ RSpec.describe OrganisationsController, type: :request do
end
context "with active parameter true" do
let(:params) do
{
id: organisation.id,
organisation: { active: "true" },
}
end
let(:active) { true }
it "redirects" do
expect(response).to have_http_status(:unauthorized)
@ -594,12 +590,7 @@ RSpec.describe OrganisationsController, type: :request do
end
context "with active parameter false" do
let(:params) do
{
id: organisation.id,
organisation: { active: "false" },
}
end
let(:active) { false }
it "redirects" do
expect(response).to have_http_status(:unauthorized)
@ -705,6 +696,7 @@ RSpec.describe OrganisationsController, type: :request do
provider_type: "LA",
holds_own_stock: "true",
housing_registration_no: "7917937",
rent_periods: [],
},
}
end
@ -1329,7 +1321,7 @@ RSpec.describe OrganisationsController, type: :request do
end
it "allows to edit the organisation details" do
expect(page).to have_link("Change", count: 3)
expect(page).to have_link("Change")
end
end
@ -1434,8 +1426,10 @@ RSpec.describe OrganisationsController, type: :request do
end
describe "#update" do
let(:params) { { id: organisation.id, organisation: { active:, rent_periods: [], all_rent_periods: [] } } }
context "with active parameter false" do
let(:params) { { id: organisation.id, organisation: { active: "false" } } }
let(:active) { false }
user_to_update = nil
@ -1455,15 +1449,9 @@ RSpec.describe OrganisationsController, type: :request do
user_to_reactivate = nil
user_not_to_reactivate = nil
let(:params) do
{
id: organisation.id,
organisation: { active: "true" },
}
end
let(:notify_client) { instance_double(Notifications::Client) }
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:active) { true }
let(:expected_personalisation) do
{
name: user_to_reactivate.name,
@ -1547,6 +1535,7 @@ RSpec.describe OrganisationsController, type: :request do
provider_type:,
holds_own_stock:,
housing_registration_no:,
rent_periods: [],
},
}
end
@ -1569,7 +1558,8 @@ RSpec.describe OrganisationsController, type: :request do
it "redirects to the organisation list" do
request
expect(response).to redirect_to("/organisations")
organisation = Organisation.find_by(housing_registration_no:)
expect(response).to redirect_to organisation_path(organisation)
end
context "when required params are missing" do

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -84,7 +84,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
parser.valid?

2
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -232,7 +232,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
parser.valid?

8
spec/services/csv/sales_log_csv_service_spec.rb

@ -160,13 +160,13 @@ RSpec.describe Csv::SalesLogCsvService do
it "exports the code for the local authority under the heading 'la'" do
la_column_index = csv.first.index("LA")
la_value = csv.second[la_column_index]
expect(la_value).to eq "E09000003"
expect(la_value).to eq "E09000033"
end
it "exports the label for the local authority under the heading 'la_label'" do
la_label_column_index = csv.first.index("LANAME")
la_label_value = csv.second[la_label_column_index]
expect(la_label_value).to eq "Barnet"
expect(la_label_value).to eq "Westminster"
end
context "when the requested form is 2024" do
@ -246,13 +246,13 @@ RSpec.describe Csv::SalesLogCsvService do
it "exports the code for the local authority under the heading 'la'" do
la_column_index = csv.first.index("LA")
la_value = csv.second[la_column_index]
expect(la_value).to eq "E09000003"
expect(la_value).to eq "E09000033"
end
it "exports the label for the local authority under the heading 'la_label'" do
la_label_column_index = csv.first.index("LANAME")
la_label_value = csv.second[la_label_column_index]
expect(la_label_value).to eq "Barnet"
expect(la_label_value).to eq "Westminster"
end
context "when the requested form is 2024" do

6
spec/services/merge/merge_organisations_service_spec.rb

@ -75,6 +75,9 @@ RSpec.describe Merge::MergeOrganisationsService do
end
context "and merging organisation rent periods" do
let(:absorbing_organisation) { create(:organisation, holds_own_stock: false, name: "absorbing org", skip_rent_period_creation: true) }
let(:merging_organisation) { create(:organisation, holds_own_stock: true, name: "fake org", skip_rent_period_creation: true) }
before do
OrganisationRentPeriod.create!(organisation: absorbing_organisation, rent_period: 1)
OrganisationRentPeriod.create!(organisation: absorbing_organisation, rent_period: 3)
@ -1157,6 +1160,9 @@ RSpec.describe Merge::MergeOrganisationsService do
end
context "and merging organisation rent periods" do
let(:new_absorbing_organisation) { create(:organisation, :without_dpc, holds_own_stock: false, skip_rent_period_creation: true) }
let(:merging_organisation) { create(:organisation, holds_own_stock: true, name: "fake org", skip_rent_period_creation: true) }
before do
OrganisationRentPeriod.create!(organisation: new_absorbing_organisation, rent_period: 1)
OrganisationRentPeriod.create!(organisation: new_absorbing_organisation, rent_period: 3)

5
spec/views/organisations/show.html.erb_spec.rb

@ -2,15 +2,10 @@ require "rails_helper"
RSpec.describe "organisations/show.html.erb" do
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
allow(view).to receive(:current_user).and_return(user)
assign(:organisation, user.organisation)
end
after do
Timecop.return
end
let(:fragment) { Capybara::Node::Simple.new(rendered) }
let(:organisation_without_dpc) { create(:organisation, :without_dpc) }
let(:organisation_with_dsa) { create(:organisation) }

Loading…
Cancel
Save