ignore searchable if one searches by handle in people#index
This commit is contained in:
parent
502f467012
commit
3db4772652
2 changed files with 22 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue