Browse Source

Support user can see additional organisation columns on logs page

pull/454/head
baarkerlounger 3 years ago
parent
commit
453d126bdf
  1. 12
      app/views/case_logs/_log_list.html.erb
  2. 23
      spec/requests/case_logs_controller_spec.rb

12
app/views/case_logs/_log_list.html.erb

@ -15,6 +15,10 @@
<th class="govuk-table__header" scope="col">Tenancy starts</th> <th class="govuk-table__header" scope="col">Tenancy starts</th>
<th class="govuk-table__header" scope="col">Log created</th> <th class="govuk-table__header" scope="col">Log created</th>
<th class="govuk-table__header" scope="col">Completed</th> <th class="govuk-table__header" scope="col">Completed</th>
<% if current_user.support? %>
<th class="govuk-table__header" scope="col">Owning organisation</th>
<th class="govuk-table__header" scope="col">Managing organisation</th>
<% end %>
</tr> </tr>
</thead> </thead>
<tbody class="govuk-table__body"> <tbody class="govuk-table__body">
@ -41,6 +45,14 @@
text: log.status.humanize text: log.status.humanize
) %> ) %>
</td> </td>
<% if current_user.support? %>
<td class="govuk-table__cell">
<%= log.owning_organisation.name %>
</td>
<td class="govuk-table__cell">
<%= log.managing_organisation.name %>
</td>
<% end %>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

23
spec/requests/case_logs_controller_spec.rb

@ -159,10 +159,32 @@ RSpec.describe CaseLogsController, type: :request do
context "when displaying a collection of logs" do context "when displaying a collection of logs" do
let(:headers) { { "Accept" => "text/html" } } let(:headers) { { "Accept" => "text/html" } }
context "when the user is a customer support user" do
let(:user) { FactoryBot.create(:user, :support) }
before do before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
end end
it "does have organisation columns" do
get "/logs", headers: headers, params: {}
expect(CGI.unescape_html(response.body)).to match(/<th class="govuk-table__header" scope="col">Owning organisation<\/th>/)
expect(CGI.unescape_html(response.body)).to match(/<th class="govuk-table__header" scope="col">Managing organisation<\/th>/)
end
end
context "when the user is not a customer support user" do
before do
sign_in user
end
it "does not have organisation columns" do
get "/logs", headers: headers, params: {}
expect(CGI.unescape_html(response.body)).not_to match(/<th class="govuk-table__header" scope="col">Owning organisation<\/th>/)
expect(CGI.unescape_html(response.body)).not_to match(/<th class="govuk-table__header" scope="col">Managing organisation<\/th>/)
end
context "when there are less than 20 logs" do context "when there are less than 20 logs" do
before do before do
get "/logs", headers: headers, params: {} get "/logs", headers: headers, params: {}
@ -263,6 +285,7 @@ RSpec.describe CaseLogsController, type: :request do
end end
end end
end end
end
context "when requesting a specific case log" do context "when requesting a specific case log" do
let(:completed_case_log) { FactoryBot.create(:case_log, :completed) } let(:completed_case_log) { FactoryBot.create(:case_log, :completed) }

Loading…
Cancel
Save