DG IZ; starting fresh with requests
This commit is contained in:
parent
f71b5b51d1
commit
a23a2691f3
9 changed files with 5 additions and 110 deletions
|
|
@ -1,18 +1,3 @@
|
|||
class FriendRequest
|
||||
include MongoMapper::Document
|
||||
|
||||
key :recipient_url
|
||||
|
||||
attr_accessor :sender
|
||||
|
||||
validates_presence_of :recipient_url
|
||||
|
||||
after_create :send_off
|
||||
|
||||
def send_off
|
||||
sender = Friend.from_xml( self.sender.to_xml )
|
||||
|
||||
sender.push_to_url self.recipient_url
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
= form_for @friend_request do |f|
|
||||
= f.error_messages
|
||||
|
||||
|
||||
= f.fields_for :recipient do |r|
|
||||
%p
|
||||
= r.label :email
|
||||
= r.text_field :email
|
||||
%p
|
||||
= r.label :url
|
||||
= r.text_field :url
|
||||
%p
|
||||
= f.submit
|
||||
f.submit
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
%li.message{:id => post.id}
|
||||
%li.message{:id => friend_request.id}
|
||||
|
||||
= post.inspect
|
||||
%h2= post.sender.is_a? User
|
||||
= friend_request.inspect
|
||||
|
|
|
|||
|
|
@ -1,12 +1,4 @@
|
|||
= form_for @friend_request, :remote => true do |f|
|
||||
= f.error_messages
|
||||
|
||||
= f.fields_for :recipient do |r|
|
||||
%p
|
||||
= r.label :email
|
||||
= r.text_field :email
|
||||
%p
|
||||
= r.label :url
|
||||
= r.text_field :url
|
||||
%p
|
||||
= f.submit
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
= render "friend_requests/new_friend_request", :friend_request => @friend_request
|
||||
%ul#stream
|
||||
- for friend_request in @friend_requests
|
||||
= render "friend_request", :post => friend_request
|
||||
= render "friend_request", :friend_request => friend_request
|
||||
#pagination
|
||||
= will_paginate @friend_requests
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
- title "Friend Request"
|
||||
|
||||
%p
|
||||
%strong Recipient:
|
||||
= @friend_request.recipient
|
||||
%p
|
||||
%strong Sender:
|
||||
= @friend_request.sender
|
||||
= friend_request.inspect
|
||||
|
||||
%p
|
||||
= link_to "Edit", edit_friend_request_path(@bookmark)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ module Diaspora
|
|||
if p.is_a? Retraction
|
||||
|
||||
p.perform
|
||||
elsif p.is_a? Friend
|
||||
p.save
|
||||
#This line checks if the sender was in the database, among other things?
|
||||
elsif p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||
p.save
|
||||
|
|
@ -65,15 +63,6 @@ module Diaspora
|
|||
@@queue.process
|
||||
end
|
||||
end
|
||||
|
||||
def push_to_url(url)
|
||||
if url
|
||||
url = url + "receive/"
|
||||
xml = self.class.build_xml_for([self])
|
||||
@@queue.add_post_request( [url], xml )
|
||||
@@queue.process
|
||||
end
|
||||
end
|
||||
|
||||
def prep_webhook
|
||||
"<post>#{self.to_xml.to_s}</post>"
|
||||
|
|
|
|||
|
|
@ -109,16 +109,6 @@ describe "parser in application helper" do
|
|||
StatusMessage.count.should == 0
|
||||
end
|
||||
|
||||
it 'should marshal friend requests' do
|
||||
sender = Factory.build(:user, :email => "bob@aol.com", :url => "http://google.com/")
|
||||
recipient = Factory.build(:person, :email => "robert@grimm.com", :url => "http://localhost:3000/")
|
||||
friend_request = FriendRequest.new(:sender => sender, :recipient => recipient)
|
||||
xml_request = Post.build_xml_for([friend_request])
|
||||
|
||||
FriendRequest.count.should be 0
|
||||
store_objects_from_xml( xml_request )
|
||||
FriendRequest.count.should be 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,52 +1,4 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe FriendRequest do
|
||||
before do
|
||||
sender = Factory.build(:user, :email => "bob@aol.com", :url => "http://google.com/")
|
||||
recipient = Factory.build(:person, :email => "robert@grimm.com", :url => "http://localhost:3000/")
|
||||
@request = FriendRequest.create(:sender => sender, :recipient => recipient)
|
||||
end
|
||||
|
||||
it 'should have sender and recipient credentials after serialization' do
|
||||
xml = @request.to_xml.to_s
|
||||
xml.include?(@request.sender.url).should be true
|
||||
xml.include?(@request.sender.email).should be true
|
||||
xml.include?(@request.recipient.url).should be true
|
||||
xml.include?(@request.recipient.email).should be true
|
||||
end
|
||||
|
||||
describe "acceptance" do
|
||||
it 'should create a friend' do
|
||||
Friend.count.should be 0
|
||||
@request.accept
|
||||
Friend.count.should be 1
|
||||
end
|
||||
|
||||
it 'should remove the request' do
|
||||
FriendRequest.count.should be 1
|
||||
@request.accept
|
||||
FriendRequest.count.should be 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "rejection" do
|
||||
it 'should not create a friend' do
|
||||
Friend.count.should be 0
|
||||
@request.reject
|
||||
Friend.count.should be 0
|
||||
end
|
||||
|
||||
it 'should remove the request' do
|
||||
FriendRequest.count.should be 1
|
||||
@request.reject
|
||||
FriendRequest.count.should be 0
|
||||
end
|
||||
end
|
||||
|
||||
it 'should dispatch upon creation' do
|
||||
FriendRequest.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
sender = Factory.build(:user, :email => "bob@aol.com", :url => "http://google.com/")
|
||||
recipient = Factory.build(:person, :email => "robert@grimm.com", :url => "http://localhost:3000/")
|
||||
FriendRequest.create(:sender => sender, :recipient => recipient)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue