Browse Source

Update setup question link

CLDC-3465-update-setup-question-link
Kat 6 months ago
parent
commit
64eef0c0dc
  1. 11
      app/helpers/check_errors_helper.rb
  2. 6
      app/views/form/check_errors.html.erb
  3. 5
      spec/requests/check_errors_controller_spec.rb

11
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

6
app/views/form/check_errors.html.erb

@ -48,10 +48,10 @@
<% end %> <% end %>
</dd> </dd>
<dd class="govuk-summary-list__actions"> <dd class="govuk-summary-list__actions">
<% if question.displayed_as_answered?(@log) %> <% if !question.displayed_as_answered?(@log) || question.subsection.id == "setup" %>
<input type="submit" value="Clear" class="govuk-body govuk-link submit-button-link" name="<%= question.id %>"> <%= govuk_link_to check_errors_answer_text(question, @log), check_errors_answer_link(@log, question, @page, applicable_questions) %>
<% else %> <% 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)) %> <input type="submit" value="Clear" class="govuk-body govuk-link submit-button-link" name="<%= question.id %>">
<% end %> <% end %>
</dd> </dd>
</div> </div>

5
spec/requests/check_errors_controller_spec.rb

@ -83,8 +83,9 @@ RSpec.describe CheckErrorsController, type: :request do
post "/sales-logs/#{sales_log.id}/buyer-1-income", params: params post "/sales-logs/#{sales_log.id}/buyer-1-income", params: params
end end
it "displays correct clear links" do it "displays correct clear and change links" do
expect(page).to have_button("Clear", count: 3) expect(page).to have_button("Clear", count: 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") expect(page).to have_link("Clear all", href: "/sales-logs/#{sales_log.id}/confirm-clear-all-answers")
end end
end end

Loading…
Cancel
Save