Skip to content

Commit

Permalink
Merge pull request #3367 from alphagov/show-parent-org
Browse files Browse the repository at this point in the history
Show parent organisation in table
  • Loading branch information
brucebolt authored Nov 27, 2024
2 parents 91f118c + 4d88a8a commit 647b499
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/views/organisations/_organisation_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<%= t.header "Name" %>
<%= t.header "Organisation Type" %>
<%= t.header "Slug" %>
<%= t.header "Parent Organisation" %>
<%= t.header "2-step verification mandated?"%>
<% end %>

Expand All @@ -12,6 +13,11 @@
<%= t.cell "#{organisation.name_with_abbreviation(indicate_closed: false)}" %>
<%= t.cell organisation.organisation_type %>
<%= t.cell organisation.slug %>
<% if organisation.parent %>
<%= t.cell organisation.parent.name %>
<% else %>
<%= t.cell "No parent" %>
<% end %>
<td class="govuk-table__cell">
<%= organisation.require_2sv %>
<% if policy(Organisation).edit? %>
Expand Down
20 changes: 20 additions & 0 deletions test/controllers/organisations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ class OrganisationsControllerTest < ActionController::TestCase
assert_select "#active tr:nth-child(2) td:first-child", text: /Department for Education/
assert_select "#active tr:last-child td:first-child", text: /Government Digital Service/
end

should "include parent organisation when one exists" do
parent = create(:organisation, name: "Cabinet Office")
create(:organisation, name: "Government Digital Service", parent:)

get :index

assert_select "#active tr:last-child td:first-child", text: /Government Digital Service/
assert_select "#active tr:last-child td:nth-child(4)", text: /Cabinet Office/
end

should "not include parent organisation when one does not exist" do
parent = create(:organisation, name: "Cabinet Office")
create(:organisation, name: "Government Digital Service", parent:)

get :index

assert_select "#active tr:first-child td:first-child", text: /Cabinet Office/
assert_select "#active tr:first-child td:nth-child(4)", text: /No parent/
end
end

context "PUT require 2sv" do
Expand Down

0 comments on commit 647b499

Please sign in to comment.