Browse Source

make minor changes after code review

pull/1268/head
Arthur Campbell 3 years ago
parent
commit
560953f434
  1. 6
      app/services/csv/lettings_log_csv_service.rb
  2. 8
      spec/models/lettings_log_spec.rb

6
app/services/csv/lettings_log_csv_service.rb

@ -32,12 +32,12 @@ module Csv
else
att = att.remove("_label", "_detail") # a couple of csv column headers have suffixes for the user that are not reflected in the app domain
field_value = record.send(att)
answer_label = record.form
.get_question(att, record)
&.label_from_value(field_value)
if is_codes_only_export
field_value
else
answer_label = record.form
.get_question(att, record)
&.label_from_value(field_value)
answer_label || label_if_boolean_value(field_value) || field_value
end
end

8
spec/models/lettings_log_spec.rb

@ -2705,14 +2705,13 @@ RSpec.describe LettingsLog do
expected_content.sub!(/\{location_startdate\}/, location["startdate"].to_s)
expected_content.sub!(/\{scheme_id\}/, scheme["service_name"].to_s)
expected_content.sub!(/\{location_id\}/, location["id"].to_s)
expected_content.gsub!("\r\n", "\n")
end
context "with a support user" do
let(:csv_export_file) { File.open("spec/fixtures/files/lettings_logs_download.csv", "r:UTF-8") }
it "generates a correct csv from a lettings log" do
expect(described_class.to_csv(is_codes_only_export: false).strip).to eq(expected_content.strip)
expect(described_class.to_csv(is_codes_only_export: false)).to eq(expected_content)
end
end
@ -2720,7 +2719,7 @@ RSpec.describe LettingsLog do
let(:csv_export_file) { File.open("spec/fixtures/files/lettings_logs_download_non_support.csv", "r:UTF-8") }
it "generates a correct csv from a lettings log" do
expect(described_class.to_csv(user, is_codes_only_export: false).strip).to eq(expected_content.strip)
expect(described_class.to_csv(user, is_codes_only_export: false)).to eq(expected_content)
end
end
end
@ -2741,13 +2740,12 @@ RSpec.describe LettingsLog do
expected_content.sub!(/\{location_startdate\}/, location.startdate.to_s)
expected_content.sub!(/\{scheme_id\}/, scheme.service_name.to_s)
expected_content.sub!(/\{location_id\}/, location.id.to_s)
expected_content.gsub!("\r\n", "\n")
end
let(:csv_export_file) { File.open("spec/fixtures/files/lettings_logs_download_codes_only.csv", "r:UTF-8") }
it "generates a correct csv from a lettings log" do
expect(described_class.to_csv(is_codes_only_export: true).strip).to eq(expected_content.strip)
expect(described_class.to_csv(is_codes_only_export: true)).to eq(expected_content)
end
end
end

Loading…
Cancel
Save