mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 03:29:31 +08:00
FIX: Topic.similar_to
results in error if cooked raw is blank.
This commit is contained in:
parent
2aa1482421
commit
aae9e6e5fd
|
@ -597,12 +597,14 @@ class Topic < ActiveRecord::Base
|
||||||
PrettyText.cook(raw[0...MAX_SIMILAR_BODY_LENGTH].strip)
|
PrettyText.cook(raw[0...MAX_SIMILAR_BODY_LENGTH].strip)
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_tsquery = Search.set_tsquery_weight_filter(
|
if cooked.present?
|
||||||
Search.prepare_data(cooked),
|
raw_tsquery = Search.set_tsquery_weight_filter(
|
||||||
'B'
|
Search.prepare_data(cooked),
|
||||||
)
|
'B'
|
||||||
|
)
|
||||||
|
|
||||||
tsquery = "#{tsquery} & #{raw_tsquery}"
|
tsquery = "#{tsquery} & #{raw_tsquery}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tsquery = Search.to_tsquery(term: tsquery, joiner: "|")
|
tsquery = Search.to_tsquery(term: tsquery, joiner: "|")
|
||||||
|
|
|
@ -515,6 +515,10 @@ describe Topic do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not result in a syntax error when raw is blank after cooking' do
|
||||||
|
expect(Topic.similar_to('some title', '#')).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
context 'with a similar topic' do
|
context 'with a similar topic' do
|
||||||
fab!(:post) {
|
fab!(:post) {
|
||||||
SearchIndexer.enable
|
SearchIndexer.enable
|
||||||
|
|
Loading…
Reference in New Issue
Block a user