Browse Source

Rename fixture files

pull/1331/head
Kat 3 years ago
parent
commit
db68858063
  1. 2
      spec/fixtures/imports/sales_logs/discounted_ownership_sales_log.xml
  2. 2
      spec/fixtures/imports/sales_logs/outright_sale_sales_log.xml
  3. 2
      spec/fixtures/imports/sales_logs/shared_ownership_sales_log.xml
  4. 2
      spec/fixtures/imports/sales_logs/shared_ownership_sales_log2.xml
  5. 2
      spec/fixtures/imports/sales_logs/shared_ownership_sales_log3.xml
  6. 2
      spec/fixtures/imports/sales_logs/shared_ownership_sales_log4.xml
  7. 86
      spec/services/imports/sales_logs_import_service_spec.rb

2
spec/fixtures/imports/sales_logs/0b4a68df-30cc-474a-93c0-a56ce8fdad3b.xml → spec/fixtures/imports/sales_logs/discounted_ownership_sales_log.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>0b4a68df-30cc-474a-93c0-a56ce8fdad3b</meta:document-id> <meta:document-id>discounted_ownership_sales_log</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id> <meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09z2c55d9cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09z2c55d9cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09z2c55d9cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09z2c55d9cb90d7ba84927e64618</meta:managing-institution-id>

2
spec/fixtures/imports/sales_logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml → spec/fixtures/imports/sales_logs/outright_sale_sales_log.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>00d2343e-d5fa-4c89-8400-ec3854b0f2b4</meta:document-id> <meta:document-id>outright_sale_sales_log</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id> <meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id>

2
spec/fixtures/imports/sales_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml → spec/fixtures/imports/sales_logs/shared_ownership_sales_log.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>0ead17cb-1668-442d-898c-0d52879ff592</meta:document-id> <meta:document-id>shared_ownership_sales_log</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id> <meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id>

2
spec/fixtures/imports/sales_logs/166fc004-392e-47a8-acb8-1c018734882b.xml → spec/fixtures/imports/sales_logs/shared_ownership_sales_log2.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>166fc004-392e-47a8-acb8-1c018734882b</meta:document-id> <meta:document-id>shared_ownership_sales_log2</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id> <meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id>

2
spec/fixtures/imports/sales_logs/893ufj2s-lq77-42m4-rty6-ej09gh585uy1.xml → spec/fixtures/imports/sales_logs/shared_ownership_sales_log3.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>893ufj2s-lq77-42m4-rty6-ej09gh585uy1</meta:document-id> <meta:document-id>shared_ownership_sales_log3</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id> <meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id>

2
spec/fixtures/imports/sales_logs/5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd.xml → spec/fixtures/imports/sales_logs/shared_ownership_sales_log4.xml vendored

@ -1,7 +1,7 @@
<Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Group xmlns="http://data.gov.uk/core/logs/2022-CORE-Sales" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile"> <meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2022-CORE-Sales</meta:form-name> <meta:form-name>2022-CORE-Sales</meta:form-name>
<meta:document-id>5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd</meta:document-id> <meta:document-id>shared_ownership_sales_log4</meta:document-id>
<meta:owner-user-id>e29c492473446dca4d50224f2bb7cf965a261d6f</meta:owner-user-id> <meta:owner-user-id>e29c492473446dca4d50224f2bb7cf965a261d6f</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id> <meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id> <meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618</meta:managing-institution-id>

86
spec/services/imports/sales_logs_import_service_spec.rb

