remove single user redirect

This commit is contained in:
maxwell 2011-01-20 15:02:46 -08:00
parent c6a3cff644
commit b21b0adca7
2 changed files with 9 additions and 26 deletions

View file

@ -12,15 +12,11 @@ class PeopleController < ApplicationController
@aspect = :search @aspect = :search
@people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => 15 @people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => 15
if @people.count == 1 @hashes = hashes_for_people(@people, @aspects)
redirect_to @people.first @people
else #only do it if it is an email address
@hashes = hashes_for_people(@people, @aspects) if params[:q].try(:match, Devise.email_regexp)
@people webfinger(params[:q])
#only do it if it is an email address
if params[:q].try(:match, Devise.email_regexp)
webfinger(params[:q])
end
end end
end end

View file

@ -75,7 +75,7 @@ describe PeopleController do
response.should be_success response.should be_success
end end
end end
describe '#index' do describe '#index (search)' do
before do before do
@eugene = Factory.create(:person, @eugene = Factory.create(:person,
:profile => Factory(:profile, :first_name => "Eugene", :profile => Factory(:profile, :first_name => "Eugene",
@ -89,26 +89,13 @@ describe PeopleController do
eugene2 = Factory.create(:person, eugene2 = Factory.create(:person,
:profile => Factory(:profile, :first_name => "Eugene", :profile => Factory(:profile, :first_name => "Eugene",
:last_name => "w")) :last_name => "w"))
get :index, :q => "Eu" get :index, :q => "Eug"
assigns[:people].should =~ [@eugene, eugene2] assigns[:people].should =~ [@eugene, eugene2]
end end
it 'shows a contact' do
user2 = bob
get :index, :q => user2.person.profile.first_name.to_s
response.should redirect_to user2.person
end
it 'shows a non-contact' do it "does not redirect to person page if there is exactly one match" do
user2 = eve
user2.person.profile.searchable = true
user2.save
get :index, :q => user2.person.profile.first_name.to_s
response.should redirect_to user2.person
end
it "redirects to person page if there is exactly one match" do
get :index, :q => "Korth" get :index, :q => "Korth"
response.should redirect_to @korth response.should_not redirect_to @korth
end end
it "does not redirect if there are no matches" do it "does not redirect if there are no matches" do