]> cat aescling's git repositories - mastodon.git/commitdiff
Fix hashtag search performing account search as well (#13758)
authorThibG <thib@sitedethib.com>
Thu, 14 May 2020 21:37:37 +0000 (23:37 +0200)
committerGitHub <noreply@github.com>
Thu, 14 May 2020 21:37:37 +0000 (23:37 +0200)
app/services/search_service.rb
spec/services/search_service_spec.rb

index 830de4de326117e449683fdfb41964b3200c3d1d..19500a8d4662de43ca4aa2579600e6bbfa16bfcd 100644 (file)
@@ -94,7 +94,7 @@ class SearchService < BaseService
   end
 
   def account_searchable?
-    account_search? && !(@query.include?('@') && @query.include?(' '))
+    account_search? && !(@query.start_with?('#') || (@query.include?('@') && @query.include?(' ')))
   end
 
   def hashtag_searchable?
index 739bb9cf5d8db78183a604f38a043a4aa78e9e66..5b52662ba025470c333e98940d9647a8a6329061 100644 (file)
@@ -91,6 +91,14 @@ describe SearchService, type: :service do
           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