added a fixed the pending request query
This commit is contained in:
parent
c8c0b5c8a2
commit
0e171e8504
4 changed files with 20 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ class PeopleController < ApplicationController
|
|||
if @contact
|
||||
@aspects_with_person = @contact.aspects
|
||||
else
|
||||
@pending_request = current_user.pending_requests.find_by_person_id(@person.id)
|
||||
@pending_request = current_user.request_for(@person)
|
||||
end
|
||||
|
||||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
= t('.thats_you')
|
||||
- elsif current_user.person_objects.include?(person)
|
||||
= t('.already_connected')
|
||||
- elsif current_user.pending_requests.find_by_person_id(person.id)
|
||||
- elsif current_user.request_for(person)
|
||||
= link_to =t('.pending_request'), aspects_manage_path
|
||||
- else
|
||||
- single_aspect_form ||= nil
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ module Diaspora
|
|||
self.aspects.all.collect{|x| x.id}
|
||||
end
|
||||
|
||||
def request_for(to_person)
|
||||
Request.first(:from_id => self.person.id, :to_id => to_person.id).first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -173,4 +173,19 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#request_for" do
|
||||
let!(:user5) {make_user}
|
||||
|
||||
it 'should not have a pending request before connecting' do
|
||||
request = user.request_for(user5.person)
|
||||
request.should be_nil
|
||||
end
|
||||
|
||||
it 'should have a pending request after sending a request' do
|
||||
user.send_contact_request_to(user5.person, user.aspects.first)
|
||||
request = user.reload.request_for(user5.person)
|
||||
request.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue