Browse Source

fixup! CLDC-4168: Update tests

pull/3195/head
samyou-softwire 3 weeks ago
parent
commit
9b133b53fc
  1. 39
      spec/models/form/sales/subsections/outright_sale_spec.rb

39
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -1,18 +1,12 @@
require "rails_helper"
RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
include CollectionTimeHelper
subject(:outright_sale) { described_class.new(subsection_id, subsection_definition, section) }
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:start_year_2024_or_later?) { true }
let(:start_year_2025_or_later?) { true }
let(:start_year_2026_or_later?) { true }
let(:start_date) { current_collection_start_date }
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) }
let(:form) { instance_double(Form, start_date:, start_year_2024_or_later?: start_year_2024_or_later?, start_year_2025_or_later?: start_year_2025_or_later?, start_year_2026_or_later?: start_year_2026_or_later?) }
let(:form) { instance_double(Form) }
before do
allow(section).to receive(:form).and_return(form)
@ -25,13 +19,13 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
describe "pages" do
let(:section) { instance_double(described_class, form: instance_double(Form)) }
context "when 2024", metadata: { year: 24 } do
let(:start_year_2025_or_later?) { false }
let(:start_year_2026_or_later?) { false }
let(:start_date) { collection_start_date_for_year(2024) }
context "when 2022" do
before do
allow(form).to receive_messages(start_date: Time.zone.local(2022, 2, 8), start_year_2024_or_later?: false)
end
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
expect(outright_sale.pages.compact.map(&:id)).to eq(
%w[
purchase_price_outright_sale
about_price_outright_sale_value_check
@ -39,21 +33,23 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
outright_sale_mortgage_used_mortgage_value_check
mortgage_amount_outright_sale
outright_sale_mortgage_amount_mortgage_value_check
mortgage_lender_outright_sale
mortgage_lender_other_outright_sale
mortgage_length_outright_sale
extra_borrowing_outright_sale
deposit_outright_sale
outright_sale_deposit_joint_purchase_value_check
outright_sale_deposit_value_check
leasehold_charges_outright_sale
monthly_charges_outright_sale_value_check
],
)
end
end
context "when 2025", metadata: { year: 25 } do
let(:start_year_2026_or_later?) { false }
let(:start_date) { collection_start_date_for_year(2025) }
context "when 2023" do
before do
allow(form).to receive_messages(start_date: Time.zone.local(2023, 2, 8), start_year_2024_or_later?: false)
end
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
@ -64,6 +60,8 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
outright_sale_mortgage_used_mortgage_value_check
mortgage_amount_outright_sale
outright_sale_mortgage_amount_mortgage_value_check
mortgage_lender_outright_sale
mortgage_lender_other_outright_sale
mortgage_length_outright_sale
extra_borrowing_outright_sale
deposit_outright_sale
@ -76,8 +74,10 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
end
end
context "when 2026", metadata: { year: 26 } do
let(:start_date) { collection_start_date_for_year(2026) }
context "when 2024" do
before do
allow(form).to receive_messages(start_date: Time.zone.local(2024, 2, 8), start_year_2024_or_later?: true)
end
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
@ -88,8 +88,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
outright_sale_mortgage_used_mortgage_value_check
mortgage_amount_outright_sale
outright_sale_mortgage_amount_mortgage_value_check
mortgage_length_outright_sale_not_interviewed
mortgage_length_outright_sale_interviewed
mortgage_length_outright_sale
extra_borrowing_outright_sale
deposit_outright_sale
outright_sale_deposit_joint_purchase_value_check

Loading…
Cancel
Save