2022-03-09 13:34:02 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe "list/list.erb" do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:category)
|
|
|
|
fab!(:topic)
|
2022-03-09 13:34:02 +08:00
|
|
|
|
|
|
|
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(
|
|
|
|
%r{<link rel="alternate nofollow" type="application/rss\+xml" title="[^"]+" href="https://www.example.com/test\.rss" />},
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2023-06-14 04:02:21 +08:00
|
|
|
it "adds structured data" do
|
2022-12-06 00:00:32 +08:00
|
|
|
view.stubs(:include_crawler_content?).returns(true)
|
|
|
|
topic.posters = []
|
|
|
|
assign(:list, OpenStruct.new(topics: [topic]))
|
|
|
|
|
|
|
|
render template: "list/list", formats: []
|
|
|
|
|
|
|
|
topic_list = Nokogiri::HTML5.fragment(rendered).css(".topic-list")
|
|
|
|
first_item = topic_list.css('[itemprop="itemListElement"]')
|
|
|
|
expect(first_item.css('[itemprop="position"]')[0]["content"]).to eq("1")
|
|
|
|
expect(first_item.css('[itemprop="url"]')[0]["href"]).to eq(topic.url)
|
|
|
|
end
|
2022-03-09 13:34:02 +08:00
|
|
|
end
|