Skip to content

Commit

Permalink
Merge pull request #9982 from alphagov/content-modelling/883-hide-the…
Browse files Browse the repository at this point in the history
…-create-journey-for-non-pension-blocks-in-production

(883) Hide the create journey for non pension blocks in production
  • Loading branch information
pezholio authored Feb 26, 2025
2 parents 7671578 + 09ff6a9 commit 6c63459
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@
feature :govspeak_visual_editor, description: "Enables a visual editor for Govspeak fields", default: false
feature :override_government, description: "Enables GDS Editors and Admins to override the government associated with a document", default: false
feature :show_link_to_content_block_manager, description: "Shows link to Content Block Manager from Whitehall editor", default: Whitehall.integration_or_staging?
feature :show_all_content_block_types,
description: "Show all applicable content block types in Content Block Manager",
default: Whitehall.integration_or_staging? || !Rails.env.production?
end
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def to_date

def unpaginated_documents
documents = ContentBlock::Document
documents = documents.where(block_type: ContentBlock::Schema.valid_schemas)
documents = documents.live
documents = documents.joins(:latest_edition)
documents = documents.with_keyword(@filters[:keyword]) if @filters[:keyword].present?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Schema

class << self
def valid_schemas
VALID_SCHEMAS
Flipflop.show_all_content_block_types? ? VALID_SCHEMAS : %w[pension]
end

def all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ class ContentBlockManager::DocumentFilterTest < ActiveSupport::TestCase
let(:document_scope_mock) { mock }

before do
ContentBlockManager::ContentBlock::Document.expects(:live).returns(document_scope_mock)
ContentBlockManager::ContentBlock::Document
.expects(:where)
.with(block_type: ContentBlockManager::ContentBlock::Schema.valid_schemas)
.returns(document_scope_mock)
document_scope_mock.expects(:live).returns(document_scope_mock)
document_scope_mock.expects(:joins).with(:latest_edition).returns(document_scope_mock)
document_scope_mock.expects(:distinct).returns(document_scope_mock)
document_scope_mock.expects(:order).with("content_block_editions.updated_at DESC").returns(document_scope_mock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,24 @@ class ContentBlockManager::SchemaTest < ActiveSupport::TestCase
end

describe ".valid_schemas" do
test "it returns the contents of the VALID_SCHEMA constant" do
it "returns the contents of the VALID_SCHEMA constant" do
assert_equal ContentBlockManager::ContentBlock::Schema.valid_schemas, %w[
email_address
postal_address
pension
]
end

describe "when the show_all_content_block_types feature flag is turned off" do
before do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:show_all_content_block_types, false)
end

it "only returns pensions" do
assert_equal ContentBlockManager::ContentBlock::Schema.valid_schemas, %w[pension]
end
end
end

describe ".all" do
Expand Down

0 comments on commit 6c63459

Please sign in to comment.