Browse Source

Check answer link text should say change if an answer is inferred (#418)

2021-2022-json-updates
baarkerlounger 3 years ago committed by GitHub
parent
commit
9811dd7273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/form/question.rb
  2. 12
      spec/models/form/question_spec.rb

4
app/models/form/question.rb

@ -74,7 +74,9 @@ class Form::Question
end
def update_answer_link_name(case_log)
link_type = if type == "checkbox"
link_type = if has_inferred_check_answers_value?(case_log)
"Change"
elsif type == "checkbox"
answer_options.keys.any? { |key| value_is_yes?(case_log[key]) } ? "Change" : "Answer"
else
case_log[id].blank? ? "Answer" : "Change"

12
spec/models/form/question_spec.rb

@ -207,6 +207,18 @@ RSpec.describe Form::Question, type: :model do
expect(question.update_answer_link_name(case_log)).to match(/Change/)
end
context "when the question has an inferred answer" do
let(:section_id) { "tenancy_and_property" }
let(:subsection_id) { "property_information" }
let(:page_id) { "property_postcode" }
let(:case_log) { FactoryBot.build(:case_log, :in_progress, postcode_known: 0, property_postcode: nil) }
let(:question_id) { "property_postcode" }
it "displays 'change' in the check answers link text" do
expect(question.update_answer_link_name(case_log)).to match(/Change/)
end
end
context "when type is date" do
let(:section_id) { "local_authority" }
let(:subsection_id) { "local_authority" }

Loading…
Cancel
Save