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

Add Landing Pages to the list of edition classes #9631

Merged
merged 3 commits into from
Nov 20, 2024
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/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