|
|
|
@ -1,6 +1,8 @@ |
|
|
|
require "rails_helper" |
|
|
|
require "rails_helper" |
|
|
|
|
|
|
|
|
|
|
|
RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
|
|
|
|
include CollectionTimeHelper |
|
|
|
|
|
|
|
|
|
|
|
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch:) } |
|
|
|
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch:) } |
|
|
|
|
|
|
|
|
|
|
|
let(:question_id) { nil } |
|
|
|
let(:question_id) { nil } |
|
|
|
@ -9,16 +11,17 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
let(:staircase) { nil } |
|
|
|
let(:staircase) { nil } |
|
|
|
let(:saledate) { Time.zone.today } |
|
|
|
let(:saledate) { Time.zone.today } |
|
|
|
let(:log) { build(:sales_log, :in_progress, ownershipsch:, stairowned:, staircase:) } |
|
|
|
let(:log) { build(:sales_log, :in_progress, ownershipsch:, stairowned:, staircase:) } |
|
|
|
|
|
|
|
let(:start_year_2024_or_later?) { true } |
|
|
|
context "when the form start year is 2024" do |
|
|
|
let(:start_year_2025_or_later?) { true } |
|
|
|
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } |
|
|
|
let(:start_year_2026_or_later?) { true } |
|
|
|
|
|
|
|
let(:form) { instance_double(Form, start_date: saledate, 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(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "shared_ownership")) } |
|
|
|
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "shared_ownership")) } |
|
|
|
let(:saledate) { Time.zone.local(2024, 5, 1) } |
|
|
|
|
|
|
|
let(:ownershipsch) { 1 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
context "when the form start year is 2024", metadata: { year: 24 } do |
|
|
|
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false) |
|
|
|
let(:saledate) { collection_start_date_for_year(2024) } |
|
|
|
end |
|
|
|
let(:ownershipsch) { 1 } |
|
|
|
|
|
|
|
let(:start_year_2025_or_later?) { false } |
|
|
|
|
|
|
|
let(:start_year_2026_or_later?) { false } |
|
|
|
|
|
|
|
|
|
|
|
it "has the correct answer_options" do |
|
|
|
it "has the correct answer_options" do |
|
|
|
expect(question.answer_options).to eq({ |
|
|
|
expect(question.answer_options).to eq({ |
|
|
|
@ -44,20 +47,10 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
context "when it is an outright sale" do |
|
|
|
context "when it is an outright sale" do |
|
|
|
let(:ownershipsch) { 3 } |
|
|
|
let(:ownershipsch) { 3 } |
|
|
|
|
|
|
|
|
|
|
|
context "and the saledate is before 24/25" do |
|
|
|
|
|
|
|
let(:saledate) { Time.zone.local(2023, 5, 1) }\ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does show the don't know option" do |
|
|
|
|
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "and the saledate is 24/25" do |
|
|
|
|
|
|
|
it "shows the don't know option" do |
|
|
|
it "shows the don't know option" do |
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when it is a shared ownership scheme" do |
|
|
|
context "when it is a shared ownership scheme" do |
|
|
|
let(:ownershipsch) { 1 } |
|
|
|
let(:ownershipsch) { 1 } |
|
|
|
@ -92,14 +85,9 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when the form start year is 2025" do |
|
|
|
context "when the form start year is 2025", metadata: { year: 25 } do |
|
|
|
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } |
|
|
|
let(:saledate) { collection_start_date_for_year(2025) } |
|
|
|
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "shared_ownership")) } |
|
|
|
let(:start_year_2026_or_later?) { false } |
|
|
|
let(:saledate) { Time.zone.local(2025, 5, 1) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when it is a discounted ownership sale" do |
|
|
|
context "when it is a discounted ownership sale" do |
|
|
|
let(:ownershipsch) { 2 } |
|
|
|
let(:ownershipsch) { 2 } |
|
|
|
@ -142,6 +130,42 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when the form start year is 2026", metadata: { year: 26 } do |
|
|
|
|
|
|
|
let(:saledate) { collection_start_date_for_year(2026) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when it is a discounted ownership sale" do |
|
|
|
|
|
|
|
let(:ownershipsch) { 2 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "shows the correct question number" do |
|
|
|
|
|
|
|
expect(question.question_number).to eq 106 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does show the don't know option" do |
|
|
|
|
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when it is a shared ownership scheme" do |
|
|
|
|
|
|
|
let(:ownershipsch) { 1 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "and it is a staircasing transaction" do |
|
|
|
|
|
|
|
let(:staircase) { 1 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does show the don't know option" do |
|
|
|
|
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "and it is not a staircasing transaction" do |
|
|
|
|
|
|
|
let(:staircase) { 2 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does show the don't know option" do |
|
|
|
|
|
|
|
expect_the_question_to_show_dont_know |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def expect_the_question_not_to_show_dont_know |
|
|
|
def expect_the_question_not_to_show_dont_know |
|
|
|
|