Browse Source

Add Property Wheelchair Accessible question

pull/1145/head
Jack S 3 years ago
parent
commit
9c7b011bd3
  1. 15
      app/models/form/sales/pages/property_wheelchair_accessible.rb
  2. 17
      app/models/form/sales/questions/property_wheelchair_accessible.rb
  3. 1
      app/models/form/sales/subsections/property_information.rb
  4. 7
      db/migrate/20230104152012_add_wchair_to_sales_log.rb
  5. 1
      db/schema.rb
  6. 1
      spec/factories/sales_log.rb
  7. 3
      spec/models/form/sales/pages/property_local_authority_spec.rb
  8. 29
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
  9. 41
      spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb
  10. 1
      spec/models/form/sales/subsections/property_information_spec.rb
  11. 4
      spec/models/form_handler_spec.rb

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

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

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

@ -0,0 +1,17 @@
class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question
def initialize(id, hsh, page)
super
@id = "wchair"
@check_answer_label = "Property build or adapted to wheelchair-user standards"
@header = "Is the property build or adapted to wheelchair-user standards?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
"3" => { "value" => "Don't know" },
}.freeze
end

1
app/models/form/sales/subsections/property_information.rb

@ -13,6 +13,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
]
end
end

7
db/migrate/20230104152012_add_wchair_to_sales_log.rb

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

1
db/schema.rb

@ -459,6 +459,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_04_164318) do
t.integer "deposit_value_check"
t.integer "hb"
t.integer "mortgageused"
t.integer "wchair"
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 ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

1
spec/factories/sales_log.rb

@ -88,6 +88,7 @@ FactoryBot.define do
relat6 { "P" }
hb { 4 }
mortgageused { 1 }
wchair { 1 }
end
end
end

3
spec/models/form/sales/pages/property_local_authority_spec.rb

@ -16,7 +16,8 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
%w[
la_known
la
])
],
)
end
it "has the correct id" do

29
spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, 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[wchair])
end
it "has the correct id" do
expect(page.id).to eq("property_wheelchair_accessible")
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
end

41
spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb

@ -0,0 +1,41 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PropertyWheelchairAccessible, 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("wchair")
end
it "has the correct header" do
expect(question.header).to eq("Is the property build or adapted to wheelchair-user standards?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Property build or adapted to wheelchair-user standards")
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 answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
"3" => { "value" => "Don't know" },
})
end
end

1
spec/models/form/sales/subsections/property_information_spec.rb

@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
property_building_type
property_unit_type
property_local_authority
property_wheelchair_accessible
],
)
end

4
spec/models/form_handler_spec.rb

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

Loading…
Cancel
Save