From 3399dd7a666d755288cabf55fbb71b7276f6ffb7 Mon Sep 17 00:00:00 2001 From: Tomohiro Suwa Date: Tue, 18 Apr 2017 02:57:02 +0900 Subject: [PATCH] Fix nil query_username (#2013) --- app/services/account_search_service.rb | 2 +- spec/services/account_search_service_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb index a9cb85500..58a23d978 100644 --- a/app/services/account_search_service.rb +++ b/app/services/account_search_service.rb @@ -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 diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index fa421c443..723623833 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -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)