Browse Source

Add test for org name

pull/557/head
Kat 3 years ago
parent
commit
e65dabaad2
  1. 21
      app/views/organisations/logs.erb
  2. 11
      spec/requests/organisations_controller_spec.rb

21
app/views/organisations/logs.erb

@ -1 +1,20 @@
<%= render partial: "case_logs/log_list", locals: { case_logs: @case_logs, title: "Logs", pagy: @pagy } %>
<% content_for :title, "Logs" %>
<h1 class="govuk-heading-l">
<span class="govuk-caption-l"><%= @organisation.name %></span>
<%= content_for(:title) %>
</h1>
<div class="app-filter-layout" data-controller="filter-layout">
<div class="govuk-button-group app-filter-toggle">
<%= govuk_button_to "Create a new lettings log", case_logs_path %>
<%#= govuk_link_to "Upload logs", bulk_upload_case_logs_path %>
</div>
<%= render partial: "case_logs/log_filters" %>
<% if @case_logs.present? %>
<div class="app-filter-layout__content">
<%= render partial: "case_logs/log_list", locals: { case_logs: @case_logs, title: "Logs", pagy: @pagy } %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "logs" } %>
</div>
<% end %>
</div>

11
spec/requests/organisations_controller_spec.rb

@ -366,14 +366,19 @@ RSpec.describe OrganisationsController, type: :request do
context "when viewing a specific organisation" do
let(:number_of_org1_case_logs) { 2 }
let(:number_of_org2_case_logs) { 4 }
before do
FactoryBot.create_list(:case_log, number_of_org1_case_logs, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id)
FactoryBot.create_list(:case_log, number_of_org2_case_logs, owning_organisation_id: unauthorised_organisation.id, managing_organisation_id: unauthorised_organisation.id)
end
it "only shows logs for that organisation" do
get "/organisations/#{organisation.id}/logs", headers:, params: {}
end
it "displays the name of the organisation in the header" do
expect(CGI.unescape_html(response.body)).to match("<span class=\"govuk-caption-l\">#{organisation.name}</span>")
end
it "only shows logs for that organisation" do
expect(page).to have_content("#{number_of_org1_case_logs} total logs")
organisation.case_logs.map(&:id).each do |case_log_id|
expect(page).to have_link case_log_id.to_s, href: "/logs/#{case_log_id}"

Loading…
Cancel
Save