Skip to content

Commit 8f877d2

Browse files
Merge pull request #11444 from alphagov/add-link-to-permissions-edit
Add a link on the 'Permissions error' page to allow GDS Admins to go straight to 'Update access' [WHIT-3284]
2 parents cf2bb16 + edb745f commit 8f877d2

4 files changed

Lines changed: 43 additions & 6 deletions

File tree

app/views/admin/errors/forbidden.html.erb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55
<div class="govuk-grid-row govuk-!-margin-bottom-0">
66
<div class="govuk-grid-column-two-thirds">
77
<p class="govuk-body">You do not have permission to access this page.</p>
8-
<p class="govuk-body">If you need to:</p>
9-
8+
<% if @edition && can?(:perform_administrative_tasks, Edition) %>
9+
<p class="govuk-body">
10+
<a href="<%= edit_access_limited_admin_edition_path(@edition) %>" class="govuk-link">
11+
As an administrator, you can update the access permissions of the page.
12+
</a>
13+
</p>
14+
<p class="govuk-body">Alternatively, if you need to:</p>
15+
<% else %>
16+
<p class="govuk-body">If you need to:</p>
17+
<% end %>
1018
<%= render "govuk_publishing_components/components/list", {
1119
visible_counters: true,
1220
items: [
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Viewing most recent editions in admin
2+
3+
Scenario: Viewing a current edition that has since been access limited as an editor
4+
Given I am an editor
5+
Given a published document "Road accidents" exists
6+
When someone else creates a new edition of the published document "Road accidents" and limits access to members of "Department of Secrecy"
7+
And I view the current edition of document "Road accidents"
8+
Then I am told I do not have permissions to access this page
9+
And I should not see a link to edit the access
10+
11+
Scenario: Viewing a current edition that has since been access limited as a GDS admin
12+
Given I am a GDS admin
13+
Given a published document "Road accidents" exists
14+
When someone else creates a new edition of the published document "Road accidents" and limits access to members of "Department of Secrecy"
15+
And I view the current edition of document "Road accidents"
16+
Then I am told I do not have permissions to access this page
17+
And I should see a link to edit the access
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
When(/^I view the current edition of document "([^"]*)"$/) do |title|
2+
@edition = Edition.find_by(title:).document.editions.last
3+
visit admin_edition_path(@edition)
4+
end
5+
6+
Then(/^I am told I do not have permissions to access this page/) do
7+
expect(page).to have_content "You do not have permission to access this page."
8+
end
9+
10+
Then(/^I should not see a link to edit the access/) do
11+
expect(page).not_to have_link("As an administrator, you can update the access permissions of the page.", href: edit_access_limited_admin_edition_path(@edition))
12+
end
13+
14+
Then(/^I should see a link to edit the access/) do
15+
expect(page).to have_link("As an administrator, you can update the access permissions of the page.", href: edit_access_limited_admin_edition_path(@edition))
16+
end

features/step_definitions/edition_update_slug_steps.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@
1818
visit admin_edition_path(Publication.find_by(title:))
1919
expect(page).to have_link "Preview on website (opens in new tab)", href: "https://draft-origin.test.gov.uk/government/publications/#{new_slug}"
2020
end
21-
22-
Then(/^I am told I do not have permissions to access this page/) do
23-
expect(page).to have_content "You do not have permission to access this page."
24-
end

0 commit comments

Comments
 (0)