Browse Source

Merge branch 'main' into CLDC-1854-make-empty-schemes-show-inactive

pull/1456/head
natdeanlewissoftwire 3 years ago
parent
commit
13df16c130
  1. 2
      app/models/form/lettings/pages/address.rb
  2. 2
      app/models/form/lettings/questions/address_line1.rb
  3. 2
      app/models/form/lettings/questions/uprn_known.rb
  4. 2
      app/models/form/sales/pages/address.rb
  5. 2
      app/models/form/sales/questions/address_line1.rb
  6. 2
      app/models/form/sales/questions/uprn_known.rb
  7. 2
      app/models/form_handler.rb
  8. 6
      app/models/validations/household_validations.rb
  9. 10
      app/models/validations/soft_validations.rb
  10. 36
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  11. 33
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  12. 2
      config/initializers/feature_toggle.rb
  13. 4
      config/locales/en.yml
  14. 1
      spec/features/form/page_routing_spec.rb
  15. 2
      spec/models/form/lettings/pages/address_spec.rb
  16. 4
      spec/models/form/lettings/questions/address_line1_spec.rb
  17. 2
      spec/models/form/lettings/questions/uprn_known_spec.rb
  18. 2
      spec/models/form/sales/pages/address_spec.rb
  19. 4
      spec/models/form/sales/questions/address_line1_spec.rb
  20. 2
      spec/models/form/sales/questions/uprn_known_spec.rb
  21. 11
      spec/models/form_handler_spec.rb
  22. 67
      spec/models/validations/household_validations_spec.rb
  23. 11
      spec/models/validations/soft_validations_spec.rb
  24. 4
      spec/requests/form_controller_spec.rb
  25. 24
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb
  26. 32
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

2
app/models/form/lettings/pages/address.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "address" @id = "address"
@header = "What is the property's address?" @header = "Q12 - What is the property's address?"
end end
def questions def questions

2
app/models/form/lettings/questions/address_line1.rb

@ -6,7 +6,7 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
@header = "Address line 1" @header = "Address line 1"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@question_number = 12 @check_answer_label = "Q12 - Address"
end end
def hidden_in_check_answers?(log, _current_user = nil) def hidden_in_check_answers?(log, _current_user = nil)

2
app/models/form/lettings/questions/uprn_known.rb

@ -3,7 +3,7 @@ class Form::Lettings::Questions::UprnKnown < ::Form::Question
super super
@id = "uprn_known" @id = "uprn_known"
@check_answer_label = "UPRN known?" @check_answer_label = "UPRN known?"
@header = "Do you know the property UPRN?" @header = "Do you know the property's UPRN?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br> @hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br>

2
app/models/form/sales/pages/address.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "address" @id = "address"
@header = "What is the property's address?" @header = "Q15 - What is the property's address?"
end end
def questions def questions

2
app/models/form/sales/questions/address_line1.rb

@ -6,7 +6,7 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
@header = "Address line 1" @header = "Address line 1"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@question_number = 15 @check_answer_label = "Q15 - Address"
end end
def hidden_in_check_answers?(log, _current_user = nil) def hidden_in_check_answers?(log, _current_user = nil)

2
app/models/form/sales/questions/uprn_known.rb

@ -3,7 +3,7 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question
super super
@id = "uprn_known" @id = "uprn_known"
@check_answer_label = "UPRN known?" @check_answer_label = "UPRN known?"
@header = "Do you know the property UPRN?" @header = "Do you know the property's UPRN?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br> @hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br>

2
app/models/form_handler.rb

@ -47,7 +47,7 @@ class FormHandler
form = Form.new(form_path) form = Form.new(form_path)
form_to_set = form_name_from_start_year(form.start_date.year, "lettings") form_to_set = form_name_from_start_year(form.start_date.year, "lettings")
forms[form_to_set] = form if forms[form_to_set].blank? forms[form_to_set] = form if form_to_set && forms[form_to_set].blank?
end end
end end

6
app/models/validations/household_validations.rb

