Browse Source

[CLDC-1502] Add household wheelchair question (#935)

pull/911/head
Jack S 2 years ago committed by GitHub
parent
commit
f2716ef0c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      app/models/form/sales/pages/household_wheelchair.rb
  2. 17
      app/models/form/sales/questions/household_wheelchair.rb
  3. 5
      app/models/form/sales/sections/household.rb
  4. 15
      app/models/form/sales/subsections/household_needs.rb
  5. 7
      db/migrate/20221005090129_add_wheel_to_sales_log.rb
  6. 1
      db/schema.rb
  7. 1
      spec/factories/sales_log.rb
  8. 7
      spec/models/form/sales/sections/household_spec.rb
  9. 4
      spec/models/form_handler_spec.rb

15
app/models/form/sales/pages/household_wheelchair.rb

@ -0,0 +1,15 @@
class Form::Sales::Pages::HouseholdWheelchair < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "household_wheelchair"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::HouseholdWheelchair.new(nil, nil, self),
]
end
end

17
app/models/form/sales/questions/household_wheelchair.rb

@ -0,0 +1,17 @@
class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question
def initialize(id, hsh, page)
super
@id = "wheel"
@header = "Does anyone in the household use a wheelchair?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
@hint_text = "This can be inside or outside the home"
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
"3" => { "value" => "Don't know" },
}.freeze
end

5
app/models/form/sales/sections/household.rb

@ -5,6 +5,9 @@ class Form::Sales::Sections::Household < ::Form::Section
@label = "About the household" @label = "About the household"
@description = "" @description = ""
@form = form @form = form
@subsections = [Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self)] || [] @subsections = [
Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self),
Form::Sales::Subsections::HouseholdNeeds.new(nil, nil, self),
]
end end
end end

15
app/models/form/sales/subsections/household_needs.rb

@ -0,0 +1,15 @@
class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
def initialize(id, hsh, section)
super
@id = "household_needs"
@label = "Household needs"
@section = section
@depends_on = [{ "setup" => "completed" }]
end
def pages
@pages ||= [
Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self),
]
end
end

7
db/migrate/20221005090129_add_wheel_to_sales_log.rb

@ -0,0 +1,7 @@
class AddWheelToSalesLog < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :wheel, :int
end
end
end

1
db/schema.rb

@ -355,6 +355,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do
t.integer "privacynotice" t.integer "privacynotice"
t.integer "ecstat1" t.integer "ecstat1"
t.integer "hholdcount" t.integer "hholdcount"
t.integer "wheel"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

1
spec/factories/sales_log.rb

@ -38,6 +38,7 @@ FactoryBot.define do
ecstat1 { "1" } ecstat1 { "1" }
ecstat2 { "1" } ecstat2 { "1" }
hholdcount { "1" } hholdcount { "1" }
wheel { 1 }
end end
end end
end end

7
spec/models/form/sales/sections/household_spec.rb

@ -12,7 +12,12 @@ RSpec.describe Form::Sales::Sections::Household, type: :model do
end end
it "has correct subsections" do it "has correct subsections" do
expect(household.subsections.map(&:id)).to eq(%w[household_characteristics]) expect(household.subsections.map(&:id)).to eq(
%w[
household_characteristics
household_needs
],
)
end end
it "has the correct id" do it "has the correct id" do

4
spec/models/form_handler_spec.rb

@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do it "is able to load a current sales form" do
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(34) expect(form.pages.count).to eq(35)
expect(form.name).to eq("2022_2023_sales") expect(form.name).to eq("2022_2023_sales")
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(34) expect(form.pages.count).to eq(35)
expect(form.name).to eq("2021_2022_sales") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save