Skip to content

Commit

Permalink
Don't display "Grant access" to Publishing Managers
Browse files Browse the repository at this point in the history
Publishing Managers aren't allowed to grant themselves access to
applications so we shouldn't show them this button.
  • Loading branch information
chrisroos committed Sep 21, 2023
1 parent 2d10c91 commit 8acf20b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/views/account/applications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@
<td class="govuk-table__cell"><%= application.name %></td>
<td class="govuk-table__cell"><%= application.description %></td>
<td class="govuk-table__cell govuk-table__cell--numeric">
<%= button_to account_application_signin_permission_path(application),
class: "govuk-button govuk-!-margin-0",
data: { module: "govuk-button" } do %>
Grant access<span class="govuk-visually-hidden"> to <%= application.name %></span>
<% if policy(:account_applications).grant_signin_permission? %>
<%= button_to account_application_signin_permission_path(application),
class: "govuk-button govuk-!-margin-0",
data: { module: "govuk-button" } do %>
Grant access<span class="govuk-visually-hidden"> to <%= application.name %></span>
<% end %>
<% end %>
</td>
</tr>
Expand Down
14 changes: 14 additions & 0 deletions test/controllers/account/applications_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@ class Account::ApplicationsControllerTest < ActionController::TestCase
assert_redirected_to "/account/applications"
end
end

context "#index" do
context "logged in as a publishing manager" do
should "not display the button to grant access to an application" do
application = create(:application, name: "app-name")
sign_in create(:organisation_admin_user)

get :index

assert_select "tr td", text: "app-name"
assert_select "form[action='#{account_application_signin_permission_path(application)}']", count: 0
end
end
end
end

0 comments on commit 8acf20b

Please sign in to comment.