@ -35,12 +35,6 @@ module Validations::HouseholdValidations
end end
end end
def validate_pregnancy(record)
if (record.has_pregnancy? || record.pregnancy_refused?) && women_in_household(record) && !women_of_child_bearing_age_in_household(record)
record.errors.add :preg_occ, I18n.t("validations.household.preg_occ.no_female")
end
end
def validate_household_number_of_other_members(record) def validate_household_number_of_other_members(record)
(2..8).each do |n| (2..8).each do |n|
validate_person_age_matches_economic_status(record, n) validate_person_age_matches_economic_status(record, n)

10
app/models/validations/soft_validations.rb

@ -53,11 +53,11 @@ module Validations::SoftValidations
end end
def no_females_in_a_pregnant_household? def no_females_in_a_pregnant_household?
!females_in_the_household? && all_tenants_age_and_gender_information_completed? && preg_occ == 1 !females_in_the_household? && all_tenants_gender_information_completed? && preg_occ == 1
end end
def female_in_pregnant_household_in_soft_validation_range? def female_in_pregnant_household_in_soft_validation_range?
all_tenants_age_and_gender_information_completed? && (females_in_age_range(11, 15) || females_in_age_range(51, 65)) && !females_in_age_range(16, 50) && preg_occ == 1 all_tenants_age_and_gender_information_completed? && females_in_the_household? && !females_in_age_range(16, 50) && preg_occ == 1
end end
def all_tenants_age_and_gender_information_completed? def all_tenants_age_and_gender_information_completed?
@ -66,6 +66,12 @@ module Validations::SoftValidations
end end
end end
def all_tenants_gender_information_completed?
(1..hhmemb).all? do |n|
public_send("sex#{n}").present? && details_known_or_lead_tenant?(n)
end
end
TWO_YEARS_IN_DAYS = 730 TWO_YEARS_IN_DAYS = 730
TEN_YEARS_IN_DAYS = 3650 TEN_YEARS_IN_DAYS = 3650

36
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -308,14 +308,14 @@ class BulkUpload::Lettings::Year2022::RowParser
validate :validate_dont_know_disabled_needs_conjunction validate :validate_dont_know_disabled_needs_conjunction
validate :validate_no_and_dont_know_disabled_needs_conjunction validate :validate_no_and_dont_know_disabled_needs_conjunction
validate :validate_owning_org_permitted
validate :validate_owning_org_owns_stock
validate :validate_owning_org_exists
validate :validate_owning_org_data_given validate :validate_owning_org_data_given
validate :validate_owning_org_exists
validate :validate_owning_org_owns_stock
validate :validate_owning_org_permitted
validate :validate_managing_org_related
validate :validate_managing_org_exists
validate :validate_managing_org_data_given validate :validate_managing_org_data_given
validate :validate_managing_org_exists
validate :validate_managing_org_related
validate :validate_scheme_related validate :validate_scheme_related
validate :validate_scheme_exists validate :validate_scheme_exists
@ -436,19 +436,26 @@ private
def validate_managing_org_related def validate_managing_org_related
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation) if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation)
block_log_creation! block_log_creation!
if errors[:field_113].blank?
errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation") errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation")
end end
end end
end
def validate_managing_org_exists def validate_managing_org_exists
if managing_organisation.nil? if managing_organisation.nil?
errors.delete(:field_113) block_log_creation!
if errors[:field_113].blank?
errors.add(:field_113, "The managing organisation code is incorrect") errors.add(:field_113, "The managing organisation code is incorrect")
end end
end end
end
def validate_managing_org_data_given def validate_managing_org_data_given
if field_113.blank? if field_113.blank?
block_log_creation!
errors.add(:field_113, "The managing organisation code is incorrect", category: :setup) errors.add(:field_113, "The managing organisation code is incorrect", category: :setup)
end end
end end
@ -456,31 +463,42 @@ private
def validate_owning_org_owns_stock def validate_owning_org_owns_stock
if owning_organisation && !owning_organisation.holds_own_stock? if owning_organisation && !owning_organisation.holds_own_stock?
block_log_creation! block_log_creation!
errors.delete(:field_111)
if errors[:field_111].blank?
errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock") errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock")
end end
end end
end
def validate_owning_org_exists def validate_owning_org_exists
if owning_organisation.nil? if owning_organisation.nil?
errors.delete(:field_111) block_log_creation!
if errors[:field_111].blank?
errors.add(:field_111, "The owning organisation code is incorrect") errors.add(:field_111, "The owning organisation code is incorrect")
end end
end end
end
def validate_owning_org_data_given def validate_owning_org_data_given
if field_111.blank? if field_111.blank?
block_log_creation!
if errors[:field_111].blank?
errors.add(:field_111, "The owning organisation code is incorrect", category: :setup) errors.add(:field_111, "The owning organisation code is incorrect", category: :setup)
end end
end end
end
def validate_owning_org_permitted def validate_owning_org_permitted
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation) if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)
block_log_creation! block_log_creation!
errors.delete(:field_111)
if errors[:field_111].blank?
errors.add(:field_111, "You do not have permission to add logs for this owning organisation") errors.add(:field_111, "You do not have permission to add logs for this owning organisation")
end end
end end
end
def validate_no_and_dont_know_disabled_needs_conjunction def validate_no_and_dont_know_disabled_needs_conjunction
if field_59 == 1 && field_60 == 1 if field_59 == 1 && field_60 == 1

33
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -311,14 +311,14 @@ class BulkUpload::Lettings::Year2023::RowParser
validate :validate_dont_know_disabled_needs_conjunction validate :validate_dont_know_disabled_needs_conjunction
validate :validate_no_and_dont_know_disabled_needs_conjunction validate :validate_no_and_dont_know_disabled_needs_conjunction
validate :validate_owning_org_permitted
validate :validate_owning_org_owns_stock
validate :validate_owning_org_exists
validate :validate_owning_org_data_given validate :validate_owning_org_data_given
validate :validate_owning_org_exists
validate :validate_owning_org_owns_stock
validate :validate_owning_org_permitted
validate :validate_managing_org_related
validate :validate_managing_org_exists
validate :validate_managing_org_data_given validate :validate_managing_org_data_given
validate :validate_managing_org_exists
validate :validate_managing_org_related
validate :validate_scheme_related validate :validate_scheme_related
validate :validate_scheme_exists validate :validate_scheme_exists
@ -551,19 +551,26 @@ private
def validate_managing_org_related def validate_managing_org_related
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation) if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation)
block_log_creation! block_log_creation!
if errors[:field_2].blank?
errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation") errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation")
end end
end end
end
def validate_managing_org_exists def validate_managing_org_exists
if managing_organisation.nil? if managing_organisation.nil?
errors.delete(:field_2) block_log_creation!
if errors[:field_2].blank?
errors.add(:field_2, "The managing organisation code is incorrect") errors.add(:field_2, "The managing organisation code is incorrect")
end end
end end
end
def validate_managing_org_data_given def validate_managing_org_data_given
if field_2.blank? if field_2.blank?
block_log_creation!
errors.add(:field_2, "The managing organisation code is incorrect", category: :setup) errors.add(:field_2, "The managing organisation code is incorrect", category: :setup)
end end
end end
@ -571,20 +578,26 @@ private
def validate_owning_org_owns_stock def validate_owning_org_owns_stock
if owning_organisation && !owning_organisation.holds_own_stock? if owning_organisation && !owning_organisation.holds_own_stock?
block_log_creation! block_log_creation!
errors.delete(:field_1)
if errors[:field_1].blank?
errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock") errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock")
end end
end end
end
def validate_owning_org_exists def validate_owning_org_exists
if owning_organisation.nil? if owning_organisation.nil?
errors.delete(:field_1) block_log_creation!
if errors[:field_1].blank?
errors.add(:field_1, "The owning organisation code is incorrect") errors.add(:field_1, "The owning organisation code is incorrect")
end end
end end
end
def validate_owning_org_data_given def validate_owning_org_data_given
if field_1.blank? if field_1.blank?
block_log_creation!
errors.add(:field_1, "The owning organisation code is incorrect", category: :setup) errors.add(:field_1, "The owning organisation code is incorrect", category: :setup)
end end
end end
@ -592,10 +605,12 @@ private
def validate_owning_org_permitted def validate_owning_org_permitted
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation) if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)
block_log_creation! block_log_creation!
errors.delete(:field_1)
if errors[:field_1].blank?
errors.add(:field_1, "You do not have permission to add logs for this owning organisation") errors.add(:field_1, "You do not have permission to add logs for this owning organisation")
end end
end end
end
def setup_question?(question) def setup_question?(question)
log.form.setup_sections[0].subsections[0].questions.include?(question) log.form.setup_sections[0].subsections[0].questions.include?(question)

