Browse Source

Fixes some tests

pull/705/head
Stéphane Meny 3 years ago
parent
commit
76386282f4
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 2
      app/models/form/setup/questions/location.rb
  2. 8
      app/models/form/setup/questions/scheme_id.rb
  3. 4
      spec/features/log_spec.rb
  4. 2
      spec/models/form/setup/questions/location_spec.rb
  5. 4
      spec/models/form/setup/questions/needs_type_spec.rb

2
app/models/form/setup/questions/location.rb

@ -19,6 +19,8 @@ class Form::Setup::Questions::Location < ::Form::Question
!supported_housing_selected?(case_log) !supported_housing_selected?(case_log)
end end
private
def supported_housing_selected?(case_log) def supported_housing_selected?(case_log)
case_log.needstype == 2 case_log.needstype == 2
end end

8
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) } answer_options.select { |k, _v| user_org_scheme_ids.include?(k) }
end end
def hidden_in_check_answers?(case_log, _current_user = nil)
!supported_housing_selected?(case_log)
end
private private
def selected_answer_option_is_derived?(_case_log) def selected_answer_option_is_derived?(_case_log)
false false
end end
def supported_housing_selected?(case_log)
case_log.needstype == 2
end
end end

4
spec/features/log_spec.rb

@ -90,7 +90,7 @@ RSpec.describe "Log Features" do
visit("logs/#{log_id}/setup/check-answers") visit("logs/#{log_id}/setup/check-answers")
expect(page).to have_content("Owning organisation #{support_user.organisation.name}") 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("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 end
end end
@ -120,7 +120,7 @@ RSpec.describe "Log Features" do
visit("logs/#{log_id}/setup/check-answers") 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("Owning organisation #{support_user.organisation.name}")
expect(page).not_to have_content("User #{support_user.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 end
end end

2
spec/models/form/setup/questions/location_spec.rb

@ -28,7 +28,7 @@ RSpec.describe Form::Setup::Questions::Location, type: :model do
end end
it "is marked as derived" do it "is marked as derived" do
expect(question.derived?).to be_falsey expect(question).not_to be_derived
end end
it "has the correct answer_options" do it "has the correct answer_options" do

4
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") expect(question.type).to eq("radio")
end end
it "is marked as derived" do it "is not marked as derived" do
expect(question.derived?).to be true expect(question).not_to be_derived
end end
it "has the correct answer_options" do it "has the correct answer_options" do

Loading…
Cancel
Save