Browse Source

Display unresolved logs banner

pull/1035/head
Kat 4 years ago
parent
commit
32d1a6ea57
  1. 1
      app/controllers/lettings_logs_controller.rb
  2. 12
      app/views/logs/index.html.erb
  3. 7
      spec/requests/lettings_logs_controller_spec.rb

1
app/controllers/lettings_logs_controller.rb

@ -13,6 +13,7 @@ class LettingsLogsController < LogsController
@pagy, @logs = pagy(unpaginated_filtered_logs)
@searched = search_term.presence
@total_count = all_logs.size
@unresolved_count = all_logs.where(unresolved: true, created_by: current_user).count
render "logs/index"
end
end

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

@ -4,6 +4,18 @@
<% content_for :title, title %>
<% if current_page?(controller: 'lettings_logs', action: 'index') %>
<% if @unresolved_count > 0 %>
<%= govuk_notification_banner(
title_text: "Important",
title_heading_level: 3,
title_id: "impacted-logs-banner",
) do |notification_banner| %>
<% notification_banner.heading(text: "A scheme has changed and it has affected #{@unresolved_count} #{@unresolved_count > 1 ? 'logs' : 'log'}") %>
<div class="govuk-notification-banner__heading">
<a class="govuk-notification-banner__link" href="/lettings-logs/update-logs">Update logs</a>
</div>
<% end %>
<% end %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Lettings logs", sub: nil } : { main: "Lettings logs", sub: current_user.organisation.name } %>
<% elsif current_page?(controller: 'sales_logs', action: 'index') %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Sales logs", sub: nil } : { main: "Sales logs", sub: current_user.organisation.name } %>

7
spec/requests/lettings_logs_controller_spec.rb

@ -859,6 +859,13 @@ RSpec.describe LettingsLogsController, type: :request do
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
it "displays a banner on the lettings log page" do
get "/lettings-logs", headers:, params: {}
expect(page).to have_css(".govuk-notification-banner")
expect(page).to have_content("A scheme has changed and it has affected 3 logs")
expect(page).to have_link("Update logs", href: "/lettings-logs/update-logs")
end
end
context "when viewing a specific log affected by deactivated location" do

Loading…
Cancel
Save