|
|
|
@ -6,16 +6,24 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
|
|
|
|
|
let(:subsection_id) { nil } |
|
|
|
|
let(:subsection_definition) { nil } |
|
|
|
|
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } |
|
|
|
|
let(:form) { instance_double(Form) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
allow(section).to receive(:form).and_return(form) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has correct section" do |
|
|
|
|
expect(outright_sale.section).to eq(section) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "pages" do |
|
|
|
|
let(:section) { instance_double(described_class, form: instance_double(Form, start_date:)) } |
|
|
|
|
let(:section) { instance_double(described_class, form: instance_double(Form)) } |
|
|
|
|
|
|
|
|
|
context "when 2022" do |
|
|
|
|
let(:start_date) { Time.utc(2022, 2, 8) } |
|
|
|
|
before do |
|
|
|
|
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 2, 8)) |
|
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(false) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has correct pages" do |
|
|
|
|
expect(outright_sale.pages.compact.map(&:id)).to eq( |
|
|
|
@ -39,7 +47,11 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when 2023" do |
|
|
|
|
let(:start_date) { Time.utc(2023, 2, 8) } |
|
|
|
|
before do |
|
|
|
|
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 2, 8)) |
|
|
|
|
|
|
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(false) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has correct pages" do |
|
|
|
|
expect(outright_sale.pages.map(&:id)).to eq( |
|
|
|
@ -62,6 +74,32 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
|
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when 2024" do |
|
|
|
|
before do |
|
|
|
|
allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 2, 8)) |
|
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has correct pages" do |
|
|
|
|
expect(outright_sale.pages.map(&:id)).to eq( |
|
|
|
|
%w[ |
|
|
|
|
purchase_price_outright_sale |
|
|
|
|
about_price_outright_sale_value_check |
|
|
|
|
mortgage_used_outright_sale |
|
|
|
|
outright_sale_mortgage_used_mortgage_value_check |
|
|
|
|
mortgage_amount_outright_sale |
|
|
|
|
outright_sale_mortgage_amount_mortgage_value_check |
|
|
|
|
mortgage_length_outright_sale |
|
|
|
|
extra_borrowing_outright_sale |
|
|
|
|
about_deposit_outright_sale |
|
|
|
|
outright_sale_deposit_value_check |
|
|
|
|
leasehold_charges_outright_sale |
|
|
|
|
monthly_charges_outright_sale_value_check |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has the correct id" do |
|
|
|
|