Skip to content

Commit

Permalink
Merge pull request #9631 from alphagov/landing-page-document-filter
Browse files Browse the repository at this point in the history
Add Landing Pages to the list of edition classes
  • Loading branch information
richardTowers authored Nov 20, 2024
2 parents 03dc8e4 + 95c7688 commit 55aea3a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/helpers/admin/edition_actions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def edition_type_options_for_select(user, selected)
def type_options_container(user)
Whitehall.edition_classes.map { |edition_type|
next if edition_type == FatalityNotice && !user.can_handle_fatalities?
next if edition_type == LandingPage && !user.gds_admin?

[edition_type.format_name.humanize.pluralize, edition_type.model_name.singular]
}.compact
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/search_api_presenters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.present_all_detailed_content
end

def self.searchable_classes_for_government_index
searchable_classes - [DetailedGuide]
searchable_classes - [DetailedGuide, LandingPage]
end

def self.searchable_classes
Expand Down
3 changes: 2 additions & 1 deletion lib/whitehall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def self.edition_classes
DetailedGuide,
DocumentCollection,
FatalityNotice,
LandingPage,
NewsArticle,
Publication,
Speech,
Expand All @@ -171,7 +172,7 @@ def self.edition_classes
end

def self.edition_route_path_segments
%w[news speeches policies publications consultations priority detailed-guides case-studies statistical-data-sets fatalities collections supporting-pages calls-for-evidence worldwide-organisations]
%w[news speeches policies publications consultations priority detailed-guides case-studies statistical-data-sets fatalities collections supporting-pages calls-for-evidence worldwide-organisations landing-pages]
end

def self.analytics_format(format)
Expand Down
7 changes: 7 additions & 0 deletions test/unit/app/helpers/admin/edition_actions_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ class Admin::EditionActionsHelperTest < ActionView::TestCase

assert_same_elements @editions + ["Fatality notices"], types
end

test "#filter_edition_type_opt_groups should include landing pages when the user is an admin" do
filter_options = filter_edition_type_opt_groups(create(:gds_admin), nil)
types = filter_options[1].last.map { |type| type[:text] }

assert_same_elements @editions + ["Fatality notices", "Landing pages"], types
end
end
7 changes: 6 additions & 1 deletion test/unit/app/helpers/govspeak_helper_link_rewriting_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ class GovspeakHelperLinkRewritingTest < ActionView::TestCase

Whitehall.edition_classes.each do |edition_class|
test "should rewrite absolute path to an admin page for a published #{edition_class} as link to its public page" do
edition = create("published_#{edition_class.name.underscore}")
document = if edition_class == LandingPage
create(:document, slug: "/starts-with-slash")
else
create(:document)
end
edition = create("published_#{edition_class.name.underscore}", document:)
assert_rewrites_link(from: admin_edition_path(edition), to: edition.public_url)
end
end
Expand Down

0 comments on commit 55aea3a

Please sign in to comment.