Browse Source

amend wheelchair question class name, tweak depends on for readability, add test file

pull/1343/head
Arthur Campbell 3 years ago
parent
commit
bee46a3678
  1. 4
      app/models/form/lettings/pages/property_wheelchair_accessible.rb
  2. 1
      app/models/form/lettings/questions/voiddate.rb
  3. 7
      app/models/form/lettings/questions/wheelchair.rb
  4. 8
      db/schema.rb
  5. 42
      spec/models/form/lettings/questions/wheelchair_spec.rb

4
app/models/form/lettings/pages/property_wheelchair_accessible.rb

@ -2,10 +2,10 @@ class Form::Lettings::Pages::PropertyWheelchairAccessible < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "property_wheelchair_accessible" @id = "property_wheelchair_accessible"
@depends_on = [{ "needstype" => 1 }] @depends_on = [{ "is_supported_housing?" => false }]
end end
def questions def questions
@questions ||= [Form::Lettings::Questions::Wchair.new(nil, nil, self)] @questions ||= [Form::Lettings::Questions::Wheelchair.new(nil, nil, self)]
end end
end end

1
app/models/form/lettings/questions/voiddate.rb

@ -6,6 +6,5 @@ class Form::Lettings::Questions::Voiddate < ::Form::Question
@header = "What is the void or renewal date?" @header = "What is the void or renewal date?"
@type = "date" @type = "date"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = "For example, 27 3 2021."
end end
end end

7
app/models/form/lettings/questions/wchair.rb → app/models/form/lettings/questions/wheelchair.rb

@ -1,4 +1,4 @@
class Form::Lettings::Questions::Wchair < ::Form::Question class Form::Lettings::Questions::Wheelchair < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "wchair" @id = "wchair"
@ -10,5 +10,8 @@ class Form::Lettings::Questions::Wchair < ::Form::Question
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
end end
ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "2" => { "value" => "No" } }.freeze ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
}.freeze
end end

8
db/schema.rb

@ -490,7 +490,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_13_140932) do
t.integer "prevten" t.integer "prevten"
t.integer "mortgageused" t.integer "mortgageused"
t.integer "wchair" t.integer "wchair"
t.integer "income2_value_check"
t.integer "armedforcesspouse" t.integer "armedforcesspouse"
t.datetime "hodate", precision: nil t.datetime "hodate", precision: nil
t.integer "hoday" t.integer "hoday"
@ -515,13 +514,14 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_13_140932) do
t.integer "retirement_value_check" t.integer "retirement_value_check"
t.integer "hodate_check" t.integer "hodate_check"
t.integer "extrabor_value_check" t.integer "extrabor_value_check"
t.integer "grant_value_check"
t.integer "staircase_bought_value_check"
t.integer "deposit_and_mortgage_value_check" t.integer "deposit_and_mortgage_value_check"
t.integer "shared_ownership_deposit_value_check" t.integer "shared_ownership_deposit_value_check"
t.integer "grant_value_check"
t.integer "value_value_check"
t.integer "old_persons_shared_ownership_value_check" t.integer "old_persons_shared_ownership_value_check"
t.integer "staircase_bought_value_check" t.integer "income2_value_check"
t.integer "monthly_charges_value_check" t.integer "monthly_charges_value_check"
t.integer "value_value_check"
t.integer "details_known_5" t.integer "details_known_5"
t.integer "details_known_6" t.integer "details_known_6"
t.integer "saledate_check" t.integer "saledate_check"

42
spec/models/form/lettings/questions/wheelchair_spec.rb

@ -0,0 +1,42 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Wheelchair, 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("wchair")
end
it "has the correct header" do
expect(question.header).to eq("Is the property built or adapted to wheelchair-user standards?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Property built or adapted to wheelchair-user standards")
end
it "has the correct type" do
expect(question.type).to eq("radio")
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" },
})
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
end
Loading…
Cancel
Save