Browse Source

correct minor error and linting

pull/1268/head
Arthur Campbell 3 years ago
parent
commit
c7c63f6333
  1. 2
      app/jobs/email_csv_job.rb
  2. 6
      app/services/csv/lettings_log_csv_service.rb
  3. 12
      spec/models/lettings_log_spec.rb

2
app/jobs/email_csv_job.rb

@ -12,7 +12,7 @@ class EmailCsvJob < ApplicationJob
filename = organisation.present? ? "logs-#{organisation.name}-#{Time.zone.now}.csv" : "logs-#{Time.zone.now}.csv"
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"])
storage_service.write_file(filename, BYTE_ORDER_MARK + filtered_logs.to_csv(user, is_codes_only_export))
storage_service.write_file(filename, BYTE_ORDER_MARK + filtered_logs.to_csv(user, is_codes_only_export:))
url = storage_service.get_presigned_url(filename, EXPIRATION_TIME)

6
app/services/csv/lettings_log_csv_service.rb

@ -26,9 +26,9 @@ module Csv
record.send(att)
elsif %w[mrcdate startdate voiddate].include? att
record.send(att)&.to_formatted_s(:govuk_date)
elsif is_codes_only_export && (att.start_with?("location_", "scheme_"))
att = att + "_before_type_cast" unless %w[location_code scheme_code scheme_owning_organisation_name scheme_created_at location_startdate].include? att
value = record.send(att)
elsif is_codes_only_export && att.start_with?("location_", "scheme_")
att += "_before_type_cast" unless %w[location_code scheme_code scheme_owning_organisation_name scheme_created_at location_startdate].include? att
record.send(att)
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)

12
spec/models/lettings_log_spec.rb

@ -2688,7 +2688,7 @@ RSpec.describe LettingsLog do
after do
Timecop.unfreeze
end
context "with values represented as human readable labels" do
before do
Timecop.freeze(Time.utc(2022, 6, 5))
@ -2707,18 +2707,18 @@ RSpec.describe LettingsLog do
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)
end
end
context "with a non support user" 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)
end
@ -2743,7 +2743,7 @@ RSpec.describe LettingsLog do
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

Loading…
Cancel
Save