diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index 7efc276b6..1c9de803a 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -9,6 +9,13 @@
<%= case_log[page] %>
+
+ <% if case_log[page].blank? %> + <%= link_to "Answer", "/case_logs/#{case_log_id}/#{page}", class: "govuk-link" %> + <% else %> + <%= link_to "Change", "/case_logs/#{case_log_id}/#{page}", class: "govuk-link" %> + <% end %> +
<% end %> diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 8aa7aa153..95ac523eb 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -1,6 +1,7 @@ require "rails_helper" RSpec.describe "Test Features" do let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } + let!(:empty_case_log) { FactoryBot.create(:case_log) } let(:id) { case_log.id } let(:status) { case_log.status } @@ -135,6 +136,23 @@ RSpec.describe "Test Features" do expect(page).to have_content("28") expect(page).to have_content("Non-binary") end + + it "should have an answer link for questions missing an answer" do + visit("case_logs/#{empty_case_log.id}/#{subsection}/check_answers") + assert_selector "a", text: "Answer", count: 7 + assert_selector "a", text: "Change", count: 0 + expect(page).to have_link('Answer', href: "/case_logs/#{empty_case_log.id}/tenant_age") + end + + it "should have a change link for answered questions" do + visit("/case_logs/#{empty_case_log.id}/tenant_age") + fill_in("tenant_age", with: 28) + click_button("Save and continue") + visit("/case_logs/#{empty_case_log.id}/#{subsection}/check_answers") + assert_selector "a", text: "Answer", count: 6 + assert_selector "a", text: "Change", count: 1 + expect(page).to have_link('Change', href: "/case_logs/#{empty_case_log.id}/tenant_age") + end end end end