Browse Source

Fix tests

pull/2724/head
Rachael Booth 2 years ago
parent
commit
50599ed1b7
  1. 2
      app/models/form/lettings/subsections/income_and_benefits.rb
  2. 3
      spec/models/form/lettings/subsections/income_and_benefits_spec.rb
  3. 42
      spec/models/form/lettings/subsections/property_information_spec.rb
  4. 4
      spec/services/documentation_generator_spec.rb

2
app/models/form/lettings/subsections/income_and_benefits.rb

@ -24,7 +24,7 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection
Form::Lettings::Pages::RentBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::Rent4Weekly.new(nil, nil, self),
Form::Lettings::Pages::RentMonthly.new(nil, nil, self),
Form::Lettings::Pages::RentValueCheck.new("rent_value_check", nil, self, check_answers_card_number: 0),
Form::Lettings::Pages::RentValueCheck.new("brent_rent_value_check", nil, self, check_answers_card_number: 0),
Form::Lettings::Pages::SchargeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::PschargeValueCheck.new(nil, nil, self),
Form::Lettings::Pages::SupchargValueCheck.new(nil, nil, self),

3
spec/models/form/lettings/subsections/income_and_benefits_spec.rb

@ -30,8 +30,7 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do
rent_bi_weekly
rent_4_weekly
rent_monthly
brent_min_rent_value_check
brent_max_rent_value_check
brent_rent_value_check
scharge_value_check
pscharge_value_check
supcharg_value_check

42
spec/models/form/lettings/subsections/property_information_spec.rb

@ -17,36 +17,6 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
it "has correct pages" do
expect(property_information.pages.compact.map(&:id)).to eq(
%w[
property_postcode
property_local_authority
local_authority_min_rent_value_check
local_authority_max_rent_value_check
first_time_property_let_as_social_housing
property_let_type
property_vacancy_reason_not_first_let
property_vacancy_reason_first_let
property_number_of_times_relet
property_unit_type
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
beds_min_rent_value_check
beds_max_rent_value_check
void_date
void_date_value_check
property_major_repairs
property_major_repairs_value_check
],
)
end
end
context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) }
@ -57,8 +27,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
uprn_confirmation
address
property_local_authority
local_authority_min_rent_value_check
local_authority_max_rent_value_check
local_authority_rent_value_check
first_time_property_let_as_social_housing
property_let_type
property_vacancy_reason_not_first_let
@ -68,8 +37,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
beds_min_rent_value_check
beds_max_rent_value_check
beds_rent_value_check
void_date
void_date_value_check
property_major_repairs
@ -96,8 +64,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
uprn_selection
address
property_local_authority
local_authority_min_rent_value_check
local_authority_max_rent_value_check
local_authority_rent_value_check
first_time_property_let_as_social_housing
property_let_type
property_vacancy_reason_not_first_let
@ -106,8 +73,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
beds_min_rent_value_check
beds_max_rent_value_check
beds_rent_value_check
void_date
void_date_value_check
property_major_repairs

4
spec/services/documentation_generator_spec.rb

@ -89,7 +89,7 @@ describe DocumentationGenerator do
end
describe ":describe_soft_validations" do
let(:all_validation_methods) { ["rent_in_soft_min_range?"] }
let(:all_validation_methods) { ["rent_soft_validation_triggered?"] }
let(:response) do
{ "choices" => [{ "message" => { "tool_calls" => [{ "function" => { "arguments" =>
"{\n \"description\": \"Validates the format.\",\n \"validation_type\": \"format\",\n \"other_validated_models\": \"User\"}" } }] } }] }
@ -100,7 +100,7 @@ describe DocumentationGenerator do
it "creates new validation documentation records" do
expect { described_class.new.describe_soft_validations(client, all_validation_methods, all_helper_methods, log_type) }.to change(LogValidation, :count)
expect(LogValidation.where(validation_name: "rent_in_soft_min_range?").count).to be_positive
expect(LogValidation.where(validation_name: "rent_soft_validation_triggered?").count).to be_positive
any_validation = LogValidation.first
expect(any_validation.description).to eq("Validates the format.")
expect(any_validation.field).not_to be_empty

Loading…
Cancel
Save