Skip to content
Extraits de code Groupes Projets
Valider 3db47726 rédigé par MrZYX's avatar MrZYX
Parcourir les fichiers

ignore searchable if one searches by handle in people#index

parent 502f4670
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......@@ -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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter