|
|
|
|
@ -67,4 +67,35 @@ RSpec.describe Imports::ImportReportService do
|
|
|
|
|
report_service.generate_logs_report("report_suffix.csv") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#generate_unassigned_logs_report" do |
|
|
|
|
context "when there is no unassigned user (all the logs have ben assigned)" do |
|
|
|
|
let(:institutions_csv) { CSV.parse("Institution name,Id,Old Completed lettings logs,Old In progress lettings logs,Old Completed sales logs,Old In progress sales logs\norg1,1,2,1,4,3", headers: true) } |
|
|
|
|
|
|
|
|
|
it "writes an empty unassigned logs report" do |
|
|
|
|
expect(storage_service).to receive(:write_file).with("UnassignedLogsReport_report_suffix.csv", "\uFEFFOwning Organisation ID,Old Owning Organisation ID,Managing Organisation ID,Old Managing Organisation ID,Log ID,Old Log ID,Tenancy code,Purchaser code\n") |
|
|
|
|
|
|
|
|
|
report_service.generate_unassigned_logs_report("report_suffix.csv") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when some logs have been added to Unassigned user" do |
|
|
|
|
let(:organisation) { create(:organisation, old_org_id: "1", name: "org1") } |
|
|
|
|
let(:organisation2) { create(:organisation, old_org_id: "2", name: "org2") } |
|
|
|
|
let(:unassigned_user) { create(:user, name: "Unassigned", organisation:) } |
|
|
|
|
let(:institutions_csv) { CSV.parse("Institution name,Id,Old Completed lettings logs,Old In progress lettings logs,Old Completed sales logs,Old In progress sales logs\norg1,1,2,1,4,3", headers: true) } |
|
|
|
|
let!(:lettings_log) { create(:lettings_log, owning_organisation: organisation, managing_organisation: organisation2, created_by: unassigned_user, tenancycode: "tenancycode", old_id: "12") } |
|
|
|
|
let!(:sales_log) { create(:sales_log, owning_organisation: organisation, created_by: unassigned_user, purchid: "purchid", old_id: "23") } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
create(:organisation_relationship, parent_organisation: organisation, child_organisation: organisation2) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "writes a report with all unassigned logs" do |
|
|
|
|
expect(storage_service).to receive(:write_file).with("UnassignedLogsReport_report_suffix.csv", "\uFEFFOwning Organisation ID,Old Owning Organisation ID,Managing Organisation ID,Old Managing Organisation ID,Log ID,Old Log ID,Tenancy code,Purchaser code\n#{organisation.id},1,#{organisation2.id},2,#{lettings_log.id},12,tenancycode,\n#{organisation.id},1,,,#{sales_log.id},23,,purchid\n") |
|
|
|
|
|
|
|
|
|
report_service.generate_unassigned_logs_report("report_suffix.csv") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|