diff --git a/app/helpers/check_errors_helper.rb b/app/helpers/check_errors_helper.rb new file mode 100644 index 000000000..6d1ff0166 --- /dev/null +++ b/app/helpers/check_errors_helper.rb @@ -0,0 +1,11 @@ +module CheckErrorsHelper + include GovukLinkHelper + + def check_errors_answer_text(question, log) + question.displayed_as_answered?(log) ? "Change" : "Answer" + end + + def check_errors_answer_link(log, question, page, applicable_questions) + send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer: "check_errors", original_page_id: page.id, related_question_ids: applicable_questions.map(&:id)) + end +end diff --git a/app/views/form/check_errors.html.erb b/app/views/form/check_errors.html.erb index 53fb0c820..27fa3ea0c 100644 --- a/app/views/form/check_errors.html.erb +++ b/app/views/form/check_errors.html.erb @@ -48,10 +48,10 @@ <% end %>
- <% if question.displayed_as_answered?(@log) %> - + <% if !question.displayed_as_answered?(@log) || question.subsection.id == "setup" %> + <%= govuk_link_to check_errors_answer_text(question, @log), check_errors_answer_link(@log, question, @page, applicable_questions) %> <% else %> - <%= govuk_link_to "Answer", send("#{@log.model_name.param_key}_#{question.page.id}_path", @log, referrer: "check_errors", original_page_id: @page.id, related_question_ids: applicable_questions.map(&:id)) %> + <% end %>
diff --git a/spec/requests/check_errors_controller_spec.rb b/spec/requests/check_errors_controller_spec.rb index e5bf6647e..6e78d7098 100644 --- a/spec/requests/check_errors_controller_spec.rb +++ b/spec/requests/check_errors_controller_spec.rb @@ -83,9 +83,10 @@ RSpec.describe CheckErrorsController, type: :request do post "/sales-logs/#{sales_log.id}/buyer-1-income", params: params end - it "displays correct clear links" do - expect(page.all(:button, value: "Clear").count).to eq(3) - expect(page).to have_button("Clear all") + it "displays correct clear and change links" do + expect(page.all(:button, value: "Clear").count).to eq(2) + expect(page).to have_link("Change", count: 1) + expect(page).to have_link("Clear all", href: "/sales-logs/#{sales_log.id}/confirm-clear-all-answers") end end end