diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 45779f3c3..9f0863713 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -26,13 +26,15 @@ class PeopleController < ApplicationController end format.all do - @people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => limit - @hashes = hashes_for_people(@people, @aspects) - #only do it if it is an email address if params[:q].try(:match, Devise.email_regexp) webfinger(params[:q]) + people = Person.where(:diaspora_handle => params[:q]) + else + people = Person.search(params[:q], current_user) end + @people = people.paginate :page => params[:page], :per_page => limit + @hashes = hashes_for_people(@people, @aspects) end end end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 31c53c3c5..c5883b3b0 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -42,6 +42,22 @@ describe PeopleController do assigns[:people].should =~ [@eugene, eugene2] end + it "excludes people that are not searchable" do + eugene2 = Factory.create(:person, + :profile => Factory.build(:profile, :first_name => "Eugene", + :last_name => "w", :searchable => false)) + get :index, :q => "Eug" + assigns[:people].should_not =~ [eugene2] + end + + it "allows unsearchable people to be found by handle" do + eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org", + :profile => Factory.build(:profile, :first_name => "Eugene", + :last_name => "w", :searchable => false)) + get :index, :q => "eugene@example.org" + assigns[:people].should =~ [eugene2] + end + it "does not redirect to person page if there is exactly one match" do get :index, :q => "Korth" response.should_not redirect_to @korth @@ -268,4 +284,4 @@ describe PeopleController do get :retrieve_remote, :diaspora_handle => @user.diaspora_handle end end -end \ No newline at end of file +end