From c7c63f6333a1425f7987b15eab1e3e17bde3664d Mon Sep 17 00:00:00 2001 From: Arthur Campbell Date: Thu, 9 Feb 2023 10:35:52 +0000 Subject: [PATCH] correct minor error and linting --- app/jobs/email_csv_job.rb | 2 +- app/services/csv/lettings_log_csv_service.rb | 6 +++--- spec/models/lettings_log_spec.rb | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/jobs/email_csv_job.rb b/app/jobs/email_csv_job.rb index 235cb072c..f67ab1cdc 100644 --- a/app/jobs/email_csv_job.rb +++ b/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) diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index 30bdb6360..82ba9507d 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/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) diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 9713e5006..9a4cf94ad 100644 --- a/spec/models/lettings_log_spec.rb +++ b/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