Browse Source

utilise rails url helpers

pull/1427/head
Arthur Campbell 3 years ago
parent
commit
e74930cf92
  1. 5
      app/views/form/check_answers.html.erb
  2. 10
      app/views/form/review.html.erb
  3. 2
      spec/features/sales_log_spec.rb

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

@ -1,8 +1,7 @@
<% content_for :title, "#{subsection.id.humanize} - Check your answers" %> <% content_for :title, "#{subsection.id.humanize} - Check your answers" %>
<% class_name = @log.class.name.underscore %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => send("#{class_name.pluralize}_path"), "Logs" => url_for(@log.class),
"Log #{@log.id}" => send("#{class_name}_path", @log), "Log #{@log.id}" => url_for(@log),
subsection.label => "", subsection.label => "",
}) %> }) %>

10
app/views/form/review.html.erb

@ -1,9 +1,9 @@
<% class_name = @log.class.name.underscore %> <% class_name = @log.class.name.underscore.humanize(capitalize: false) %>
<% content_for :title, "Review #{class_name.humanize(capitalize: false)}" %> <% content_for :title, "Review #{class_name}" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { <% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => send("#{class_name.pluralize}_path"), "Logs" => url_for(@log.class),
"Log #{@log.id}" => send("#{class_name}_path", @log.id), "Log #{@log.id}" => url_for(@log),
"Review #{class_name.humanize(capitalize: false)}" => "", "Review #{class_name}" => "",
}) %> }) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">

2
spec/features/sales_log_spec.rb

@ -88,7 +88,6 @@ RSpec.describe "Sales Log Features" do
end end
context "when visiting a subsection check answers page as a support user" do context "when visiting a subsection check answers page as a support user" do
it "has the correct breadcrumbs with the correct links" do it "has the correct breadcrumbs with the correct links" do
visit sales_log_setup_check_answers_path(sales_log.id) visit sales_log_setup_check_answers_path(sales_log.id)
breadcrumbs = page.find_all(".govuk-breadcrumbs__link") breadcrumbs = page.find_all(".govuk-breadcrumbs__link")
@ -100,7 +99,6 @@ RSpec.describe "Sales Log Features" do
end end
context "when reviewing a complete log" do context "when reviewing a complete log" do
it "has the correct breadcrumbs with the correct links" do it "has the correct breadcrumbs with the correct links" do
visit review_sales_log_path(sales_log.id, sales_log: true) visit review_sales_log_path(sales_log.id, sales_log: true)
breadcrumbs = page.find_all(".govuk-breadcrumbs__link") breadcrumbs = page.find_all(".govuk-breadcrumbs__link")

Loading…
Cancel
Save