Commit e4ad229a authored by Raphael's avatar Raphael

Requestors are now high in search

parent 4e60d2b9
......@@ -67,7 +67,8 @@ class Person < ActiveRecord::Base
# ORDER BY `contacts`.user_id DESC
Person.searchable.where(sql, *tokens).joins(
"LEFT OUTER JOIN `contacts` ON `contacts`.user_id = #{} AND `contacts`.person_id = `people`.id"
).order("contacts.user_id DESC", "profiles.last_name ASC", "profiles.first_name ASC", "people.diaspora_handle ASC")
).joins("LEFT OUTER JOIN `requests` ON `requests`.recipient_id = #{} AND `requests`.sender_id = `people`.id"
).order("contacts.user_id DESC", "requests.recipient_id DESC", "profiles.last_name ASC", "profiles.first_name ASC")
def name
......@@ -152,6 +152,12 @@ describe Person do
describe '.search' do
before do
@user = Factory.create(:user_with_aspect)
user_profile = @user.person.profile
user_profile.first_name = "aiofj"
user_profile.last_name = "asdji"
@robert_grimm = Factory.create(:searchable_person)
@eugene_weinstein = Factory.create(:searchable_person)
@yevgeniy_dodis = Factory.create(:searchable_person)
......@@ -224,11 +230,22 @@ describe Person do
people.should == [@robert_grimm]
it 'orders by whether the person is friends with the searching user' do
it "puts the searching user's contacts first" do
@user.activate_contact(@casey_grippi, @user.aspects.first)
people ="ing", @user){|p|}.should == [@casey_grippi, @yevgeniy_dodis, @robert_grimm, @eugene_weinstein].map{|p|}
it "puts the searching user's incoming requests first" do
requestor = Factory(:user_with_aspect)
profile = requestor.person.profile
profile.first_name = "Requesting"
profile.last_name = "Something"
requestor.send_contact_request_to(@user.person, requestor.aspects.first)
people ="ing", @user){|p|}.should == [requestor.person, @yevgeniy_dodis, @robert_grimm, @casey_grippi, @eugene_weinstein].map{|p|}
context 'people finders for webfinger' do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment