mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add nofollow to RSS alternate link in topics and categories (#16013)
* FEATURE: add nofollow to RSS alternate link in topics and categories * Rspec tests for category and topic view: add nofollow to RSS alternate link
This commit is contained in:
18
spec/views/list/list.erb_spec.rb
Normal file
18
spec/views/list/list.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe "list/list.erb" do
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
|
||||
it "add nofollow to RSS alternate link for category" do
|
||||
view.stubs(:include_crawler_content?).returns(false)
|
||||
view.stubs(:url_for).returns('https://www.example.com/test.rss')
|
||||
view.instance_variable_set("@rss", false)
|
||||
view.instance_variable_set("@category", category)
|
||||
render template: 'list/list', formats: []
|
||||
|
||||
expect(view.content_for(:head)).to match(/<link rel="alternate nofollow" type="application\/rss\+xml" title="[^"]+" href="https:\/\/www.example.com\/test\.rss" \/>/)
|
||||
end
|
||||
|
||||
end
|
||||
23
spec/views/topics/show.html.erb_spec.rb
Normal file
23
spec/views/topics/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
require "ostruct"
|
||||
|
||||
describe "topics/show.html.erb" do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
|
||||
it "add nofollow to RSS alternate link for topic" do
|
||||
topic_view = OpenStruct.new(
|
||||
topic: topic,
|
||||
posts: []
|
||||
)
|
||||
topic_view.stubs(:summary).returns('')
|
||||
view.stubs(:crawler_layout?).returns(false)
|
||||
view.stubs(:url_for).returns('https://www.example.com/test.rss')
|
||||
view.instance_variable_set("@topic_view", topic_view)
|
||||
render template: 'topics/show', formats: [:html]
|
||||
|
||||
expect(view.content_for(:head)).to match(/<link rel="alternate nofollow" type="application\/rss\+xml" title="[^"]+" href="https:\/\/www.example.com\/test\.rss" \/>/)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user