Requestors are now high in search
This commit is contained in:
parent
4e60d2b92e
commit
e4ad229a5a
2 changed files with 20 additions and 2 deletions
|
|
@ -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 = #{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 = #{user.person.id} AND `requests`.sender_id = `people`.id"
|
||||
).order("contacts.user_id DESC", "requests.recipient_id DESC", "profiles.last_name ASC", "profiles.first_name ASC")
|
||||
end
|
||||
|
||||
def name
|
||||
|
|
|
|||
|
|
@ -152,6 +152,12 @@ describe Person do
|
|||
describe '.search' do
|
||||
before do
|
||||
Person.delete_all
|
||||
@user = Factory.create(:user_with_aspect)
|
||||
user_profile = @user.person.profile
|
||||
user_profile.first_name = "aiofj"
|
||||
user_profile.last_name = "asdji"
|
||||
user_profile.save
|
||||
|
||||
@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]
|
||||
end
|
||||
|
||||
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 = Person.search("ing", @user)
|
||||
people.map{|p| p.name}.should == [@casey_grippi, @yevgeniy_dodis, @robert_grimm, @eugene_weinstein].map{|p|p.name}
|
||||
end
|
||||
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"
|
||||
profile.save
|
||||
|
||||
requestor.send_contact_request_to(@user.person, requestor.aspects.first)
|
||||
people = Person.search("ing", @user)
|
||||
people.map{|p| p.name}.should == [requestor.person, @yevgeniy_dodis, @robert_grimm, @casey_grippi, @eugene_weinstein].map{|p|p.name}
|
||||
end
|
||||
end
|
||||
|
||||
context 'people finders for webfinger' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue