Browse Source

Update answer links

CLDC-3465-update-setup-question-link
Kat 9 months ago
parent
commit
4209fbed03
  1. 6
      app/components/check_answers_summary_list_card_component.rb
  2. 15
      spec/requests/check_your_errors_controller_spec.rb

6
app/components/check_answers_summary_list_card_component.rb

@ -31,7 +31,11 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
def action_href(question, log, correcting_hard_validation: false) def action_href(question, log, correcting_hard_validation: false)
if correcting_hard_validation if correcting_hard_validation
lettings_log_confirm_clear_answer_path(log, question_id: question.id, related_question_ids: request.query_parameters["related_question_ids"], original_question_id: request.query_parameters["original_question_id"]) if question.displayed_as_answered?(log)
lettings_log_confirm_clear_answer_path(log, question_id: question.id, related_question_ids: request.query_parameters["related_question_ids"], original_question_id: request.query_parameters["original_question_id"])
else
send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer: "check_your_errors", related_question_ids: request.query_parameters["related_question_ids"], original_question_id: request.query_parameters["original_question_id"])
end
else else
referrer = question.displayed_as_answered?(log) ? "check_answers" : "check_answers_new_answer" referrer = question.displayed_as_answered?(log) ? "check_answers" : "check_answers_new_answer"
send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer:) send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer:)

15
spec/requests/check_your_errors_controller_spec.rb

@ -27,7 +27,7 @@ RSpec.describe CheckYourErrorsController, type: :request do
end end
context "when user is signed in" do context "when user is signed in" do
context "with multiple error fields" do context "with multiple error fields and answered questions" do
before do before do
sign_in user sign_in user
get "/lettings-logs/#{lettings_log.id}/check-your-errors?related_question_ids[]=startdate&related_question_ids[]=needstype&original_question_id=startdate" get "/lettings-logs/#{lettings_log.id}/check-your-errors?related_question_ids[]=startdate&related_question_ids[]=needstype&original_question_id=startdate"
@ -39,6 +39,19 @@ RSpec.describe CheckYourErrorsController, type: :request do
expect(page).to have_link("Clear all", href: "/lettings-logs/#{lettings_log.id}/confirm-clear-all-answers?original_question_id=startdate&related_question_ids%5B%5D=startdate&related_question_ids%5B%5D=needstype") expect(page).to have_link("Clear all", href: "/lettings-logs/#{lettings_log.id}/confirm-clear-all-answers?original_question_id=startdate&related_question_ids%5B%5D=startdate&related_question_ids%5B%5D=needstype")
end end
end end
context "with multiple error fields and unanswered questions" do
before do
lettings_log.update!(needstype: nil, startdate: nil)
sign_in user
get "/lettings-logs/#{lettings_log.id}/check-your-errors?related_question_ids[]=startdate&related_question_ids[]=needstype&original_question_id=startdate"
end
it "displays correct clear links" do
expect(page).to have_link("Answer", href: "/lettings-logs/#{lettings_log.id}/needs-type?original_question_id=startdate&referrer=check_your_errors&related_question_ids%5B%5D=startdate&related_question_ids%5B%5D=needstype")
expect(page).to have_link("Answer", href: "/lettings-logs/#{lettings_log.id}/tenancy-start-date?original_question_id=startdate&referrer=check_your_errors&related_question_ids%5B%5D=startdate&related_question_ids%5B%5D=needstype")
end
end
end end
end end

Loading…
Cancel
Save