Browse Source

add back button link on completed logs

pull/1613/head
Phil Lee 3 years ago
parent
commit
e5bc8695bf
  1. 12
      app/views/logs/edit.html.erb
  2. 45
      spec/views/logs/edit.html.erb_spec.rb

12
app/views/logs/edit.html.erb

@ -12,9 +12,11 @@
<% if @log.status == "in_progress" %>
<p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log) %> subsections completed.</p>
<p class="govuk-body govuk-!-margin-bottom-2">
<% next_incomplete_section = get_next_incomplete_section(@log) %>
</p>
<p>
<% if next_incomplete_section.present? %>
<a class="app-section-skip-link" href="#<%= next_incomplete_section.id.dasherize %>">
@ -28,10 +30,20 @@
<p class="govuk-body">
<%= status_tag(@log.status) %>
</p>
<p class="govuk-body">
<%= review_log_text(@log) %>
</p>
<% end %>
<%= render "tasklist" %>
<% if @log.completed? %>
<% if @log.lettings? %>
<%= govuk_button_link_to "Back to lettings logs", lettings_logs_path %>
<% else %>
<%= govuk_button_link_to "Back to sales logs", sales_logs_path %>
<% end %>
<% end %>
</div>
</div>

45
spec/views/logs/edit.html.erb_spec.rb

@ -0,0 +1,45 @@
require "rails_helper"
RSpec.describe "logs/edit.html.erb" do
before do
assign(:log, log)
end
context "when log is in progress" do
let(:log) { create(:lettings_log, :in_progress) }
it "there is no link back to log type root" do
render
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment).not_to have_link(text: "Back to lettings logs", href: "/lettings-logs")
end
end
context "when log is completed" do
context "when showing a lettings log" do
let(:log) { create(:lettings_log, :completed) }
it "has link 'Back to lettings logs'" do
render
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment).to have_link(text: "Back to lettings logs", href: "/lettings-logs")
end
end
context "when showing a sales log" do
let(:log) { create(:sales_log, :completed) }
it "has link 'Back to sales logs'" do
render
fragment = Capybara::Node::Simple.new(rendered)
expect(fragment).to have_link(text: "Back to sales logs", href: "/sales-logs")
end
end
end
end
Loading…
Cancel
Save