2
config/initializers/feature_toggle.rb

@ -5,7 +5,7 @@ class FeatureToggle
end end
def self.startdate_collection_window_validation_enabled? def self.startdate_collection_window_validation_enabled?
Rails.env.production? || Rails.env.test? || Rails.env.staging? Rails.env.production? || Rails.env.test?
end end
def self.startdate_two_week_validation_enabled? def self.startdate_two_week_validation_enabled?

4
config/locales/en.yml

@ -335,8 +335,6 @@ en:
leftreg: leftreg:
question_required: "Tell us whether the person is still serving in the UK armed forces as you told us they’re a current or former regular" question_required: "Tell us whether the person is still serving in the UK armed forces as you told us they’re a current or former regular"
question_not_required: "You cannot answer whether the person is still serving in the UK armed forces as you told us they’re not a current or former regular" question_not_required: "You cannot answer whether the person is still serving in the UK armed forces as you told us they’re not a current or former regular"
preg_occ:
no_female: "Enter ‘no’ as there are no female tenants aged 11-65 in the household"
age: age:
retired_male: "A male tenant who is retired must be 65 or over" retired_male: "A male tenant who is retired must be 65 or over"
retired_female: "A female tenant who is retired must be 60 or over" retired_female: "A female tenant who is retired must be 60 or over"
@ -516,7 +514,7 @@ en:
pregnancy: pregnancy:
title: "You told us somebody in the household is pregnant" title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property." no_females: "You also told us there are no female tenants living at the property."
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>11 to 16</li><li>50 to 65</li></ul>" females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>under 16 years old</li><li>over 50 years old</li></ul>"
major_repairs_date: major_repairs_date:
title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years" title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years"
void_date: void_date:

1
spec/features/form/page_routing_spec.rb

@ -16,7 +16,6 @@ RSpec.describe "Form Page Routing" do
before do before do
allow(lettings_log.form).to receive(:end_date).and_return(Time.zone.today + 1.day) allow(lettings_log.form).to receive(:end_date).and_return(Time.zone.today + 1.day)
allow(validator).to receive(:validate_pregnancy).and_return(true)
sign_in user sign_in user
end end

2
spec/models/form/lettings/pages/address_spec.rb

@ -20,7 +20,7 @@ RSpec.describe Form::Lettings::Pages::Address, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(page.header).to eq("What is the property's address?") expect(page.header).to eq("Q12 - What is the property's address?")
end end
it "has the correct description" do it "has the correct description" do

4
spec/models/form/lettings/questions/address_line1_spec.rb

@ -20,11 +20,11 @@ RSpec.describe Form::Lettings::Questions::AddressLine1, type: :model do
end end
it "has the correct question_number" do it "has the correct question_number" do
expect(question.question_number).to eq(12) expect(question.question_number).to be_nil
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Address") expect(question.check_answer_label).to eq("Q12 - Address")
end end
it "has the correct type" do it "has the correct type" do

2
spec/models/form/lettings/questions/uprn_known_spec.rb

@ -16,7 +16,7 @@ RSpec.describe Form::Lettings::Questions::UprnKnown, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(question.header).to eq("Do you know the property UPRN?") expect(question.header).to eq("Do you know the property's UPRN?")
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do

2
spec/models/form/sales/pages/address_spec.rb

@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::Address, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(page.header).to eq("What is the property's address?") expect(page.header).to eq("Q15 - What is the property's address?")
end end
it "has the correct description" do it "has the correct description" do

4
spec/models/form/sales/questions/address_line1_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do
end end
it "has the correct question_number" do it "has the correct question_number" do
expect(question.question_number).to eq(15) expect(question.question_number).to be_nil
end end
it "has the correct id" do it "has the correct id" do
@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Questions::AddressLine1, type: :model do
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Address") expect(question.check_answer_label).to eq("Q15 - Address")
end end
it "has the correct type" do it "has the correct type" do

