mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: when search finds a deep link in a topic it takes you to it
This commit is contained in:
parent
9897660a36
commit
a1244043d3
@ -8,7 +8,7 @@ class SearchController < ApplicationController
|
||||
|
||||
def query
|
||||
params.require(:term)
|
||||
|
||||
|
||||
search_args = {guardian: guardian}
|
||||
search_args[:type_filter] = params[:type_filter] if params[:type_filter].present?
|
||||
if params[:include_blurbs].present?
|
||||
|
@ -279,13 +279,16 @@ class Search
|
||||
|
||||
def aggregate_search
|
||||
cols = ['topics.id', 'topics.title', 'topics.slug']
|
||||
topics = posts_query(@limit, aggregate_search: true).group(*cols).pluck(*cols)
|
||||
topics = posts_query(@limit, aggregate_search: true)
|
||||
.group(*cols)
|
||||
.pluck('min(posts.post_number)',*cols)
|
||||
|
||||
topics.each do |t|
|
||||
@results.add_result(SearchResult.new(type: :topic,
|
||||
topic_id: t[0],
|
||||
id: t[0],
|
||||
title: t[1],
|
||||
url: "/t/#{t[2]}/#{t[0]}"))
|
||||
topic_id: t[1],
|
||||
id: t[1],
|
||||
title: t[2],
|
||||
url: "/t/#{t[3]}/#{t[1]}/#{t[0]}"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,17 +110,8 @@ describe Search do
|
||||
|
||||
it 'returns a result' do
|
||||
result.should be_present
|
||||
end
|
||||
|
||||
it 'has the display name as the title' do
|
||||
result[:title].should == user.username
|
||||
end
|
||||
|
||||
it 'has the avatar_template is there so it can hand it to the client' do
|
||||
result[:avatar_template].should_not be_nil
|
||||
end
|
||||
|
||||
it 'has a url for the record' do
|
||||
result[:url].should == "/users/#{user.username_lower}"
|
||||
end
|
||||
|
||||
@ -196,8 +187,7 @@ describe Search do
|
||||
result.should be_present
|
||||
result[:title].should == topic.title
|
||||
|
||||
# The link is to the topic url because it's aggregated
|
||||
result[:url].should == topic.relative_url
|
||||
result[:url].should == topic.relative_url + "/2"
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user