diff --git a/app/models/form/sales/pages/buyer_2_living_in.rb b/app/models/form/sales/pages/buyer_2_living_in.rb new file mode 100644 index 000000000..b8d32ffdc --- /dev/null +++ b/app/models/form/sales/pages/buyer_2_living_in.rb @@ -0,0 +1,11 @@ +class Form::Sales::Pages::Buyer2LivingIn < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_2_living_in" + @depends_on = [{ "buyer_two_will_live_in_property?" => true }] + end + + def questions + @questions = [Form::Sales::Questions::Buyer2LivingIn.new(nil, nil, self)] + end +end diff --git a/app/models/form/sales/pages/buyer_2_previous_housing_situation.rb b/app/models/form/sales/pages/buyer_2_previous_housing_situation.rb new file mode 100644 index 000000000..c08501c09 --- /dev/null +++ b/app/models/form/sales/pages/buyer_2_previous_housing_situation.rb @@ -0,0 +1,11 @@ +class Form::Sales::Pages::Buyer2PreviousHousingSituation < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_2_previous_housing_situation" + @depends_on = [{ "buyer_two_not_already_living_in?" => true }] + end + + def questions + @questions = [Form::Sales::Questions::PreviousTenureBuyer2.new(nil, nil, self)] + end +end diff --git a/app/models/form/sales/questions/buyer_2_living_in.rb b/app/models/form/sales/questions/buyer_2_living_in.rb new file mode 100644 index 000000000..f05773169 --- /dev/null +++ b/app/models/form/sales/questions/buyer_2_living_in.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::Buyer2LivingIn < ::Form::Question + def initialize(id, hsh, page) + super + @id = "buy2living" + @check_answer_label = "All buyers living at the same address" + @header = "Were all buyers living at the same address at the time of purchase?" + @type = "radio" + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don't know" }, + }.freeze +end diff --git a/app/models/form/sales/questions/previous_tenure_buyer_2.rb b/app/models/form/sales/questions/previous_tenure_buyer_2.rb new file mode 100644 index 000000000..6de2ed8c5 --- /dev/null +++ b/app/models/form/sales/questions/previous_tenure_buyer_2.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::PreviousTenureBuyer2 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "prevtenbuy2" + @check_answer_label = "Buyer 2’s previous tenure" + @header = "What was buyer 2’s previous tenure?" + @type = "radio" + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Local Authority" }, + "2" => { "value" => "Private registered provider or housing association tenant" }, + "3" => { "value" => "Private tenant" }, + "5" => { "value" => "Owner occupier" }, + "4" => { "value" => "Tied home or renting with job" }, + "6" => { "value" => "Living with family or friends" }, + "7" => { "value" => "Temporary accomodation" }, + "9" => { "value" => "Other" }, + "0" => { "value" => "Don't know" }, + }.freeze +end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 07b0a978f..3628911b2 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -151,6 +151,14 @@ class SalesLog < Log inc1mort == 1 end + def buyer_two_will_live_in_property? + buy2livein == 1 + end + + def buyer_two_not_already_living_in? + buy2living == 2 + end + def income2_used_for_mortgage? inc2mort == 1 end diff --git a/spec/models/form/sales/pages/buyer_2_living_in_spec.rb b/spec/models/form/sales/pages/buyer_2_living_in_spec.rb new file mode 100644 index 000000000..9bfef1ff4 --- /dev/null +++ b/spec/models/form/sales/pages/buyer_2_living_in_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer2LivingIn, type: :model do + subject(:page) { described_class.new(nil, nil, subsection) } + + let(:subsection) { instance_double(Form::Subsection) } + + 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[buy2living]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_living_in") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "buyer_two_will_live_in_property?" => true }]) + end +end diff --git a/spec/models/form/sales/pages/buyer_2_previous_housing_situation_spec.rb b/spec/models/form/sales/pages/buyer_2_previous_housing_situation_spec.rb new file mode 100644 index 000000000..7d185c2ff --- /dev/null +++ b/spec/models/form/sales/pages/buyer_2_previous_housing_situation_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer2PreviousHousingSituation, type: :model do + subject(:page) { described_class.new(nil, nil, subsection) } + + let(:subsection) { instance_double(Form::Subsection) } + + 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[prevtenbuy2]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_previous_housing_situation") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "buyer_two_not_already_living_in?" => true }]) + end +end diff --git a/spec/models/form/sales/questions/buyer_2_living_in_spec.rb b/spec/models/form/sales/questions/buyer_2_living_in_spec.rb new file mode 100644 index 000000000..bb0e0d7ef --- /dev/null +++ b/spec/models/form/sales/questions/buyer_2_living_in_spec.rb @@ -0,0 +1,43 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer2LivingIn, type: :model do + subject(:question) { described_class.new(nil, nil, page) } + + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("buy2living") + end + + it "has the correct header" do + expect(question.header).to eq("Were all buyers living at the same address at the time of purchase?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("All buyers living at the same address") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint_text" do + expect(question.hint_text).to eq("") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don't know" }, + }) + end +end diff --git a/spec/models/form/sales/questions/previous_tenure_buyer_2_spec.rb b/spec/models/form/sales/questions/previous_tenure_buyer_2_spec.rb new file mode 100644 index 000000000..1ab7a86de --- /dev/null +++ b/spec/models/form/sales/questions/previous_tenure_buyer_2_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::PreviousTenureBuyer2, type: :model do + subject(:question) { described_class.new(nil, nil, page) } + + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("prevtenbuy2") + end + + it "has the correct header" do + expect(question.header).to eq("What was buyer 2’s previous tenure?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 2’s previous tenure") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint_text" do + expect(question.hint_text).to eq("") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Local Authority" }, + "2" => { "value" => "Private registered provider or housing association tenant" }, + "3" => { "value" => "Private tenant" }, + "5" => { "value" => "Owner occupier" }, + "4" => { "value" => "Tied home or renting with job" }, + "6" => { "value" => "Living with family or friends" }, + "7" => { "value" => "Temporary accomodation" }, + "9" => { "value" => "Other" }, + "0" => { "value" => "Don't know" }, + }) + end +end