|
|
|
@ -1,14 +1,16 @@ |
|
|
|
require "rails_helper" |
|
|
|
require "rails_helper" |
|
|
|
|
|
|
|
|
|
|
|
RSpec.describe Form::Sales::Pages::Deposit, type: :model do |
|
|
|
RSpec.describe Form::Sales::Pages::Deposit, type: :model do |
|
|
|
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional: false) } |
|
|
|
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional:) } |
|
|
|
|
|
|
|
|
|
|
|
let(:page_id) { nil } |
|
|
|
let(:page_id) { nil } |
|
|
|
let(:page_definition) { nil } |
|
|
|
let(:page_definition) { nil } |
|
|
|
let(:subsection) { instance_double(Form::Subsection) } |
|
|
|
let(:subsection) { instance_double(Form::Subsection, enabled?: true) } |
|
|
|
|
|
|
|
let(:form) { instance_double(Form, start_year_after_2024?: false, start_date: Time.zone.local(2023, 4, 1)) } |
|
|
|
|
|
|
|
let(:optional) { false } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: false, start_date: Time.zone.local(2023, 4, 1))) |
|
|
|
allow(subsection).to receive(:form).and_return(form) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has correct subsection" do |
|
|
|
it "has correct subsection" do |
|
|
|
@ -31,52 +33,202 @@ RSpec.describe Form::Sales::Pages::Deposit, type: :model do |
|
|
|
expect(page.description).to be_nil |
|
|
|
expect(page.description).to be_nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has correct depends_on" do |
|
|
|
context "when routing with start year after 2024" do |
|
|
|
expect(page.depends_on).to eq( |
|
|
|
before do |
|
|
|
[{ "social_homebuy?" => false, "ownershipsch" => 1 }, |
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(true) |
|
|
|
{ "ownershipsch" => 2 }, |
|
|
|
end |
|
|
|
{ "ownershipsch" => 3, "mortgageused" => 1 }, |
|
|
|
|
|
|
|
{ "social_homebuy?" => true }], |
|
|
|
context "and optional is false" do |
|
|
|
) |
|
|
|
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do |
|
|
|
end |
|
|
|
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) } |
|
|
|
|
|
|
|
|
|
|
|
context "when optional is true" do |
|
|
|
it "does not route to the page" do |
|
|
|
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional: true) } |
|
|
|
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 "has correct depends_on" do |
|
|
|
it "routes to the page" do |
|
|
|
expect(page.depends_on).to eq( |
|
|
|
expect(page).to be_routed_to(log, nil) |
|
|
|
[{ "social_homebuy?" => false, "ownershipsch" => 1 }, |
|
|
|
end |
|
|
|
{ "ownershipsch" => 2 }, |
|
|
|
end |
|
|
|
{ "ownershipsch" => 3, "mortgageused" => 1 }, |
|
|
|
|
|
|
|
{ "social_homebuy?" => true }], |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when it's a 2024 form" do |
|
|
|
context "when routing with start year before 2024" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: true, start_date: Time.zone.local(2024, 4, 1))) |
|
|
|
allow(form).to receive(:start_year_after_2024?).and_return(false) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "has correct depends_on" do |
|
|
|
context "and optional is false" do |
|
|
|
expect(page.depends_on).to eq( |
|
|
|
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do |
|
|
|
[{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => false }, |
|
|
|
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) } |
|
|
|
{ "ownershipsch" => 2 }, |
|
|
|
|
|
|
|
{ "ownershipsch" => 3, "mortgageused" => 1 }, |
|
|
|
it "routes to the page" do |
|
|
|
{ "social_homebuy?" => true, "stairowned_100?" => false }], |
|
|
|
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 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "and optional is true" do |
|
|
|
context "and optional is true" do |
|
|
|
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional: true) } |
|
|
|
let(:optional) { true } |
|
|
|
|
|
|
|
|
|
|
|
it "has correct depends_on" do |
|
|
|
context "and the log is shared ownership, not social homembuy and stairowned is not 100" do |
|
|
|
expect(page.depends_on).to eq( |
|
|
|
let(:log) { build(:sales_log, ownershipsch: 1, type: 16, stairowned: 70) } |
|
|
|
[{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => true }, |
|
|
|
|
|
|
|
{ "ownershipsch" => 2 }, |
|
|
|
it "does routes to the page" do |
|
|
|
{ "ownershipsch" => 3, "mortgageused" => 1 }, |
|
|
|
expect(page).to be_routed_to(log, nil) |
|
|
|
{ "social_homebuy?" => true, "stairowned_100?" => true }], |
|
|
|
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 |
|
|
|
end |
|
|
|
end |
|
|
|
|