Skip to content

Commit

Permalink
Fix hashtag search performing account search as well (mastodon#13758)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and Mage committed Jan 14, 2022
1 parent 59b0603 commit 12fc07c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def full_text_searchable?
end

def account_searchable?
account_search? && !(@query.include?('@') && @query.include?(' '))
account_search? && !(@query.start_with?('#') || (@query.include?('@') && @query.include?(' ')))
end

def hashtag_searchable?
Expand Down
8 changes: 8 additions & 0 deletions spec/services/search_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
expect(Tag).not_to have_received(:search_for)
expect(results).to eq empty_results
end
it 'does not include account when starts with # character' do
query = '#tag'
allow(AccountSearchService).to receive(:new)

results = subject.call(query, nil, 10)
expect(AccountSearchService).to_not have_received(:new)
expect(results).to eq empty_results
end
end
end
end
Expand Down

0 comments on commit 12fc07c

Please sign in to comment.