Skip to content

Commit

Permalink
Exclude rendering of popular links edition from index page
Browse files Browse the repository at this point in the history
  • Loading branch information
syed-ali-tw committed Jun 14, 2024
1 parent f6b6c7d commit 9350210
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/controllers/root_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def list_parameter_from_state(state)

def build_presenter(user_filter, current_page = nil)
user_filter, user = process_user_filter(user_filter)

editions = filtered_editions.order_by([sort_column, sort_direction])
editions = editions.page(current_page).per(ITEMS_PER_PAGE)
editions = editions.where.not(_type: "PopularLinksEdition")

[PrimaryListingPresenter.new(editions, user), user_filter]
end

Expand Down
16 changes: 16 additions & 0 deletions test/integration/root_overview_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,20 @@ class RootOverviewTest < ActionDispatch::IntegrationTest

assert page.has_link?("/test-slug", href: "#{Plek.website_root}/test-slug")
end

test "should not render popular links edition" do
FactoryBot.create(:user, :govuk_editor)
FactoryBot.create(:guide_edition, title: "Draft guide")
FactoryBot.create(:transaction_edition, title: "Draft transaction")
FactoryBot.create(:popular_links, title: "Popular links edition")

visit "/"

filter_by_user("All")

assert page.has_content?("Draft guide")
assert page.has_content?("Draft transaction")
assert page.has_content?("Draft guide")
assert page.has_no_content?("Popular links edition")
end
end
2 changes: 1 addition & 1 deletion test/models/edition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def draft_second_edition_from(published_edition)
test "it should not be possible to clone from a #{source_class} to a #{destination_class}" do
source_edition = FactoryBot.create(:edition, _type: source_class.to_s, state: "published")

assert_raised do
assert_raises do
source_edition.build_clone(destination_class)
end
end
Expand Down

0 comments on commit 9350210

Please sign in to comment.