diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index aed2a9a7225..f9bb80008f2 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -103,10 +103,7 @@ <% @topic_view.link_counts[post.id].each_with_index do |link, i| %> <% if link[:reflection] && link[:title].present? %>
<% end %> diff --git a/spec/views/topics/show.html.erb_spec.rb b/spec/views/topics/show.html.erb_spec.rb index d5353e80f7f..dda660961d4 100644 --- a/spec/views/topics/show.html.erb_spec.rb +++ b/spec/views/topics/show.html.erb_spec.rb @@ -18,4 +18,27 @@ RSpec.describe "topics/show.html.erb" do %r{}, ) end + + it "adds sturctured data" do + view.stubs(:include_crawler_content?).returns(true) + post = Fabricate(:post, topic: topic) + TopicLink.create!( + topic_id: post.topic_id, + post_id: post.id, + user_id: post.user_id, + url: "https://example.com/", + domain: "example.com", + link_topic_id: Fabricate(:topic).id, + reflection: true, + ) + assign(:topic_view, TopicView.new(topic)) + assign(:tags, []) + + render template: "topics/show", formats: [:html] + + links_list = Nokogiri::HTML5.fragment(rendered).css(".crawler-linkback-list") + first_item = links_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("https://example.com/") + end end