]> cat aescling's git repositories - mastodon.git/commitdiff
Fix nil query_username (#2013)
authorTomohiro Suwa <neoen.gsn@gmail.com>
Mon, 17 Apr 2017 17:57:02 +0000 (02:57 +0900)
committerEugen <eugen@zeonfederated.com>
Mon, 17 Apr 2017 17:57:02 +0000 (19:57 +0200)
app/services/account_search_service.rb
spec/services/account_search_service_spec.rb

index a9cb85500d5cf522caff687bcbe9a1fd44dbdece..58a23d978ed4d64ed177f6690ea8b57c4a137d4e 100644 (file)
@@ -41,7 +41,7 @@ class AccountSearchService < BaseService
   end
 
   def query_username
-    @_query_username ||= split_query_string.first
+    @_query_username ||= split_query_string.first || ''
   end
 
   def query_domain
index fa421c4436effeff9527b7d844ce31aa98ff23e3..723623833568c6a8a870f12130bd4eba3626e3c5 100644 (file)
@@ -25,6 +25,18 @@ describe AccountSearchService do
     end
 
     describe 'searching local and remote users' do
+      describe "when only '@'" do
+        before do
+          allow(Account).to receive(:find_remote)
+          allow(Account).to receive(:search_for)
+          subject.call('@', 10)
+        end
+
+        it 'uses find_remote with empty query to look for local accounts' do
+          expect(Account).to have_received(:find_remote).with('', nil)
+        end
+      end
+
       describe 'when no domain' do
         before do
           allow(Account).to receive(:find_remote)