@ -1653,7 +1653,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
context " when soft validation is triggered and not required " do
context " when soft validation is triggered and not required " do
let ( :attributes ) { setup_section_params . merge ( { field_125 : 120 , field_123 : 1 , field_29 : 1 , field_4 : 1 , field_11 : " 1 " , field_23 : " E09000008 " } ) }
let ( :attributes ) { setup_section_params . merge ( { field_125 : 120 , field_126 : 120 , field_127 : 120 , field_128 : 120 , field_12 3 : 1 , field_29 : 1 , field_4 : 1 , field_11 : " 1 " , field_23 : " E09000008 " } ) }
it " adds an error to the relevant fields " do
it " adds an error to the relevant fields " do
expect ( parser . errors . where ( :field_125 , category : :soft_validation ) ) . to be_present
expect ( parser . errors . where ( :field_125 , category : :soft_validation ) ) . to be_present
@ -2240,7 +2240,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe " # chcharge " do
describe " # chcharge " do
let ( :attributes ) { { bulk_upload : , field_124 : " 123.45 " , field_125 : " 123.45 " , field_126 : " 123.45 " , field_127 : " 123.45 " , field_128 : " 123.45 " } }
let ( :attributes ) { setup_section_params . merge ( { field_124 : " 123.45 " , field_125 : " 123.45 " , field_126 : " 123.45 " , field_127 : " 123.45 " , field_128 : " 123.45 " } ) }
it " sets value given " do
it " sets value given " do
expect ( parser . log . chcharge ) . to eq ( 123 . 45 )
expect ( parser . log . chcharge ) . to eq ( 123 . 45 )
@ -2261,7 +2261,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe " # supcharg " do
describe " # supcharg " do
let ( :attributes ) { { bulk_upload : , field_128 : " 123.45 " } }
let ( :attributes ) { setup_section_params . merge ( { field_125 : " 330 " , field_126 : " 0 " , field_127 : " 0 " , field_128 : " 123.45 " } ) }
it " sets value given " do
it " sets value given " do
expect ( parser . log . supcharg ) . to eq ( 123 . 45 )
expect ( parser . log . supcharg ) . to eq ( 123 . 45 )
@ -2269,7 +2269,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
context " when other charges are not given " do
context " when other charges are not given " do
context " and it is carehome " do
context " and it is carehome " do
let ( :attributes ) { { bulk_upload : , field_128 : " 123.45 " , field_124 : " 123.45 " , field_125 : nil , field_126 : nil , field_127 : nil } }
let ( :attributes ) { setup_section_params . merge ( { field_128 : " 123.45 " , field_124 : " 123.45 " , field_125 : nil , field_126 : nil , field_127 : nil } ) }
it " does not set charges values " do
it " does not set charges values " do
parser . log . save!
parser . log . save!
@ -2290,7 +2290,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
context " and it is not carehome " do
context " and it is not carehome " do
let ( :attributes ) { { bulk_upload : , field_128 : " 123.45 " , field_124 : nil , field_125 : nil , field_126 : nil , field_127 : nil } }
let ( :attributes ) { setup_section_params . merge ( { field_128 : " 123.45 " , field_124 : nil , field_125 : nil , field_126 : nil , field_127 : nil } ) }
it " does not set charges values " do
it " does not set charges values " do
parser . log . save!
parser . log . save!
@ -2306,14 +2306,38 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
expect ( parser . errors [ :field_125 ] ) . to eql ( [ " Please enter the basic rent. If there is no basic rent, please enter '0'. " ] )
expect ( parser . errors [ :field_125 ] ) . to eql ( [ " Please enter the basic rent. If there is no basic rent, please enter '0'. " ] )
expect ( parser . errors [ :field_126 ] ) . to eql ( [ " Please enter the service charge. If there is no service charge, please enter '0'. " ] )
expect ( parser . errors [ :field_126 ] ) . to eql ( [ " Please enter the service charge. If there is no service charge, please enter '0'. " ] )
expect ( parser . errors [ :field_127 ] ) . to eql ( [ " Please enter the personal service charge. If there is no personal service charge, please enter '0'. " ] )
expect ( parser . errors [ :field_127 ] ) . to eql ( [ " Please enter the personal service charge. If there is no personal service charge, please enter '0'. " ] )
expect ( parser . errors [ :field_128 ] ) . to be_empty
expect ( parser . errors [ :field_128 ] ) . to eql ( [ " Please enter the basic rent. If there is no basic rent, please enter '0'. " , " Please enter the service charge. If there is no service charge, please enter '0'. " , " Please enter the personal service charge. If there is no personal service charge, please enter '0'. " ] )
end
end
end
context " when supscharg is not given " do
context " and it is not carehome " do
let ( :attributes ) { setup_section_params . merge ( { field_123 : 1 , field_124 : nil , field_125 : " 350.45 " , field_126 : " 0 " , field_127 : " 0 " , field_128 : nil } ) }
it " does not set charges values " do
parser . log . save!
expect ( parser . log . period ) . not_to be_nil
expect ( parser . log . tcharge ) . to be_nil
expect ( parser . log . brent ) . to be_nil
expect ( parser . log . supcharg ) . to be_nil
expect ( parser . log . pscharge ) . to be_nil
expect ( parser . log . scharge ) . to be_nil
end
it " adds an error to all charges " do
parser . valid?
expect ( parser . errors [ :field_125 ] ) . to eql ( [ " Please enter the support charge. If there is no support charge, please enter '0'. " ] )
expect ( parser . errors [ :field_126 ] ) . to eql ( [ " Please enter the support charge. If there is no support charge, please enter '0'. " ] )
expect ( parser . errors [ :field_127 ] ) . to eql ( [ " Please enter the support charge. If there is no support charge, please enter '0'. " ] )
expect ( parser . errors [ :field_128 ] ) . to eql ( [ " Please enter the support charge. If there is no support charge, please enter '0'. " ] )
end
end
end
end
end
end
end
end
describe " # pscharge " do
describe " # pscharge " do
let ( :attributes ) { { bulk_upload : , field_127 : " 123.45 " } }
let ( :attributes ) { { bulk_upload : , field_125 : " 111.45 " , field_126 : " 0 " , field_12 7 : " 123.45 " , field_128 : " 0 " } }
it " sets value given " do
it " sets value given " do
expect ( parser . log . pscharge ) . to eq ( 123 . 45 )
expect ( parser . log . pscharge ) . to eq ( 123 . 45 )
@ -2321,7 +2345,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe " # scharge " do
describe " # scharge " do
let ( :attributes ) { { bulk_upload : , field_126 : " 123.45 " } }
let ( :attributes ) { { bulk_upload : , field_125 : " 111.45 " , field_12 6 : " 123.45 " , field_127 : " 0 " , field_128 : " 0 " } }
it " sets value given " do
it " sets value given " do
expect ( parser . log . scharge ) . to eq ( 123 . 45 )
expect ( parser . log . scharge ) . to eq ( 123 . 45 )