diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index a83e34119..6b3ff5f2c 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -34,8 +34,10 @@ class PeopleController < ApplicationController #only do it if it is an email address if diaspora_id?(search_query) @people = Person.where(:diaspora_handle => search_query.downcase) - Webfinger.in_background(search_query) if @people.empty? - @background_query = search_query.downcase + if @people.empty? + Webfinger.in_background(search_query) + @background_query = search_query.downcase + end end @people = @people.paginate(:page => params[:page], :per_page => 15) @hashes = hashes_for_people(@people, @aspects) diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 277c0629c..456df1b54 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -8,6 +8,9 @@ - content_for :head do = include_javascripts :people = javascript_include_tag 'contact-list' + - if @background_query.present? + :javascript + $(document).ready(function() { List.startSearchDelay('#{@background_query}') } ); .span-24.last = search_header @@ -19,13 +22,12 @@ #people_stream.stream - if @hashes.empty? - if @background_query.present? - %p - =t('.searching') - :javascript - $(document).ready(function() { List.startSearchDelay('#{@background_query}') } ); + %p + = t('.searching') + = image_tag '/images/static-loader.png', :class => 'loader' - else %p - =t('.no_one_found') + = t('.no_one_found') - else - for hash in @hashes = render :partial => 'people/person', :locals => hash diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index d195a1442..73ae0a554 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -53,9 +53,14 @@ describe PeopleController do assigns[:people][0].id.should == @unsearchable_eugene.id end - it 'sets the background query task' do + it 'does not the background query task if the user is found' do get :index, :q => "Eugene@Example.ORG" - assigns[:background_query].should == "eugene@example.org" + assigns[:background_query].should == nil + end + + it 'sets background query task if the user is not found' do + get :index, :q => "Eugene@Example1.ORG" + assigns[:background_query].should == "eugene@example1.org" end end