diff --git a/spec/lib/tasks/data_import_spec.rb b/spec/lib/tasks/data_import_spec.rb index 9749ce27f..b99370bb0 100644 --- a/spec/lib/tasks/data_import_spec.rb +++ b/spec/lib/tasks/data_import_spec.rb @@ -6,7 +6,7 @@ describe "rake core:data_import", type: :task do let(:fixture_path) { "spec/fixtures/softwire_imports/organisations" } let(:instance_name) { "paas_import_instance" } - let(:organisation_type) { "organisation" } + let(:type) { "organisation" } let(:storage_service) { instance_double(StorageService) } let(:paas_config_service) { instance_double(PaasConfigurationService) } @@ -19,18 +19,38 @@ describe "rake core:data_import", type: :task do allow(StorageService).to receive(:new).and_return(storage_service) allow(PaasConfigurationService).to receive(:new).and_return(paas_config_service) - allow(Imports::OrganisationImportService).to receive(:new).and_return(import_service) allow(ENV).to receive(:[]) allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name) end context "when importing organisation data" do + before do + allow(Imports::OrganisationImportService).to receive(:new).and_return(import_service) + end + it "creates an organisation from the given XML file" do expect(StorageService).to receive(:new).with(paas_config_service, instance_name) expect(Imports::OrganisationImportService).to receive(:new).with(storage_service) expect(import_service).to receive(:create_organisations).with(fixture_path) - task.invoke(organisation_type, fixture_path) + task.invoke(type, fixture_path) + end + end + + context "when importing user data" do + let(:type) { "user" } + let(:import_service) { instance_double(Imports::UserImportService) } + + before do + allow(Imports::UserImportService).to receive(:new).and_return(import_service) + end + + it "creates a user from the given XML file" do + expect(StorageService).to receive(:new).with(paas_config_service, instance_name) + expect(Imports::UserImportService).to receive(:new).with(storage_service) + expect(import_service).to receive(:create_users).with(fixture_path) + + task.invoke(type, fixture_path) end end diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 940d01fc6..3c76b3365 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -123,6 +123,10 @@ RSpec.describe CaseLog do expect(validator).to receive(:validate_reason_for_leaving_last_settled_home) end + it "validates previous housing situation" do + expect(validator).to receive(:validate_previous_housing_situation) + end + it "validates armed forces" do expect(validator).to receive(:validate_armed_forces) end diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 12d692e9c..18692ef94 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -547,4 +547,16 @@ RSpec.describe Validations::HouseholdValidations do end end end + + describe "previous housing situation validations" do + context "when the property is being relet to a previously temporary tenant" do + it "validates that previous tenancy was temporary" do + record.rsnvac = 2 + record.prevten = 4 + household_validator.validate_previous_housing_situation(record) + expect(record.errors["prevten"]) + .to include(match I18n.t("validations.household.prevten.non_temp_accommodation")) + end + end + end end