Browse Source

feat: update tests

full-import-optimisation
natdeanlewissoftwire 2 years ago
parent
commit
b6e72af7fd
  1. 2
      spec/services/imports/data_protection_confirmation_import_service_spec.rb
  2. 8
      spec/services/imports/lettings_logs_field_import_service_spec.rb
  3. 6
      spec/services/imports/lettings_logs_import_service_spec.rb
  4. 2
      spec/services/imports/organisation_import_service_spec.rb
  5. 2
      spec/services/imports/scheme_import_service_spec.rb
  6. 2
      spec/services/imports/scheme_location_import_service_spec.rb
  7. 2
      spec/services/imports/user_import_service_spec.rb

2
spec/services/imports/data_protection_confirmation_import_service_spec.rb

@ -87,7 +87,7 @@ RSpec.describe Imports::DataProtectionConfirmationImportService do
end
it "logs that the record already exists" do
expect(logger).to receive(:warn)
expect(logger).not_to receive(:warn)
import_service.create_data_protection_confirmations("data_protection_directory")
end
end

8
spec/services/imports/lettings_logs_field_import_service_spec.rb

@ -55,7 +55,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
end
it "logs that the tenancycode already has a value and does not update the lettings_log" do
expect(logger).to receive(:info).with(/lettings log \d+ has a value for tenancycode, skipping update/)
expect(logger).not_to receive(:info)
expect { import_service.send(:update_field, field, remote_folder) }
.not_to(change { lettings_log.reload.tenancycode })
end
@ -253,13 +253,13 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
end
it "logs that major repairs already has a value and does not update major repairs" do
expect(logger).to receive(:info).with(/lettings log \d+ has a value for major repairs, skipping update/)
expect(logger).not_to receive(:info)
expect { import_service.send(:update_field, field, remote_folder) }
.not_to(change { lettings_log.reload.majorrepairs })
end
it "logs that major repairs already has a value and does not update the major repairs date" do
expect(logger).to receive(:info).with(/lettings log \d+ has a value for major repairs, skipping update/)
expect(logger).not_to receive(:info)
expect { import_service.send(:update_field, field, remote_folder) }
.not_to(change { lettings_log.reload.mrcdate })
end
@ -317,7 +317,7 @@ RSpec.describe Imports::LettingsLogsFieldImportService do
end
it "does not update the lettings_log offered value" do
expect(logger).to receive(:info).with(/lettings log \d+ has a value for offered, skipping update/)
expect(logger).not_to receive(:info)
expect { import_service.send(:update_field, field, remote_folder) }
.not_to(change { lettings_log.reload.offered })
end

6
spec/services/imports/lettings_logs_import_service_spec.rb

@ -124,7 +124,7 @@ RSpec.describe Imports::LettingsLogsImportService do
expect(logger).not_to receive(:error)
expect(logger).not_to receive(:warn)
expect { lettings_log_service.create_logs(remote_folder) }
.to change(OrganisationRelationship, :count).by(1)
.not_to change(OrganisationRelationship, :count)
end
end
@ -1146,11 +1146,11 @@ RSpec.describe Imports::LettingsLogsImportService do
end
end
it "creates organisation relationship once" do
it "does not create organisation relationship" do
expect(logger).not_to receive(:error)
expect(logger).not_to receive(:warn)
expect { lettings_log_service.create_logs(remote_folder) }
.to change(OrganisationRelationship, :count).by(1)
.not_to change(OrganisationRelationship, :count)
end
end

2
spec/services/imports/organisation_import_service_spec.rb

@ -81,7 +81,7 @@ RSpec.describe Imports::OrganisationImportService do
it "successfully create an organisation the first time, and does not update it" do
expect(storage_service).to receive(:list_files).with(folder_name).twice
expect(storage_service).to receive(:get_file_io).with(filenames[0]).twice
expect(logger).to receive(:warn).once
expect(logger).not_to receive(:warn)
expect { import_service.create_organisations(folder_name) }.to change(Organisation, :count).by(1)
expect { import_service.create_organisations(folder_name) }.to change(Organisation, :count).by(0)

2
spec/services/imports/scheme_import_service_spec.rb

@ -53,7 +53,7 @@ RSpec.describe Imports::SchemeImportService do
before { scheme_xml.at_xpath("//mgmtgroup:status").content = "Temporary" }
it "does not create the scheme" do
expect(logger).to receive(:warn).with("Scheme with legacy ID 6d6d7618b58affe2a150a5ef2e9f4765fa6cd05d is not approved (Temporary), skipping")
expect(logger).not_to receive(:warn)
expect { scheme_service.create_scheme(scheme_xml) }
.not_to change(Scheme, :count)
end

2
spec/services/imports/scheme_location_import_service_spec.rb

@ -175,7 +175,7 @@ RSpec.describe Imports::SchemeLocationImportService do
before { location_service.create_scheme_location(location_xml) }
it "does not create the location" do
expect(logger).to receive(:warn).with("Location is already present with legacy ID 0ae7ad6dc0f1cf7ef33c18cc8c108bebc1b4923e, skipping")
expect(logger).not_to receive(:warn)
expect { location_service.create_scheme_location(location_xml) }
.not_to change(Location, :count)
end

2
spec/services/imports/user_import_service_spec.rb

@ -102,7 +102,7 @@ RSpec.describe Imports::UserImportService do
end
it "logs that the user already exists" do
expect(logger).to receive(:warn)
expect(logger).not_to receive(:warn)
import_service.create_users("user_directory")
end
end

Loading…
Cancel
Save