From ff096b8adc704d574545d8ffd780d4d828e216d2 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 27 Jun 2020 02:01:34 -0500 Subject: [PATCH] Fix #4508: Specific tag not showing a wiki. Fix the wiki excerpt not appearing when searching for a tag that doesn't exist in the tag list. This could happen if someone created a wiki for a tag that has never been used on a post. --- app/logical/post_sets/post.rb | 5 ++--- test/functional/posts_controller_test.rb | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 30d76717e..79585110b 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -24,9 +24,8 @@ module PostSets end def wiki_page - return nil unless tag.present? && tag.wiki_page.present? - return nil unless !tag.wiki_page.is_deleted? - tag.wiki_page + return nil unless normalized_query.has_single_tag? + @wiki_page ||= WikiPage.undeleted.find_by(title: normalized_query.tags.first.name) end def tag diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 173798edd..41bdc1c88 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -96,6 +96,13 @@ class PostsControllerTest < ActionDispatch::IntegrationTest assert_response :success end + should "show the wiki excerpt for a wiki page without a tag" do + as(@user) { create(:wiki_page, title: "no_tag") } + get posts_path(tags: "no_tag") + assert_select "#show-excerpt-link", count: 1 + assert_select "#excerpt", count: 1 + end + should "show a notice for a single tag search with a pending BUR" do create(:bulk_update_request, script: "create alias foo -> bar") get_auth posts_path(tags: "foo"), @user