FIX: categories page crawler view had incorrect URLs

This commit is contained in:
Neil Lalonde 2018-07-23 14:54:32 -04:00
parent 568276fe40
commit f4b5eccad3
2 changed files with 11 additions and 2 deletions

View File

@ -3,9 +3,9 @@
<% @category_list.categories.each_with_index do |c, index| %> <% @category_list.categories.each_with_index do |c, index| %>
<div class='category' itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <div class='category' itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
<meta itemprop='position' content='<%= index %>'> <meta itemprop='position' content='<%= index %>'>
<meta itemprop='url' content='<%= "#{Discourse.base_url}#{c.url}" %>'> <meta itemprop='url' content='<%= "#{c.url}" %>'>
<h2> <h2>
<a href='<%= "#{Discourse.base_url}#{c.url}" %>' itemprop='item'> <a href='<%= "#{c.url}" %>' itemprop='item'>
<span itemprop='name'><%= c.name %></span> <span itemprop='name'><%= c.name %></span>
</a> </a>
</h2> </h2>

View File

@ -17,6 +17,15 @@ describe CategoriesController do
get "/categories" get "/categories"
expect(response.body).not_to include('AMAZING AMAZING') expect(response.body).not_to include('AMAZING AMAZING')
end end
it 'web crawler view has correct urls for subfolder install' do
GlobalSetting.stubs(:relative_url_root).returns('/forum')
Discourse.stubs(:base_uri).returns("/forum")
get '/categories', headers: { 'HTTP_USER_AGENT' => 'Googlebot' }
html = Nokogiri::HTML(response.body)
expect(html.css('body.crawler')).to be_present
expect(html.css("a[href=\"/forum/c/#{category.slug}\"]")).to be_present
end
end end
context 'extensibility event' do context 'extensibility event' do