Browse Source

display correct content when there are no unresolved logs

pull/1035/head
Kat 4 years ago
parent
commit
2e427e3f66
  1. 12
      app/views/logs/update_logs.html.erb
  2. 8
      spec/requests/lettings_logs_controller_spec.rb

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

@ -1,8 +1,17 @@
<% item_label = format_label(@pagy.count, "logs") %> <% item_label = format_label(@pagy.count, "logs") %>
<% title = format_title(@searched, "Logs", current_user, item_label, @pagy.count, nil) %> <% title = "Update logs"%>
<% content_for :title, title %> <% content_for :title, title %>
<% if @total_count < 1 %>
<%= render partial: "organisations/headings", locals: { main: "There are no more logs that need updating", sub: "" } %>
<p class="govuk-body">
You’ve completed all the logs that were affected by scheme changes.
</p>
<div>
<%= govuk_button_link_to "Back to all logs", lettings_logs_path %>
</div>
<% else %>
<%= render partial: "organisations/headings", locals: { main: "You need to update #{@total_count} logs", sub: "" } %> <%= render partial: "organisations/headings", locals: { main: "You need to update #{@total_count} logs", sub: "" } %>
<%= govuk_table do |table| %> <%= govuk_table do |table| %>
@ -32,5 +41,6 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>

8
spec/requests/lettings_logs_controller_spec.rb

@ -828,6 +828,14 @@ RSpec.describe LettingsLogsController, type: :request do
expect(page).not_to have_content(affected_lettings_logs.first.id) expect(page).not_to have_content(affected_lettings_logs.first.id)
expect(page).to have_content("You need to update 2 logs") expect(page).to have_content("You need to update 2 logs")
end end
it "displays correct content when there are no unresolved logs" do
LettingsLog.where(unresolved: true).update!(unresolved: false)
get "/lettings-logs/update-logs", headers:, params: {}
expect(page).to have_content("There are no more logs that need updating")
expect(page).to have_content("You’ve completed all the logs that were affected by scheme changes.")
page.assert_selector(".govuk-button", text: "Back to all logs")
end
end end
context "when viewing a specific log affected by deactivated location" do context "when viewing a specific log affected by deactivated location" do

Loading…
Cancel
Save