Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
11 KiB

require "rails_helper"
RSpec.describe Csv::LettingsLogCsvService do
context "when the user is support" do
let(:user) { FactoryBot.create(:user, :support) }
let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json") }
before do
CLDC-1917 Add Startdate Validation (#1378) * feat: add validation with feature flag, typo fix and update tests * feat: flip feature toggle * feat: update feature toggle name * feat: fix form handler inequality * refactor: linting * refactor: use between in form handler * feat: remove feature toggle * feat: add dynamic date to lettings log factory * feat: fix log_summary_component_spec.rb tests * feat: update lettings_log.rb and start fixing lettings_log_spec.rb * feat: fix more tests * feat: fix more tests * feat: fix lettings log import service * refactor: linting * feat: fix checkboxes_spec.rb * feat: fix interruption_screen_helper_spec.rb * feat: fix check_answers_helper_spec.rb * feat: fix page_routing_spec.rb * feat: fix lettings_logs_field_import_service_spec.rb * feat: fix lettings_log_spec.rb * feat: fix question_spec.rb * feat: fix lettings_logs_controller_spec.rb * feat: fix check_answers_page_lettings_logs_spec.rb * feat: fix tenancy_validations_spec.rb * feat: fix validations_spec.rb * feat: fix accessible_autocomplete_spec.rb * feat: fix form_navigation_spec.rb * feat: fix soft_validations_spec.rb * feat: fix lettings_log_export_service_spec.rb * feat: fix saving_data_spec.rb * feat: fix page_spec.rb * feat: fix form_controller_spec.rb * refactor: linting * feat: fix subsection_spec.rb * feat: fix lettings_log_spec.rb * feat: fix financial_validations_spec.rb * feat: fix tasklist_page_spec.rb * feat: fix conditional_questions_spec.rb * feat: fix form_page_error_helper_spec.rb and log_summary_component_spec.rb * feat: fix lettings_log_csv_service_spec.rb * feat: fix tasklist_helper_spec.rb * refactor: linting * refactor: linting * feat: fix lettings_log_spec.rb * refactor: linting * refactor: replace financial year with collection yaer * feat: respond to PR comments pt. 1 * feat: respond to PR comments pt. 2
2 years ago
LettingsLog.create!(startdate: Time.zone.today, created_at: Time.utc(2022, 2, 8, 16, 52, 15))
allow(FormHandler.instance).to receive(:get_form).and_return(real_2021_2022_form)
end
it "sets csv attributes in correct order" do
expected_csv_attributes = %w[id
status
created_at
updated_at
created_by_name
is_dpo
owning_organisation_name
managing_organisation_name
collection_start_year
needstype
renewal
startdate
rent_type_detail
irproduct_other
tenancycode
propcode
postcode_known
postcode_full
is_la_inferred
la_label
la
first_time_property_let_as_social_housing
unitletas
rsnvac
offered
unittype_gn
builtype
wchair
beds
voiddate
void_date_value_check
majorrepairs
mrcdate
major_repairs_date_value_check
startertenancy
tenancy
tenancyother
tenancylength
sheltered
declaration
hhmemb
pregnancy_value_check
age1_known
age1
sex1
ethnic_group
ethnic
national
ecstat1
retirement_value_check
details_known_2
relat2
age2_known
age2
sex2
ecstat2
details_known_3
relat3
age3_known
age3
sex3
ecstat3
details_known_4
relat4
age4_known
age4
sex4
ecstat4
details_known_5
relat5
age5_known
age5
sex5
ecstat5
details_known_6
relat6
age6_known
age6
sex6
ecstat6
details_known_7
relat7
age7_known
age7
sex7
ecstat7
details_known_8
relat8
age8_known
age8
sex8
ecstat8
armedforces
leftreg
reservist
preg_occ
housingneeds
housingneeds_type
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
underoccupation_benefitcap
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_unknown
referral
net_income_known
earnings
incfreq
net_income_value_check
hb
benefits
household_charge
period
is_carehome
chcharge
brent
scharge
pscharge
supcharg
tcharge
rent_value_check
hbrentshortfall
tshortfall_known
tshortfall
housingneeds_a
housingneeds_b
housingneeds_c
housingneeds_f
housingneeds_g
housingneeds_h
property_owner_organisation
property_manager_organisation
purchaser_code
property_relet
incref
renttype
lettype
totchild
totelder
totadult
nocharge
has_benefits
wrent
wscharge
wpschrge
wsupchrg
wtcharge
wtshortfall
refused
wchchrg
newprop
old_form_id
lar
irproduct
old_id
joint
hhtype
new_old
vacdays
unresolved
updated_by_id
uprn
uprn_known
uprn_confirmed
address_line1
address_line2
town_or_city
county
unittype_sh
scheme_code
scheme_service_name
scheme_sensitive
scheme_type
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_admin_district
location_startdate]
CLDC-1826 lettings log codes only download (#1268) * update seeds to add self in review env, change spec to reflect this, update config yml to allow csv exports in review * update interface of relevant methods EmailCsvJob, LettingsLog.to_csv and LettingsLogCsvService consume codes_only flag * update tests including adding a new csv file to test against * update LettingsLogCsvService to output codes only csv * correct minor error and linting * enable codes only download in UI - add link on lettings log index page - pass codes_only flag through params in relevant links and methods - convert flag to boolean in controller methods * ensure link displayed successfully for all renderings of logs_list and params passed through relevant methods in organisations controller * fix existing tests * correct linting thing * correct linting error * update tests for lettings log controller * correct linting errors * update organisations controller tests * make minor changes after code review * remove changes made for testing on review app * make codes only download visible to support users only * change variable names throughout after info on rauby/rails naming conventions, update tests for change in who can view codes only download link * rework csv service for readability, remove delegating methods from lettings log to keep all code to do with mapping between our domain and desired export format in one place * update test name * correct a small typo and remove a duplicated method after clever git merge conflict suggestion * point review app at staging csv bucket for csv download * change variables named codes_only_export to codes_only to avoid inconsistency * write tests to ensure that differetn user roles have the correct permissions around csv download * ensure that non support users may not download codes only exports * correct a small error in a previous commit * correct minor linting error
2 years ago
csv = CSV.parse(described_class.new(user, export_type: "labels").to_csv)
expect(csv.first).to eq(expected_csv_attributes)
end
end
end