@ -11,10 +11,6 @@ RSpec.describe Imports::SalesLogsImportService do
let(:organisation) { FactoryBot.create(:organisation, old_visible_id: "1", provider_type: "PRP") } let(:organisation) { FactoryBot.create(:organisation, old_visible_id: "1", provider_type: "PRP") }
let(:managing_organisation) { FactoryBot.create(:organisation, old_visible_id: "2", provider_type: "PRP") } let(:managing_organisation) { FactoryBot.create(:organisation, old_visible_id: "2", provider_type: "PRP") }
let(:remote_folder) { "sales_logs" } let(:remote_folder) { "sales_logs" }
let(:shared_ownership_sales_log_id) { "0ead17cb-1668-442d-898c-0d52879ff592" }
let(:shared_ownership_sales_log_id2) { "166fc004-392e-47a8-acb8-1c018734882b" }
let(:outright_sale_sales_log_id) { "00d2343e-d5fa-4c89-8400-ec3854b0f2b4" }
let(:discounted_ownership_sales_log_id) { "0b4a68df-30cc-474a-93c0-a56ce8fdad3b" }
def open_file(directory, filename) def open_file(directory, filename)
File.open("#{directory}/#{filename}.xml") File.open("#{directory}/#{filename}.xml")
@ -42,19 +38,19 @@ RSpec.describe Imports::SalesLogsImportService do
before do before do
# Stub the S3 file listing and download # Stub the S3 file listing and download
allow(storage_service).to receive(:list_files) allow(storage_service).to receive(:list_files)
.and_return(%W[#{remote_folder}/#{shared_ownership_sales_log_id}.xml #{remote_folder}/#{shared_ownership_sales_log_id2}.xml #{remote_folder}/#{outright_sale_sales_log_id}.xml #{remote_folder}/#{discounted_ownership_sales_log_id}.xml]) .and_return(%W[#{remote_folder}/shared_ownership_sales_log.xml #{remote_folder}/shared_ownership_sales_log2.xml #{remote_folder}/outright_sale_sales_log.xml #{remote_folder}/discounted_ownership_sales_log.xml])
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{shared_ownership_sales_log_id}.xml") .with("#{remote_folder}/shared_ownership_sales_log.xml")
.and_return(open_file(fixture_directory, shared_ownership_sales_log_id), open_file(fixture_directory, shared_ownership_sales_log_id)) .and_return(open_file(fixture_directory, "shared_ownership_sales_log"), open_file(fixture_directory, "shared_ownership_sales_log"))
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{shared_ownership_sales_log_id2}.xml") .with("#{remote_folder}/shared_ownership_sales_log2.xml")
.and_return(open_file(fixture_directory, shared_ownership_sales_log_id2), open_file(fixture_directory, shared_ownership_sales_log_id2)) .and_return(open_file(fixture_directory, "shared_ownership_sales_log2"), open_file(fixture_directory, "shared_ownership_sales_log2"))
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{outright_sale_sales_log_id}.xml") .with("#{remote_folder}/outright_sale_sales_log.xml")
.and_return(open_file(fixture_directory, outright_sale_sales_log_id), open_file(fixture_directory, outright_sale_sales_log_id)) .and_return(open_file(fixture_directory, "outright_sale_sales_log"), open_file(fixture_directory, "outright_sale_sales_log"))
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{discounted_ownership_sales_log_id}.xml") .with("#{remote_folder}/discounted_ownership_sales_log.xml")
.and_return(open_file(fixture_directory, discounted_ownership_sales_log_id), open_file(fixture_directory, discounted_ownership_sales_log_id)) .and_return(open_file(fixture_directory, "discounted_ownership_sales_log"), open_file(fixture_directory, "discounted_ownership_sales_log"))
end end
it "successfully creates all sales logs" do it "successfully creates all sales logs" do
@ -74,33 +70,31 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when there are status discrepancies" do context "when there are status discrepancies" do
let(:shared_ownership_sales_log_id3) { "893ufj2s-lq77-42m4-rty6-ej09gh585uy1" } let(:sales_log_file) { open_file(fixture_directory, "shared_ownership_sales_log3") }
let(:shared_ownership_sales_log_id4) { "5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd" }
let(:sales_log_file) { open_file(fixture_directory, shared_ownership_sales_log_id3) }
let(:sales_log_xml) { Nokogiri::XML(sales_log_file) } let(:sales_log_xml) { Nokogiri::XML(sales_log_file) }
before do before do
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{shared_ownership_sales_log_id3}.xml") .with("#{remote_folder}/shared_ownership_sales_log3.xml")
.and_return(open_file(fixture_directory, shared_ownership_sales_log_id3), open_file(fixture_directory, shared_ownership_sales_log_id3)) .and_return(open_file(fixture_directory, "shared_ownership_sales_log3"), open_file(fixture_directory, "shared_ownership_sales_log3"))
allow(storage_service).to receive(:get_file_io) allow(storage_service).to receive(:get_file_io)
.with("#{remote_folder}/#{shared_ownership_sales_log_id4}.xml") .with("#{remote_folder}/shared_ownership_sales_log4.xml")
.and_return(open_file(fixture_directory, shared_ownership_sales_log_id4), open_file(fixture_directory, shared_ownership_sales_log_id4)) .and_return(open_file(fixture_directory, "shared_ownership_sales_log4"), open_file(fixture_directory, "shared_ownership_sales_log4"))
end end
it "the logger logs a warning with the sales log's old id/filename" do it "the logger logs a warning with the sales log's old id/filename" do
expect(logger).to receive(:warn).with(/is not completed/).once expect(logger).to receive(:warn).with(/is not completed/).once
expect(logger).to receive(:warn).with(/sales log with old id:#{shared_ownership_sales_log_id3} is incomplete but status should be complete/).once expect(logger).to receive(:warn).with(/sales log with old id:shared_ownership_sales_log3 is incomplete but status should be complete/).once
sales_log_service.send(:create_log, sales_log_xml) sales_log_service.send(:create_log, sales_log_xml)
end end
it "on completion the ids of all logs with status discrepancies are logged in a warning" do it "on completion the ids of all logs with status discrepancies are logged in a warning" do
allow(storage_service).to receive(:list_files) allow(storage_service).to receive(:list_files)
.and_return(%W[#{remote_folder}/#{shared_ownership_sales_log_id3}.xml #{remote_folder}/#{shared_ownership_sales_log_id4}.xml]) .and_return(%W[#{remote_folder}/shared_ownership_sales_log3.xml #{remote_folder}/shared_ownership_sales_log4.xml])
expect(logger).to receive(:warn).with(/is not completed/).twice expect(logger).to receive(:warn).with(/is not completed/).twice
expect(logger).to receive(:warn).with(/is incomplete but status should be complete/).twice expect(logger).to receive(:warn).with(/is incomplete but status should be complete/).twice
expect(logger).to receive(:warn).with(/The following sales logs had status discrepancies: \[893ufj2s-lq77-42m4-rty6-ej09gh585uy1, 5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd\]/) expect(logger).to receive(:warn).with(/The following sales logs had status discrepancies: \[shared_ownership_sales_log3, shared_ownership_sales_log4\]/)
sales_log_service.create_logs(remote_folder) sales_log_service.create_logs(remote_folder)
end end
@ -112,7 +106,7 @@ RSpec.describe Imports::SalesLogsImportService do
let(:sales_log_xml) { Nokogiri::XML(sales_log_file) } let(:sales_log_xml) { Nokogiri::XML(sales_log_file) }
context "and the organisation legacy ID does not exist" do context "and the organisation legacy ID does not exist" do
let(:sales_log_id) { shared_ownership_sales_log_id } let(:sales_log_id) { "shared_ownership_sales_log" }
before { sales_log_xml.at_xpath("//xmlns:OWNINGORGID").content = 99_999 } before { sales_log_xml.at_xpath("//xmlns:OWNINGORGID").content = 99_999 }
@ -123,7 +117,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when the mortgage lender is set to an existing option" do context "when the mortgage lender is set to an existing option" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:Q34a").content = "halifax" sales_log_xml.at_xpath("//xmlns:Q34a").content = "halifax"
@ -139,7 +133,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when the mortgage lender is set to a non existing option" do context "when the mortgage lender is set to a non existing option" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:Q34a").content = "something else" sales_log_xml.at_xpath("//xmlns:Q34a").content = "something else"
@ -156,7 +150,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "with shared ownership type" do context "with shared ownership type" do
let(:sales_log_id) { shared_ownership_sales_log_id } let(:sales_log_id) { "shared_ownership_sales_log" }
it "successfully creates a completed shared ownership log" do it "successfully creates a completed shared ownership log" do
expect(logger).not_to receive(:error) expect(logger).not_to receive(:error)
@ -168,7 +162,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "with discounted ownership type" do context "with discounted ownership type" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
it "successfully creates a completed discounted ownership log" do it "successfully creates a completed discounted ownership log" do
expect(logger).not_to receive(:error) expect(logger).not_to receive(:error)
@ -180,7 +174,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "with outright sale type" do context "with outright sale type" do
let(:sales_log_id) { outright_sale_sales_log_id } let(:sales_log_id) { "outright_sale_sales_log" }
it "successfully creates a completed outright sale log" do it "successfully creates a completed outright sale log" do
expect(logger).not_to receive(:error) expect(logger).not_to receive(:error)
@ -193,7 +187,7 @@ RSpec.describe Imports::SalesLogsImportService do
context "when inferring default answers for completed sales logs" do context "when inferring default answers for completed sales logs" do
context "when the armedforcesspouse is not answered" do context "when the armedforcesspouse is not answered" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:ARMEDFORCESSPOUSE").content = "" sales_log_xml.at_xpath("//xmlns:ARMEDFORCESSPOUSE").content = ""
@ -209,7 +203,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when the savings not known is not answered and savings is not given" do context "when the savings not known is not answered and savings is not given" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:savingsKnown").content = "" sales_log_xml.at_xpath("//xmlns:savingsKnown").content = ""
@ -225,7 +219,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when the savings not known is not answered and savings is given" do context "when the savings not known is not answered and savings is given" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:Q3Savings").content = "10000" sales_log_xml.at_xpath("//xmlns:Q3Savings").content = "10000"
@ -242,7 +236,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "and it's an outright sale" do context "and it's an outright sale" do
let(:sales_log_id) { outright_sale_sales_log_id } let(:sales_log_id) { "outright_sale_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -257,7 +251,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring age known" do context "when inferring age known" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3"
@ -282,7 +276,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring gender" do context "when inferring gender" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3"
@ -307,7 +301,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring ethnic group" do context "when inferring ethnic group" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "1" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "1"
@ -324,7 +318,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring nationality" do context "when inferring nationality" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "1" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "1"
@ -341,7 +335,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring economic status" do context "when inferring economic status" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3"
@ -366,7 +360,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring relationship" do context "when inferring relationship" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3" sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "3"
@ -389,7 +383,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring armed forces" do context "when inferring armed forces" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -413,7 +407,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring disability" do context "when inferring disability" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -437,7 +431,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring wheelchair" do context "when inferring wheelchair" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -461,7 +455,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring housing benefit" do context "when inferring housing benefit" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -485,7 +479,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring income not known" do context "when inferring income not known" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
sales_log_xml.at_xpath("//xmlns:joint").content = "1 Yes" sales_log_xml.at_xpath("//xmlns:joint").content = "1 Yes"
@ -531,7 +525,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring prevown" do context "when inferring prevown" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)
@ -555,7 +549,7 @@ RSpec.describe Imports::SalesLogsImportService do
end end
context "when inferring household count" do context "when inferring household count" do
let(:sales_log_id) { discounted_ownership_sales_log_id } let(:sales_log_id) { "discounted_ownership_sales_log" }
before do before do
allow(logger).to receive(:warn).and_return(nil) allow(logger).to receive(:warn).and_return(nil)

Loading…
Cancel
Save