Skip to content

Commit

Permalink
Remove the ability for users to create new news articles
Browse files Browse the repository at this point in the history
Users should still be able to edit existing documents. We want to reduce publishing news articles to zero, so that we can eventually retire content publisher.
  • Loading branch information
baisa committed Sep 4, 2023
1 parent e20f04b commit ecab0b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
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/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

0 comments on commit ecab0b1

Please sign in to comment.