diff --git a/app/models/form/lettings/pages/previous_housing_situation.rb b/app/models/form/lettings/pages/previous_housing_situation.rb index 182d964df..aafabe7f3 100644 --- a/app/models/form/lettings/pages/previous_housing_situation.rb +++ b/app/models/form/lettings/pages/previous_housing_situation.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituation < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_housing_situation" - @depends_on = [{ "renewal" => 0 }] + @depends_on = [{ "is_renewal?" => false }] end def questions diff --git a/app/models/form/lettings/pages/previous_housing_situation_renewal.rb b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb index 627be0a78..317350911 100644 --- a/app/models/form/lettings/pages/previous_housing_situation_renewal.rb +++ b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituationRenewal < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_housing_situation_renewal" - @depends_on = [{ "renewal" => 1, "needstype" => 2 }] + @depends_on = [{ "is_renewal?" => true, "is_supported_housing?" => true }] end def questions diff --git a/spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb b/spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb new file mode 100644 index 000000000..4bdc2d8a3 --- /dev/null +++ b/spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PreviousHousingSituationRenewal, type: :model do + subject(:page) { described_class.new(nil, nil, subsection) } + + 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[prevten]) + end + + it "has the correct id" do + expect(page.id).to eq("previous_housing_situation_renewal") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has the correct depends_on" do + expect(page.depends_on).to eq([{ "is_renewal?" => true, "is_supported_housing?" => true }]) + end +end diff --git a/spec/models/form/lettings/pages/previous_housing_situation_spec.rb b/spec/models/form/lettings/pages/previous_housing_situation_spec.rb new file mode 100644 index 000000000..c891996c9 --- /dev/null +++ b/spec/models/form/lettings/pages/previous_housing_situation_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PreviousHousingSituation, type: :model do + subject(:page) { described_class.new(nil, nil, subsection) } + + 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[prevten]) + end + + it "has the correct id" do + expect(page.id).to eq("previous_housing_situation") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has the correct depends_on" do + expect(page.depends_on).to eq([{ "is_renewal?" => false }]) + end +end