Browse Source
* feat: add question page and subsection * refactor: linting * feat: remove schema rows from other branch * feat: slight refactor, fix tag behaviour and add section tests * test: update and add tests * feat: update status behaviour * feat: update subsection status tag * refactor: lintingpull/1122/head
15 changed files with 227 additions and 4 deletions
@ -0,0 +1,15 @@
|
||||
class Form::Sales::Pages::BuyersOrganisations < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "buyers_organisations" |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::BuyersOrganisations.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,19 @@
|
||||
class Form::Sales::Questions::BuyersOrganisations < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "buyers_organisations" |
||||
@check_answer_label = "Organisations buyers were registered with" |
||||
@header = "What organisations were the buyers registered with?" |
||||
@type = "checkbox" |
||||
@hint_text = "Select all that apply" |
||||
@page = page |
||||
@answer_options = ANSWER_OPTIONS |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"pregyrha" => { "value" => "Their private registered provider (PRP) - housing association" }, |
||||
"pregother" => { "value" => "Other private registered provider (PRP) - housing association" }, |
||||
"pregla" => { "value" => "Local Authority" }, |
||||
"pregghb" => { "value" => "Help to Buy Agent" }, |
||||
}.freeze |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection |
||||
def initialize(id, hsh, section) |
||||
super |
||||
@id = "household_situation" |
||||
@label = "Household situation" |
||||
@section = section |
||||
@depends_on = [{ "setup_completed?" => true }] |
||||
end |
||||
|
||||
def pages |
||||
@pages ||= [ |
||||
Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,10 @@
|
||||
class AddBuyersOrganisationsToSalesLog < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :pregyrha, :int |
||||
t.column :pregla, :int |
||||
t.column :pregghb, :int |
||||
t.column :pregother, :integer |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::BuyersOrganisations, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
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[buyers_organisations]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("buyers_organisations") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
end |
||||
@ -0,0 +1,48 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::BuyersOrganisations, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
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("buyers_organisations") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What organisations were the buyers registered with?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Organisations buyers were registered with") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("checkbox") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("Select all that apply") |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"pregyrha" => { "value" => "Their private registered provider (PRP) - housing association" }, |
||||
"pregother" => { "value" => "Other private registered provider (PRP) - housing association" }, |
||||
"pregla" => { "value" => "Local Authority" }, |
||||
"pregghb" => { "value" => "Help to Buy Agent" }, |
||||
}, |
||||
) |
||||
end |
||||
end |
||||
@ -0,0 +1,34 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do |
||||
subject(:household_characteristics) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Sales::Sections::Household) } |
||||
|
||||
it "has correct section" do |
||||
expect(household_characteristics.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(household_characteristics.pages.map(&:id)).to eq( |
||||
%w[ |
||||
household_wheelchair |
||||
household_disability |
||||
], |
||||
) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(household_characteristics.id).to eq("household_needs") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(household_characteristics.label).to eq("Household needs") |
||||
end |
||||
|
||||
it "has correct depends on" do |
||||
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) |
||||
end |
||||
end |
||||
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do |
||||
subject(:household_characteristics) { described_class.new(subsection_id, subsection_definition, section) } |
||||
|
||||
let(:subsection_id) { nil } |
||||
let(:subsection_definition) { nil } |
||||
let(:section) { instance_double(Form::Sales::Sections::Household) } |
||||
|
||||
it "has correct section" do |
||||
expect(household_characteristics.section).to eq(section) |
||||
end |
||||
|
||||
it "has correct pages" do |
||||
expect(household_characteristics.pages.map(&:id)).to eq( |
||||
%w[ |
||||
buyers_organisations |
||||
], |
||||
) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(household_characteristics.id).to eq("household_situation") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(household_characteristics.label).to eq("Household situation") |
||||
end |
||||
|
||||
it "has correct depends on" do |
||||
expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) |
||||
end |
||||
end |
||||
Loading…
Reference in new issue