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.

50 lines
2.3 KiB

CLDC-2810 Send missing addresses template (#1952) * Add missing addresses csv job * Update missing addresses csv service methods * Add rake task * Update the job to send missing town or city templates * Update service to create mising town or city templates * Add send missing town or city csv rake task * Add IDs to the CSVs * Put all log in the same csv * Add issue type column * Write wrong uprn logs to csv * Add mailer methods * Skip uprn issue for specified orgs * Add sales csv rake task * set SKIP_UPRN_ISSUE_ORG_IDS on review apps * test * Update notify template IDs for testing * Initialize service with organisation instead of a hash * Add expiration time to url * Add optional tags and remove LA from csv * Extract log to csv methods * Update casing * Update old IDs in factories * Move constant * Extract some repeating scopes * Pass in organisations to skip instead of using an env var * update template id for sales * Update link expiry time and headers * Lower the threshold for testing * Add issue explanation to the email * Add how to fix * update emails * CLDC-2810 Create all addresses CSV (#1953) * Add rake tasks for creating all addresses CSV * Write headers if logs don't exist, update header names * Rename method * CLDC-2810 Correct addresses from csv (#1957) * Updating importing lettings addresses form csv * Add import_sales_addresses_from_csv rake * Allow correcting addresses from both templates * escape . * Reinfer LA if the postcode hasn't changed * Update labels and email content * Update missing addresses threshold * Remove unused env var
1 year ago
require "rails_helper"
describe CreateAddressesCsvJob do
include Helpers
let(:job) { described_class.new }
let(:storage_service) { instance_double(Storage::S3Service) }
let(:mailer) { instance_double(CsvDownloadMailer) }
let(:missing_addresses_csv_service) { instance_double(Csv::MissingAddressesCsvService) }
let(:organisation) { build(:organisation) }
let(:users) { create_list(:user, 2) }
before do
allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(storage_service).to receive(:write_file)
allow(Csv::MissingAddressesCsvService).to receive(:new).and_return(missing_addresses_csv_service)
allow(missing_addresses_csv_service).to receive(:create_lettings_addresses_csv).and_return("")
allow(missing_addresses_csv_service).to receive(:create_sales_addresses_csv).and_return("")
end
context "when sending all lettings logs csv" do
it "uses an appropriate filename in S3" do
expect(storage_service).to receive(:write_file).with(/lettings-logs-addresses-#{organisation.name}-.*\.csv/, anything)
expect(Rails.logger).to receive(:info).with(/Created addresses file: lettings-logs-addresses-#{organisation.name}-.*\.csv/)
job.perform(organisation, "lettings")
end
it "creates a MissingAddressesCsvService with the correct organisation and calls create all lettings logs adresses csv" do
expect(Csv::MissingAddressesCsvService).to receive(:new).with(organisation, [])
expect(missing_addresses_csv_service).to receive(:create_lettings_addresses_csv)
job.perform(organisation, "lettings")
end
end
context "when sending all sales logs csv" do
it "uses an appropriate filename in S3" do
expect(storage_service).to receive(:write_file).with(/sales-logs-addresses-#{organisation.name}-.*\.csv/, anything)
expect(Rails.logger).to receive(:info).with(/Created addresses file: sales-logs-addresses-#{organisation.name}-.*\.csv/)
job.perform(organisation, "sales")
end
it "creates a MissingAddressesCsvService with the correct organisation and calls create all sales logs adresses csv" do
expect(Csv::MissingAddressesCsvService).to receive(:new).with(organisation, [])
expect(missing_addresses_csv_service).to receive(:create_sales_addresses_csv)
job.perform(organisation, "sales")
end
end
end