Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

232 lines
7.4 KiB

CLDC-3541 Update sales financial validations (#2546) * CLDC-3569 Update social homebuy errors (#2541) * Split questions * Update the error message * Add guidance * Add back the headers * Refactor depends_on * Refactor further * CLDC-3569 Update missed errors (#2548) * Update some skipped error messages * Remove repeating deposit question * CLDC-3571 Discounted ownership validation (#2547) * Rename discount to deposit discount * Split about price rtb questions * Update error message * Update guidance partial * Fix top_guidance_partial method * Split about_price_not_rtb * Update guidance partial and validation * Fix bulk upload test * Update deposit routed_to and guidance * Refactor guidance links into a helper (#2551) * Refactor guidance links into a helper * Refactor discounted ownership guidance * CLDC-3570 Validations all other shared ownership types (#2550) * Update "all other shared ownership" errors * CLDC-3571 Update outright sale financial validations (#2549) * Update outright sale validation message * Add outright sale guidance * Update duplicate page id * User guidance helper * Fix up financial equations content (#2552) * Tweak shared ownership validation wording * Add top_guidance_partial to missed shared ownership questions * Update discounted ownership validation message when there's no grant * Update discounted sale guidance and errors * Lint and update test * Update BU test * Update test * CLDC-3569 Update guidance for shared ownership without mortgage (#2562) * Update how we display errors for BU * Update guidance for shared ownership * Add header to mortgage used question * Update shared ownership guidance * Update spacing (#2569) * Fix spacing again (#2570) * Update discounted ownership guidance (#2582) * Update discounted ownership guidance * Add top guidance partial to outright sale * Update outright sale guidance content * Update model test --------- Co-authored-by: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
5 months ago
require "rails_helper"
RSpec.describe Form::Sales::Pages::Deposit, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional:) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, enabled?: true, depends_on: true) }
let(:form) { instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1), depends_on_met: true) }
CLDC-3541 Update sales financial validations (#2546) * CLDC-3569 Update social homebuy errors (#2541) * Split questions * Update the error message * Add guidance * Add back the headers * Refactor depends_on * Refactor further * CLDC-3569 Update missed errors (#2548) * Update some skipped error messages * Remove repeating deposit question * CLDC-3571 Discounted ownership validation (#2547) * Rename discount to deposit discount * Split about price rtb questions * Update error message * Update guidance partial * Fix top_guidance_partial method * Split about_price_not_rtb * Update guidance partial and validation * Fix bulk upload test * Update deposit routed_to and guidance * Refactor guidance links into a helper (#2551) * Refactor guidance links into a helper * Refactor discounted ownership guidance * CLDC-3570 Validations all other shared ownership types (#2550) * Update "all other shared ownership" errors * CLDC-3571 Update outright sale financial validations (#2549) * Update outright sale validation message * Add outright sale guidance * Update duplicate page id * User guidance helper * Fix up financial equations content (#2552) * Tweak shared ownership validation wording * Add top_guidance_partial to missed shared ownership questions * Update discounted ownership validation message when there's no grant * Update discounted sale guidance and errors * Lint and update test * Update BU test * Update test * CLDC-3569 Update guidance for shared ownership without mortgage (#2562) * Update how we display errors for BU * Update guidance for shared ownership * Add header to mortgage used question * Update shared ownership guidance * Update spacing (#2569) * Fix spacing again (#2570) * Update discounted ownership guidance (#2582) * Update discounted ownership guidance * Add top guidance partial to outright sale * Update outright sale guidance content * Update model test --------- Co-authored-by: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
5 months ago
let(:optional) { false }
before do
allow(subsection).to receive(:form).and_return(form)
end
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[deposit])
end
it "has the correct id" do
expect(page.id).to eq(nil)
end
it "has the correct description" do
expect(page.description).to be_nil
end
context "when routing with start year after 2024" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
CLDC-3541 Update sales financial validations (#2546) * CLDC-3569 Update social homebuy errors (#2541) * Split questions * Update the error message * Add guidance * Add back the headers * Refactor depends_on * Refactor further * CLDC-3569 Update missed errors (#2548) * Update some skipped error messages * Remove repeating deposit question * CLDC-3571 Discounted ownership validation (#2547) * Rename discount to deposit discount * Split about price rtb questions * Update error message * Update guidance partial * Fix top_guidance_partial method * Split about_price_not_rtb * Update guidance partial and validation * Fix bulk upload test * Update deposit routed_to and guidance * Refactor guidance links into a helper (#2551) * Refactor guidance links into a helper * Refactor discounted ownership guidance * CLDC-3570 Validations all other shared ownership types (#2550) * Update "all other shared ownership" errors * CLDC-3571 Update outright sale financial validations (#2549) * Update outright sale validation message * Add outright sale guidance * Update duplicate page id * User guidance helper * Fix up financial equations content (#2552) * Tweak shared ownership validation wording * Add top_guidance_partial to missed shared ownership questions * Update discounted ownership validation message when there's no grant * Update discounted sale guidance and errors * Lint and update test * Update BU test * Update test * CLDC-3569 Update guidance for shared ownership without mortgage (#2562) * Update how we display errors for BU * Update guidance for shared ownership * Add header to mortgage used question * Update shared ownership guidance * Update spacing (#2569) * Fix spacing again (#2570) * Update discounted ownership guidance (#2582) * Update discounted ownership guidance * Add top guidance partial to outright sale * Update outright sale guidance content * Update model test --------- Co-authored-by: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
5 months ago
end
context "and optional is false" do
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, not social homembuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 100) }
it "does not route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 80) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 100) }
it "does not route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
context "and the log is discounted ownership" do
let(:log) { build(:sales_log, ownershipsch: 2, type: 18) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is outright ownership and mortgage used is yes" do
let(:log) { build(:sales_log, ownershipsch: 3, mortgageused: 1) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and ownership is outright sale and mortgage used is not yes" do
let(:log) { build(:sales_log, ownershipsch: 3, mortgageused: 2) }
it "doesn't route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
end
context "and optional is true" do
let(:optional) { true }
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) }
it "does not route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, not social homembuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 80) }
it "does not route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
end
end
context "when routing with start year before 2024" do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
CLDC-3541 Update sales financial validations (#2546) * CLDC-3569 Update social homebuy errors (#2541) * Split questions * Update the error message * Add guidance * Add back the headers * Refactor depends_on * Refactor further * CLDC-3569 Update missed errors (#2548) * Update some skipped error messages * Remove repeating deposit question * CLDC-3571 Discounted ownership validation (#2547) * Rename discount to deposit discount * Split about price rtb questions * Update error message * Update guidance partial * Fix top_guidance_partial method * Split about_price_not_rtb * Update guidance partial and validation * Fix bulk upload test * Update deposit routed_to and guidance * Refactor guidance links into a helper (#2551) * Refactor guidance links into a helper * Refactor discounted ownership guidance * CLDC-3570 Validations all other shared ownership types (#2550) * Update "all other shared ownership" errors * CLDC-3571 Update outright sale financial validations (#2549) * Update outright sale validation message * Add outright sale guidance * Update duplicate page id * User guidance helper * Fix up financial equations content (#2552) * Tweak shared ownership validation wording * Add top_guidance_partial to missed shared ownership questions * Update discounted ownership validation message when there's no grant * Update discounted sale guidance and errors * Lint and update test * Update BU test * Update test * CLDC-3569 Update guidance for shared ownership without mortgage (#2562) * Update how we display errors for BU * Update guidance for shared ownership * Add header to mortgage used question * Update shared ownership guidance * Update spacing (#2569) * Fix spacing again (#2570) * Update discounted ownership guidance (#2582) * Update discounted ownership guidance * Add top guidance partial to outright sale * Update outright sale guidance content * Update model test --------- Co-authored-by: Manny Dinssa <44172848+Dinssa@users.noreply.github.com>
5 months ago
end
context "and optional is false" do
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, not social homembuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 80) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is discounted ownership" do
let(:log) { build(:sales_log, ownershipsch: 2, type: 18) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is outright ownership and mortgage used is yes" do
let(:log) { build(:sales_log, ownershipsch: 3, mortgageused: 1) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and ownership is outright sale and mortgage used is not yes" do
let(:log) { build(:sales_log, ownershipsch: 3, mortgageused: 2) }
it "doesn't route to the page" do
expect(page).not_to be_routed_to(log, nil)
end
end
end
context "and optional is true" do
let(:optional) { true }
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) }
it "does routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, not social homembuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is not 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 80) }
it "does routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
context "and the log is shared ownership, social homebuy and stairowned is 100" do
let(:log) { build(:sales_log, ownershipsch: 1, type: 18, stairowned: 100) }
it "routes to the page" do
expect(page).to be_routed_to(log, nil)
end
end
end
end
end