@ -1,16 +1,17 @@
require " rails_helper "
RSpec . describe Form :: Sales :: Questions :: MortgageLender , type : :model do
include CollectionTimeHelper
subject ( :question ) { described_class . new ( question_id , question_definition , page , ownershipsch : 1 ) }
let ( :question_id ) { nil }
let ( :question_definition ) { nil }
let ( :page ) { instance_double ( Form :: Page ) }
let ( :subsection ) { instance_double ( Form :: Subsection ) }
let ( :form ) { instance_double ( Form , start_date : Time . zone . local ( 2023 , 4 , 1 ) ) }
let ( :form ) { instance_double ( Form , start_date : current_collection_start_date ) }
before do
allow ( form ) . to receive ( :start_year_2024_or_later? )
allow ( page ) . to receive ( :subsection ) . and_return ( subsection )
allow ( subsection ) . to receive ( :form ) . and_return ( form )
end
@ -44,203 +45,98 @@ RSpec.describe Form::Sales::Questions::MortgageLender, type: :model do
expect ( question . top_guidance_partial ) . to be_nil
end
context " when form year is before 2024 " do
before do
allow ( form ) . to receive ( :start_year_2024_or_later? ) . and_return ( false )
end
it " has the correct answer_options " do
expect ( question . answer_options ) . to eq ( {
" " = > " Select an option " ,
" 0 " = > " Don’t know " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 40 " = > " Other " ,
} )
end
it " has the correct displayed_answer_options " do
expect ( question . displayed_answer_options ( nil , nil ) ) . to eq ( {
" " = > " Select an option " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 40 " = > " Other " ,
} )
end
it " has the correct answer_options " do
expect ( question . answer_options ) . to eq ( {
" " = > " Select an option " ,
" 0 " = > " Don’t know " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 41 " = > " Kent Reliance " ,
" 40 " = > " Other " ,
} )
end
context " when form year is >= 2024 " do
before do
allow ( form ) . to receive ( :start_year_2024_or_later? ) . and_return ( true )
end
it " has the correct answer_options " do
expect ( question . answer_options ) . to eq ( {
" " = > " Select an option " ,
" 0 " = > " Don’t know " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 41 " = > " Kent Reliance " ,
" 40 " = > " Other " ,
} )
end
it " has the correct displayed_answer_options " do
expect ( question . displayed_answer_options ( nil , nil ) ) . to eq ( {
" " = > " Select an option " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 41 " = > " Kent Reliance " ,
" 40 " = > " Other " ,
} )
end
it " has the correct displayed_answer_options " do
expect ( question . displayed_answer_options ( nil , nil ) ) . to eq ( {
" " = > " Select an option " ,
" 1 " = > " Atom Bank " ,
" 2 " = > " Barclays Bank PLC " ,
" 3 " = > " Bath Building Society " ,
" 4 " = > " Buckinghamshire Building Society " ,
" 5 " = > " Cambridge Building Society " ,
" 6 " = > " Coventry Building Society " ,
" 7 " = > " Cumberland Building Society " ,
" 8 " = > " Darlington Building Society " ,
" 9 " = > " Dudley Building Society " ,
" 10 " = > " Ecology Building Society " ,
" 11 " = > " Halifax " ,
" 12 " = > " Hanley Economic Building Society " ,
" 13 " = > " Hinckley and Rugby Building Society " ,
" 14 " = > " Holmesdale Building Society " ,
" 15 " = > " Ipswich Building Society " ,
" 16 " = > " Leeds Building Society " ,
" 17 " = > " Lloyds Bank " ,
" 18 " = > " Mansfield Building Society " ,
" 19 " = > " Market Harborough Building Society " ,
" 20 " = > " Melton Mowbray Building Society " ,
" 21 " = > " Nationwide Building Society " ,
" 22 " = > " Natwest " ,
" 23 " = > " Nedbank Private Wealth " ,
" 24 " = > " Newbury Building Society " ,
" 25 " = > " OneSavings Bank " ,
" 26 " = > " Parity Trust " ,
" 27 " = > " Penrith Building Society " ,
" 28 " = > " Pepper Homeloans " ,
" 29 " = > " Royal Bank of Scotland " ,
" 30 " = > " Santander " ,
" 31 " = > " Skipton Building Society " ,
" 32 " = > " Teachers Building Society " ,
" 33 " = > " The Co-operative Bank " ,
" 34 " = > " Tipton & Coseley Building Society " ,
" 35 " = > " TSB " ,
" 36 " = > " Ulster Bank " ,
" 37 " = > " Virgin Money " ,
" 38 " = > " West Bromwich Building Society " ,
" 39 " = > " Yorkshire Building Society " ,
" 41 " = > " Kent Reliance " ,
" 40 " = > " Other " ,
} )
end
end