Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ability for users to create new news articles #2895

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class User < ApplicationRecord
MANAGING_EDITOR_PERMISSION = "managing_editor".freeze
ACCESS_LIMIT_OVERRIDE_PERMISSION = "access_limit_override".freeze
MANAGE_LIVE_HISTORY_MODE = "manage_live_history_mode".freeze
CREATE_NEW_DOCUMENT_PERMISSION = "create_new_document".freeze

def can_access?(edition)
return true unless edition.access_limit
Expand Down
14 changes: 8 additions & 6 deletions app/views/documents/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<% content_for :title, t("documents.index.title") %>

<% content_for :title_side, render("govuk_publishing_components/components/button", {
text: "Create new document",
href: new_document_path,
margin_bottom: true,
data_attributes: { gtm: "new-document" }
}) %>
<% if current_user.has_permission?(User::CREATE_NEW_DOCUMENT_PERMISSION) %>
<% content_for :title_side, render("govuk_publishing_components/components/button", {
text: "Create new document",
href: new_document_path,
margin_bottom: true,
data_attributes: { gtm: "new-document" }
}) %>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-quarter">
Expand Down
5 changes: 5 additions & 0 deletions spec/features/formats/news_article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
include TopicsHelper

scenario do
when_i_have_the_create_new_document_permission
when_i_choose_this_document_type
and_i_fill_in_the_form_fields
then_the_document_should_be_previewable
end

def when_i_have_the_create_new_document_permission
current_user.update(permissions: [User::CREATE_NEW_DOCUMENT_PERMISSION])
end

def when_i_choose_this_document_type
visit root_path
click_on "Create new document"
Expand Down
5 changes: 5 additions & 0 deletions spec/features/formats/publication_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
RSpec.describe "Publication format" do
scenario do
when_i_have_the_create_new_document_permission
when_i_choose_this_document_type
and_i_fill_in_the_form_fields
then_the_document_should_be_previewable
end

def when_i_have_the_create_new_document_permission
current_user.update(permissions: [User::CREATE_NEW_DOCUMENT_PERMISSION, User::PRE_RELEASE_FEATURES_PERMISSION])
end

def when_i_choose_this_document_type
visit root_path
click_on "Create new document"
Expand Down
5 changes: 5 additions & 0 deletions spec/features/workflow/create_document_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RSpec.feature "Create a document" do
scenario do
when_i_have_the_create_new_document_permission
given_i_am_on_the_home_page
when_i_click_to_create_a_document
and_i_select_a_supertype
Expand All @@ -9,6 +10,10 @@
and_i_see_the_timeline_entry
end

def when_i_have_the_create_new_document_permission
current_user.update(permissions: [User::CREATE_NEW_DOCUMENT_PERMISSION])
end

def given_i_am_on_the_home_page
visit root_path
end
Expand Down