-
-
- <% if t.image_url.present? %>
-
- <% end %>
- <%= t.title %>
+ <%= t.title %>
<% if (!@category || @category.has_children?) && t.category && !t.category.uncategorized? %>
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index 60ea55c524a..d98121066c4 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -89,6 +89,16 @@ RSpec.describe ListController do
expect(response.body).to have_tag "title", text: "Discourse - Best community"
end
+
+ it "returns structured data" do
+ get "/latest"
+
+ expect(response.status).to eq(200)
+ topic_list = Nokogiri::HTML5(response.body).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
end
describe "categories and X" do
diff --git a/spec/views/list/list.erb_spec.rb b/spec/views/list/list.erb_spec.rb
index 093e4408938..07279e1582e 100644
--- a/spec/views/list/list.erb_spec.rb
+++ b/spec/views/list/list.erb_spec.rb
@@ -4,6 +4,7 @@ require "rails_helper"
RSpec.describe "list/list.erb" do
fab!(:category) { Fabricate(:category) }
+ fab!(:topic) { Fabricate(:topic) }
it "add nofollow to RSS alternate link for category" do
view.stubs(:include_crawler_content?).returns(false)
@@ -15,4 +16,16 @@ RSpec.describe "list/list.erb" do
expect(view.content_for(:head)).to match(//)
end
+ it "adds sturctured data" do
+ 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
end
|