related tags: fix exception on copyright tags with nonexistent wiki pages.
This commit is contained in:
@@ -48,7 +48,7 @@ class RelatedTagQuery
|
|||||||
def other_wiki_pages
|
def other_wiki_pages
|
||||||
return [] unless Tag.category_for(query) == Tag.categories.copyright
|
return [] unless Tag.category_for(query) == Tag.categories.copyright
|
||||||
|
|
||||||
other_wikis = DText.parse_wiki_titles(wiki_page.body).grep(/\Alist_of_/i)
|
other_wikis = DText.parse_wiki_titles(wiki_page&.body&.to_s).grep(/\Alist_of_/i)
|
||||||
other_wikis = other_wikis.map { |name| WikiPage.titled(name).first }
|
other_wikis = other_wikis.map { |name| WikiPage.titled(name).first }
|
||||||
other_wikis = other_wikis.select { |wiki| wiki.tags.present? }
|
other_wikis = other_wikis.select { |wiki| wiki.tags.present? }
|
||||||
other_wikis
|
other_wikis
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class RelatedTagsControllerTest < ActionDispatch::IntegrationTest
|
class RelatedTagsControllerTest < ActionDispatch::IntegrationTest
|
||||||
context "The related tags controller" do
|
context "The related tags controller" do
|
||||||
setup do
|
setup do
|
||||||
create(:post, tag_string: "touhou")
|
create(:post, tag_string: "copy:touhou")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
@@ -16,6 +16,11 @@ class RelatedTagsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
get related_tag_path(format: :json), params: { query: "touhou" }
|
get related_tag_path(format: :json), params: { query: "touhou" }
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "work for .js responses for copyright tags without a wiki" do
|
||||||
|
get related_tag_path(format: :js), params: { query: "touhou" }, xhr: true
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user