Browse Source
* create and run migration for new columns related to buyer two previous tenure * a little refactoring for readability * create new pages, questions, associated tests and a couple of boolean methods on sales log for depends_on readability * add new pages to subsection and amend tests to reflect this change * make new pages only visible for new collection year, rename filesamend tests * some copy changes and alterations of readability after code reviewpull/1409/head
Arthur Campbell
2 years ago
committed by
GitHub
15 changed files with 287 additions and 20 deletions
@ -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 |
@ -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_property?" => true }] |
||||
end |
||||
|
||||
def questions |
||||
@questions = [Form::Sales::Questions::PreviousTenureBuyer2.new(nil, nil, self)] |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Questions::Buyer2LivingIn < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "buy2living" |
||||
@check_answer_label = "Buyer 2 living at the same address" |
||||
@header = "At the time of purchase, was buyer 2 living at the same address as buyer 1?" |
||||
@type = "radio" |
||||
@hint_text = "" |
||||
@answer_options = ANSWER_OPTIONS |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No" }, |
||||
"3" => { "value" => "Don't know" }, |
||||
}.freeze |
||||
end |
@ -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 |
@ -0,0 +1,8 @@
|
||||
class AddColumnsToSalesLog < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :buy2living, :integer |
||||
t.column :prevtenbuy2, :integer |
||||
end |
||||
end |
||||
end |
@ -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 |
@ -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_property?" => true }]) |
||||
end |
||||
end |
@ -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 "At the time of purchase, was buyer 2 living at the same address as buyer 1?" |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq "Buyer 2 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 |
@ -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 |
Loading…
Reference in new issue