diff --git a/app/models/form/setup/questions/location.rb b/app/models/form/setup/questions/location.rb index afcf8c90a..146e54ead 100644 --- a/app/models/form/setup/questions/location.rb +++ b/app/models/form/setup/questions/location.rb @@ -19,6 +19,8 @@ class Form::Setup::Questions::Location < ::Form::Question !supported_housing_selected?(case_log) end +private + def supported_housing_selected?(case_log) case_log.needstype == 2 end diff --git a/app/models/form/setup/questions/scheme_id.rb b/app/models/form/setup/questions/scheme_id.rb index 79caeedc9..9e76238b2 100644 --- a/app/models/form/setup/questions/scheme_id.rb +++ b/app/models/form/setup/questions/scheme_id.rb @@ -25,9 +25,17 @@ class Form::Setup::Questions::SchemeId < ::Form::Question answer_options.select { |k, _v| user_org_scheme_ids.include?(k) } end + def hidden_in_check_answers?(case_log, _current_user = nil) + !supported_housing_selected?(case_log) + end + private def selected_answer_option_is_derived?(_case_log) false end + + def supported_housing_selected?(case_log) + case_log.needstype == 2 + end end diff --git a/spec/features/log_spec.rb b/spec/features/log_spec.rb index f88196d6f..69623aff8 100644 --- a/spec/features/log_spec.rb +++ b/spec/features/log_spec.rb @@ -90,7 +90,7 @@ RSpec.describe "Log Features" do visit("logs/#{log_id}/setup/check-answers") expect(page).to have_content("Owning organisation #{support_user.organisation.name}") expect(page).to have_content("User #{support_user.name}") - expect(page).to have_content("You have answered 2 of 7 questions") + expect(page).to have_content("You have answered 2 of 8 questions") end end end @@ -120,7 +120,7 @@ RSpec.describe "Log Features" do visit("logs/#{log_id}/setup/check-answers") expect(page).not_to have_content("Owning organisation #{support_user.organisation.name}") expect(page).not_to have_content("User #{support_user.name}") - expect(page).to have_content("You have answered 0 of 5 questions") + expect(page).to have_content("You have answered 0 of 6 questions") end end end diff --git a/spec/models/form/setup/questions/location_spec.rb b/spec/models/form/setup/questions/location_spec.rb index 13a23a3f5..faf350cbf 100644 --- a/spec/models/form/setup/questions/location_spec.rb +++ b/spec/models/form/setup/questions/location_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Form::Setup::Questions::Location, type: :model do end it "is marked as derived" do - expect(question.derived?).to be_falsey + expect(question).not_to be_derived end it "has the correct answer_options" do diff --git a/spec/models/form/setup/questions/needs_type_spec.rb b/spec/models/form/setup/questions/needs_type_spec.rb index 485ac4164..c10fcb3b1 100644 --- a/spec/models/form/setup/questions/needs_type_spec.rb +++ b/spec/models/form/setup/questions/needs_type_spec.rb @@ -27,8 +27,8 @@ RSpec.describe Form::Setup::Questions::NeedsType, type: :model do expect(question.type).to eq("radio") end - it "is marked as derived" do - expect(question.derived?).to be true + it "is not marked as derived" do + expect(question).not_to be_derived end it "has the correct answer_options" do