Browse Source

Remove soft validations from lettings setup and make them mandatory

pull/1645/head
Kat 3 years ago
parent
commit
7e00e1192d
  1. 8
      app/models/form/lettings/subsections/setup.rb
  2. 2
      app/models/lettings_log.rb
  3. 16
      spec/models/form/lettings/subsections/setup_spec.rb

8
app/models/form/lettings/subsections/setup.rb

@ -9,22 +9,14 @@ class Form::Lettings::Subsections::Setup < ::Form::Subsection
def pages
@pages ||= [
Form::Lettings::Pages::StockOwner.new(nil, nil, self),
Form::Lettings::Pages::MinRentValueCheck.new("stock_owner_min_rent_value_check", nil, self),
Form::Lettings::Pages::MaxRentValueCheck.new("stock_owner_max_rent_value_check", nil, self),
Form::Lettings::Pages::ManagingOrganisation.new(nil, nil, self),
Form::Lettings::Pages::CreatedBy.new(nil, nil, self),
Form::Lettings::Pages::NeedsType.new(nil, nil, self),
Form::Lettings::Pages::Scheme.new(nil, nil, self),
Form::Lettings::Pages::Location.new(nil, nil, self),
Form::Lettings::Pages::MinRentValueCheck.new("needs_type_min_rent_value_check", nil, self),
Form::Lettings::Pages::MaxRentValueCheck.new("needs_type_max_rent_value_check", nil, self),
Form::Lettings::Pages::Renewal.new(nil, nil, self),
Form::Lettings::Pages::TenancyStartDate.new(nil, nil, self),
Form::Lettings::Pages::MinRentValueCheck.new("start_date_min_rent_value_check", nil, self),
Form::Lettings::Pages::MaxRentValueCheck.new("start_date_max_rent_value_check", nil, self),
Form::Lettings::Pages::RentType.new(nil, nil, self),
Form::Lettings::Pages::MinRentValueCheck.new("rent_type_min_rent_value_check", nil, self),
Form::Lettings::Pages::MaxRentValueCheck.new("rent_type_max_rent_value_check", nil, self),
Form::Lettings::Pages::TenantCode.new(nil, nil, self),
Form::Lettings::Pages::PropertyReference.new(nil, nil, self),
].compact

2
app/models/lettings_log.rb

@ -55,7 +55,7 @@ class LettingsLog < Log
scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org).or(where(managing_organisation: org)) }
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
OPTIONAL_FIELDS = %w[rent_value_check first_time_property_let_as_social_housing tenancycode propcode chcharge].freeze
OPTIONAL_FIELDS = %w[first_time_property_let_as_social_housing tenancycode propcode chcharge].freeze
RENT_TYPE_MAPPING_LABELS = { 1 => "Social Rent", 2 => "Affordable Rent", 3 => "Intermediate Rent" }.freeze
HAS_BENEFITS_OPTIONS = [1, 6, 8, 7].freeze
NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52, 10 => 53 }.freeze

16
spec/models/form/lettings/subsections/setup_spec.rb

@ -15,22 +15,14 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do
expect(setup.pages.map(&:id)).to eq(
%w[
stock_owner
stock_owner_min_rent_value_check
stock_owner_max_rent_value_check
managing_organisation
created_by
needs_type
scheme
location
needs_type_min_rent_value_check
needs_type_max_rent_value_check
renewal
tenancy_start_date
start_date_min_rent_value_check
start_date_max_rent_value_check
rent_type
rent_type_min_rent_value_check
rent_type_max_rent_value_check
tenant_code
property_reference
],
@ -50,22 +42,14 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do
expect(setup.pages.map(&:id)).to eq(
%w[
stock_owner
stock_owner_min_rent_value_check
stock_owner_max_rent_value_check
managing_organisation
created_by
needs_type
scheme
location
needs_type_min_rent_value_check
needs_type_max_rent_value_check
renewal
tenancy_start_date
start_date_min_rent_value_check
start_date_max_rent_value_check
rent_type
rent_type_min_rent_value_check
rent_type_max_rent_value_check
tenant_code
property_reference
],

Loading…
Cancel
Save