2
spec/models/form/sales/questions/uprn_known_spec.rb

@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(question.header).to eq("Do you know the property UPRN?") expect(question.header).to eq("Do you know the property's UPRN?")
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do

11
spec/models/form_handler_spec.rb

@ -9,8 +9,6 @@ RSpec.describe FormHandler do
Singleton.__init__(described_class) Singleton.__init__(described_class)
example.run example.run
end end
Timecop.return
Singleton.__init__(described_class)
end end
context "when accessing a form in a different year" do context "when accessing a form in a different year" do
@ -35,6 +33,15 @@ RSpec.describe FormHandler do
expect(all_forms.count).to be >= 1 expect(all_forms.count).to be >= 1
expect(all_forms["current_sales"]).to be_a(Form) expect(all_forms["current_sales"]).to be_a(Form)
end end
context "when in 23/24 period or later" do
let(:now) { Time.utc(2023, 6, 7) }
it "does not load outdated forms" do
all_forms = form_handler.forms
expect(all_forms.keys).not_to include nil
end
end
end end
describe "Get specific form" do describe "Get specific form" do

67
spec/models/validations/household_validations_spec.rb

@ -60,73 +60,6 @@ RSpec.describe Validations::HouseholdValidations do
end end
end end
describe "pregnancy validations" do
context "when there are no female tenants" do
it "validates that pregnancy can be yes" do
record.preg_occ = 1
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"]).to be_empty
end
it "validates that pregnancy can be prefer not to say" do
record.preg_occ = 3
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"]).to be_empty
end
end
context "when there are female tenants" do
context "but they are older than 65" do
before { record.assign_attributes(sex1: "F", age1: 66, preg_occ: 1) }
it "validates that pregnancy cannot be yes" do
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
.to include(match I18n.t("validations.household.preg_occ.no_female"))
end
end
context "and they are the lead tenant and under 65" do
before { record.assign_attributes(sex1: "F", age1: 64, preg_occ: 1) }
it "allows pregnancy to be set to yes" do
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"]).to be_empty
end
end
context "and they are another household member and under 51" do
before { record.assign_attributes(sex1: "M", age1: 25, sex3: "F", age3: 64, preg_occ: 1) }
it "allows pregnancy to be set to yes" do
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"]).to be_empty
end
end
context "and they are another household member and under 11" do
before { record.assign_attributes(sex1: "M", age1: 25, sex3: "F", age3: 10, preg_occ: 1) }
it "validates that pregnancy cannot be yes" do
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
.to include(match I18n.t("validations.household.preg_occ.no_female"))
end
end
context "and one tenant's age is unknown" do
before { record.assign_attributes(sex1: "F", age1: nil, age1_known: 1, preg_occ: 1) }
it "allows pregnancy to be set to yes" do
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"]).to be_empty
end
end
end
end
describe "reason for leaving last settled home validations" do describe "reason for leaving last settled home validations" do
let(:field) { "validations.other_field_not_required" } let(:field) { "validations.other_field_not_required" }
let(:main_field_label) { "reason" } let(:main_field_label) { "reason" }

11
spec/models/validations/soft_validations_spec.rb

@ -175,14 +175,21 @@ RSpec.describe Validations::SoftValidations do
end end
end end
context "when female tenants are in 11-16 age range" do context "when there are no female tenants and age of other tenants is unknown" do
it "shows the interruption screen" do
record.update!(sex1: "M", preg_occ: 1, hhmemb: 1, age1_known: 1)
expect(record.no_females_in_a_pregnant_household?).to be true
end
end
context "when female tenants are under 16" do
it "shows the interruption screen" do it "shows the interruption screen" do
record.update!(age2: 14, sex2: "F", preg_occ: 1, hhmemb: 2, details_known_2: 0, age2_known: 0, age1: 18, sex1: "M", age1_known: 0) record.update!(age2: 14, sex2: "F", preg_occ: 1, hhmemb: 2, details_known_2: 0, age2_known: 0, age1: 18, sex1: "M", age1_known: 0)
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be true expect(record.female_in_pregnant_household_in_soft_validation_range?).to be true
end end
end end
context "when female tenants are in 50-65 age range" do context "when female tenants are over 50" do
it "shows the interruption screen" do it "shows the interruption screen" do
record.update!(age1: 54, sex1: "F", preg_occ: 1, hhmemb: 1, age1_known: 0) record.update!(age1: 54, sex1: "F", preg_occ: 1, hhmemb: 1, age1_known: 0)
expect(record.female_in_pregnant_household_in_soft_validation_range?).to be true expect(record.female_in_pregnant_household_in_soft_validation_range?).to be true

