Ben/new branch noindex spam comments (#12210)
* noindex google any comment permalinks with negative score * Add commentable noindex * Give dummy score to podcast episodes
This commit is contained in:
parent
f339531932
commit
9b5e694e9c
3 changed files with 25 additions and 0 deletions
|
|
@ -73,6 +73,10 @@ class PodcastEpisode < ApplicationRecord
|
|||
ActionView::Base.full_sanitizer.sanitize(processed_html)
|
||||
end
|
||||
|
||||
def score
|
||||
1 # When it is expected that a "commentable" has a score, this is the fallback.
|
||||
end
|
||||
|
||||
def zero_method
|
||||
0
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
<meta name="twitter:title" content="<%= truncate(strip_tags(@root_comment.processed_html), length: 50) %> — <%= community_name %>">
|
||||
<meta property="og:image" content="<%= comment_social_image_url(@root_comment) %>" />
|
||||
<meta name="twitter:image" content="<%= comment_social_image_url(@root_comment) %>">
|
||||
<% if @root_comment.score < 0 || @commentable.score < 0 %>
|
||||
<meta name="googlebot" content="noindex">
|
||||
<meta name="googlebot" content="nofollow">
|
||||
<% end %>
|
||||
<% else %>
|
||||
<link rel="canonical" href="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
<meta property="og:url" content="<%= app_url("#{@commentable.path}/comments") %>" />
|
||||
|
|
|
|||
|
|
@ -49,6 +49,23 @@ RSpec.describe "Comments", type: :request do
|
|||
get comment.path
|
||||
expect(response.body).to include(comment.processed_html)
|
||||
end
|
||||
|
||||
it "displays noindex if comment has score of less than 0" do
|
||||
comment.update_column(:score, -5)
|
||||
get comment.path
|
||||
expect(response.body).to include('<meta name="googlebot" content="noindex">')
|
||||
end
|
||||
|
||||
it "displays does not display noindex if comment has 0 or more score" do
|
||||
get comment.path
|
||||
expect(response.body).not_to include('<meta name="googlebot" content="noindex">')
|
||||
end
|
||||
|
||||
it "displays noindex if comment has score of less than 0" do
|
||||
comment.commentable.update_column(:score, -5)
|
||||
get comment.path
|
||||
expect(response.body).to include('<meta name="googlebot" content="noindex">')
|
||||
end
|
||||
end
|
||||
|
||||
context "when the comment is a child comment" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue