@ -981,18 +981,6 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end
end
describe " # field_119 " do
context " when validate_discounted_ownership_value is triggered " do
let ( :attributes ) { setup_section_params . merge ( field_116 : 100 , field_125 : 100 , field_7 : 2 , field_9 : 9 , field_119 : 2 , field_118 : 10 ) }
it " only adds errors to the discounted ownership field " do
expect ( parser . errors [ :field_105 ] ) . to be_empty
expect ( parser . errors [ :field_119 ] ) . to include ( " Mortgage, deposit, and grant total must equal £90.00. Your given mortgage, deposit and grant total is £100.00 " )
expect ( parser . errors [ :field_128 ] ) . to be_empty
end
end
end
describe " soft validations " do
context " when soft validation is triggered " do
let ( :attributes ) { valid_attributes . merge ( { field_30 : 22 , field_35 : 5 } ) }
@ -1020,6 +1008,108 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end
end
end
describe " # field_105 " do
context " when invalid value " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 4 " ) }
it " returns correct errors " do
expect ( parser . errors [ :field_105 ] ) . to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
end
context " when value is 3 and stairowned is not 100 " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 3 " , field_87 : " 1 " , field_88 : " 50 " , field_89 : " 99 " , field_111 : nil ) }
it " returns correct errors " do
expect ( parser . errors [ :field_105 ] ) . to include ( " The percentage owned has to be 100% if the mortgage used is 'Don’t know' " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
end
context " when value is 3 and stairowned is not answered " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 3 " , field_87 : " 1 " , field_88 : " 50 " , field_89 : nil , field_111 : nil ) }
it " does not add errors " do
expect ( parser . errors [ :field_105 ] ) . not_to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? - Shared ownership " )
expect ( parser . errors [ :field_105 ] ) . not_to include ( " The percentage owned has to be 100% if the mortgage used is 'Don’t know' " )
end
end
context " when value is 3 and stairowned is 100 " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 3 " , field_87 : " 1 " , field_88 : " 50 " , field_89 : " 100 " , field_111 : nil ) }
it " does not add errors " do
expect ( parser . errors [ :field_105 ] ) . to be_empty
expect ( parser . errors [ :field_119 ] ) . to be_empty
expect ( parser . errors [ :field_128 ] ) . to be_empty
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to eq ( 3 )
end
end
context " when it is not a staircasing transaction " do
context " when value is 3 and stairowned is not answered " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 3 " , field_87 : " 2 " , field_88 : " 50 " , field_89 : nil , field_111 : nil ) }
it " returns correct errors " do
expect ( parser . errors [ :field_105 ] ) . to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
end
context " when value is 3 and stairowned is 100 " do
let ( :attributes ) { setup_section_params . merge ( field_105 : " 3 " , field_87 : " 2 " , field_88 : " 50 " , field_89 : " 100 " , field_111 : nil ) }
it " returns correct errors " do
expect ( parser . errors [ :field_105 ] ) . to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
end
end
end
describe " # field_119 " do
let ( :attributes ) { valid_attributes . merge ( { field_7 : " 2 " , field_9 : " 8 " , field_119 : " 3 " } ) }
it " does not allow 3 (don't know) as an option for discounted ownership " do
expect ( parser . errors [ :field_119 ] ) . to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
context " when validate_discounted_ownership_value is triggered " do
let ( :attributes ) { setup_section_params . merge ( field_116 : 100 , field_125 : 100 , field_7 : 2 , field_9 : 9 , field_119 : 2 , field_118 : 10 ) }
it " only adds errors to the discounted ownership field " do
expect ( parser . errors [ :field_105 ] ) . to be_empty
expect ( parser . errors [ :field_119 ] ) . to include ( " Mortgage, deposit, and grant total must equal £90.00. Your given mortgage, deposit and grant total is £100.00 " )
expect ( parser . errors [ :field_128 ] ) . to be_empty
end
end
end
describe " # field_128 " do
let ( :attributes ) { valid_attributes . merge ( { field_7 : " 3 " , field_10 : " 10 " , field_128 : " 3 " , field_12 : " 2 " } ) }
it " does not allow 3 (don't know) as an option for outright sale " do
expect ( parser . errors [ :field_128 ] ) . to include ( " Enter a valid value for Was a mortgage used for the purchase of this property? " )
parser . log . blank_invalid_non_setup_fields!
parser . log . save!
expect ( parser . log . mortgageused ) . to be_nil
end
end
end
describe " # log " do