4
spec/requests/form_controller_spec.rb

@ -632,10 +632,6 @@ RSpec.describe FormController, type: :request do
} }
end end
before do
allow(validator).to receive(:validate_pregnancy).and_return(true)
end
it "routes to the appropriate conditional page based on the question answer of the current page" do it "routes to the appropriate conditional page based on the question answer of the current page" do
post "/lettings-logs/#{lettings_log.id}/form", params: lettings_log_form_conditional_question_yes_params post "/lettings-logs/#{lettings_log.id}/form", params: lettings_log_form_conditional_question_yes_params
expect(response).to redirect_to("/lettings-logs/#{lettings_log.id}/conditional-question-yes-page") expect(response).to redirect_to("/lettings-logs/#{lettings_log.id}/conditional-question-yes-page")

24
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -634,6 +634,10 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
expect(setup_errors.find { |e| e.attribute == :field_111 }.message).to eql("The owning organisation code is incorrect") expect(setup_errors.find { |e| e.attribute == :field_111 }.message).to eql("The owning organisation code is incorrect")
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
context "when cannot find owning org" do context "when cannot find owning org" do
@ -642,6 +646,10 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_111]).to eql(["The owning organisation code is incorrect"]) expect(parser.errors[:field_111]).to eql(["The owning organisation code is incorrect"])
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
context "when org is not stock owning" do context "when org is not stock owning" do
@ -674,12 +682,28 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
end end
describe "#field_113" do # managing org describe "#field_113" do # managing org
context "when blank" do
let(:attributes) { { bulk_upload:, field_113: "" } }
it "is not permitted" do
expect(parser.errors[:field_113]).to eql(["The managing organisation code is incorrect"])
end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end
context "when cannot find managing org" do context "when cannot find managing org" do
let(:attributes) { { bulk_upload:, field_113: "donotexist" } } let(:attributes) { { bulk_upload:, field_113: "donotexist" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_113]).to eql(["The managing organisation code is incorrect"]) expect(parser.errors[:field_113]).to eql(["The managing organisation code is incorrect"])
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
context "when not affiliated with managing org" do context "when not affiliated with managing org" do

32
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -585,12 +585,28 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
describe "#field_1" do # owning org describe "#field_1" do # owning org
context "when blank" do
let(:attributes) { { bulk_upload:, field_1: "" } }
it "is not permitted" do
expect(parser.errors[:field_1]).to eql(["The owning organisation code is incorrect"])
end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end
context "when cannot find owning org" do context "when cannot find owning org" do
let(:attributes) { { bulk_upload:, field_1: "donotexist" } } let(:attributes) { { bulk_upload:, field_1: "donotexist" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_1]).to eql(["The owning organisation code is incorrect"]) expect(parser.errors[:field_1]).to eql(["The owning organisation code is incorrect"])
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
context "when org is not stock owning" do context "when org is not stock owning" do
@ -623,12 +639,28 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
describe "#field_2" do # managing org describe "#field_2" do # managing org
context "when blank" do
let(:attributes) { { bulk_upload:, field_2: "" } }
it "is not permitted" do
expect(parser.errors[:field_2]).to eql(["The managing organisation code is incorrect"])
end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end
context "when cannot find managing org" do context "when cannot find managing org" do
let(:attributes) { { bulk_upload:, field_2: "donotexist" } } let(:attributes) { { bulk_upload:, field_2: "donotexist" } }
it "is not permitted" do it "is not permitted" do
expect(parser.errors[:field_2]).to eql(["The managing organisation code is incorrect"]) expect(parser.errors[:field_2]).to eql(["The managing organisation code is incorrect"])
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
context "when not affiliated with managing org" do context "when not affiliated with managing org" do

Loading…
Cancel
Save