mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
fix deep link to post in search
This commit is contained in:
parent
dca216ed54
commit
9656759ecf
2 changed files with 16 additions and 1 deletions
|
@ -41,7 +41,9 @@ class Search
|
|||
end
|
||||
|
||||
def self.from_post(p)
|
||||
SearchResult.from_topic(p.topic)
|
||||
# we want the topic link when it's the OP
|
||||
return SearchResult.from_topic(p.topic) if p.post_number == 1
|
||||
SearchResult.new(type: :topic, id: p.topic.id, title: p.topic.title, url: p.url)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -126,6 +126,18 @@ describe Search do
|
|||
end
|
||||
end
|
||||
|
||||
context 'searching for a post' do
|
||||
let!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
|
||||
let!(:reply) { Fabricate(:basic_reply, topic: topic, user: topic.user) }
|
||||
let(:result) { first_of_type(Search.new('quote', type_filter: 'topic').execute, 'topic') }
|
||||
|
||||
it 'returns the post' do
|
||||
result.should be_present
|
||||
result[:title].should == topic.title
|
||||
result[:url].should == reply.url
|
||||
end
|
||||
end
|
||||
|
||||
context "search for a topic by id" do
|
||||
let(:result) { first_of_type(Search.new(topic.id, type_filter: 'topic').execute, 'topic') }
|
||||
|
||||
|
@ -148,6 +160,7 @@ describe Search do
|
|||
|
||||
context 'security' do
|
||||
let!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
|
||||
|
||||
def result(current_user)
|
||||
first_of_type(Search.new('hello', guardian: current_user).execute, 'topic')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue