Skip to content

Commit

Permalink
Fix nil query_username (mastodon#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuwatch authored and palon7 committed Apr 19, 2017
1 parent 6d39f56 commit 87feec8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/account_search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def split_query_string
end

def query_username
@_query_username ||= split_query_string.first
@_query_username ||= split_query_string.first || ''
end

def query_domain
Expand Down
12 changes: 12 additions & 0 deletions spec/services/account_search_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
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)
Expand Down

0 comments on commit 87feec8

Please sign in to comment.