Browse Source

CLDC-4173: update sales export spec and make sales log csv service future-proof

pull/3186/head
Nat Dean-Lewis 4 weeks ago
parent
commit
52f0103691
  1. 6
      app/services/csv/sales_log_csv_service.rb
  2. 6
      spec/fixtures/files/sales_logs_csv_export_codes_26.csv
  3. 6
      spec/fixtures/files/sales_logs_csv_export_labels_26.csv
  4. 5
      spec/services/csv/sales_log_csv_service_spec.rb

6
app/services/csv/sales_log_csv_service.rb

@ -249,7 +249,7 @@ module Csv
return @attributes unless @user.support?
mappings = SUPPORT_ATTRIBUTE_NAME_MAPPINGS
mappings = mappings.merge(SUPPORT_ATTRIBUTE_NAME_MAPPINGS_2025) if @year == 2025
mappings = mappings.merge(SUPPORT_ATTRIBUTE_NAME_MAPPINGS_2025) if @year >= 2025
@attributes.map do |attribute|
mappings[attribute] || attribute.upcase
@ -300,7 +300,7 @@ module Csv
mappings = case @year
when 2024
ATTRIBUTE_MAPPINGS.merge(ATTRIBUTE_MAPPINGS_2024)
when 2025
when (2025..)
ATTRIBUTE_MAPPINGS.merge(ATTRIBUTE_MAPPINGS_2024).merge(ATTRIBUTE_MAPPINGS_2025)
else
ATTRIBUTE_MAPPINGS
@ -346,7 +346,7 @@ module Csv
%w[id status duplicate_set_id created_at updated_at old_form_id collection_start_year creation_method is_dpo]
when 2024
%w[id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo]
when 2025
when 2025, 2026
%w[id status duplicate_set_id created_at created_by_id updated_at updated_by_id creation_method bulk_upload_id]
else
%w[id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo]

6
spec/fixtures/files/sales_logs_csv_export_codes_26.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/sales_logs_csv_export_labels_26.csv vendored

File diff suppressed because one or more lines are too long

5
spec/services/csv/sales_log_csv_service_spec.rb

@ -21,17 +21,22 @@ RSpec.describe Csv::SalesLogCsvService do
purchid: nil,
hholdcount: 3,
age1: 30,
sexrab1: "F",
sex1: "X",
age2: 35,
sexrab2: "M",
sex2: "X",
sexrab3: "F",
sex3: "X",
age4_known: 1,
sexrab4: "R",
sex4: "X",
details_known_5: 2,
age6_known: nil,
age6: nil,
ecstat6: nil,
relat6: nil,
sexrab6: nil,
sex6: nil,
town_or_city: "Town or city",
address_line1_as_entered: "address line 1 as entered",

Loading…
Cancel
Save