diff --git a/app/models/form/sales/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb new file mode 100644 index 000000000..d587d61a7 --- /dev/null +++ b/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 diff --git a/app/models/form/sales/questions/property_wheelchair_accessible.rb b/app/models/form/sales/questions/property_wheelchair_accessible.rb new file mode 100644 index 000000000..0290815ef --- /dev/null +++ b/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 diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 2a29e27c2..02d7b4037 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/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 diff --git a/db/migrate/20230104152012_add_wchair_to_sales_log.rb b/db/migrate/20230104152012_add_wchair_to_sales_log.rb new file mode 100644 index 000000000..62097c944 --- /dev/null +++ b/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 diff --git a/db/schema.rb b/db/schema.rb index 4ebaba663..57fe3142d 100644 --- a/db/schema.rb +++ b/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" diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index 138a5c394..f11044c89 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -88,6 +88,7 @@ FactoryBot.define do relat6 { "P" } hb { 4 } mortgageused { 1 } + wchair { 1 } end end end diff --git a/spec/models/form/sales/pages/property_local_authority_spec.rb b/spec/models/form/sales/pages/property_local_authority_spec.rb index 6f4230c60..17b840186 100644 --- a/spec/models/form/sales/pages/property_local_authority_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb new file mode 100644 index 000000000..f2ffb3567 --- /dev/null +++ b/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 diff --git a/spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb new file mode 100644 index 000000000..c8d7eadaf --- /dev/null +++ b/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 diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index 284d0e02c..b512c8e5e 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/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 diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 83e1aa582..fa392fdf2 100644 --- a/spec/models/form_handler_spec.rb +++ b/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