Browse Source

add specs for change/answer links on check answers

pull/25/head
MadeTech Dushan 3 years ago
parent
commit
82e87483b9
  1. 7
      app/views/form/check_answers.html.erb
  2. 18
      spec/features/case_log_spec.rb

7
app/views/form/check_answers.html.erb

@ -9,6 +9,13 @@
<dd class="govuk-summary-list__value"> <dd class="govuk-summary-list__value">
<%= case_log[page] %> <%= case_log[page] %>
</dd> </dd>
<dd class="govuk-summary-list__actions">
<% 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 %>
</dd>
</div> </div>
</dl> </dl>
<% end %> <% end %>

18
spec/features/case_log_spec.rb

@ -1,6 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe "Test Features" do RSpec.describe "Test Features" do
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } let!(:case_log) { FactoryBot.create(:case_log, :in_progress) }
let!(:empty_case_log) { FactoryBot.create(:case_log) }
let(:id) { case_log.id } let(:id) { case_log.id }
let(:status) { case_log.status } 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("28")
expect(page).to have_content("Non-binary") expect(page).to have_content("Non-binary")
end 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 end
end end

Loading…
Cancel
Save