DG IZ; added for action to friend request
This commit is contained in:
parent
4b6e29a4d2
commit
d705d39f70
2 changed files with 10 additions and 8 deletions
|
|
@ -8,7 +8,7 @@ class FriendRequest
|
|||
|
||||
validates_presence_of :url
|
||||
|
||||
before_save :shoot_off, :check_for_friend_requests
|
||||
before_save :check_for_friend_requests
|
||||
|
||||
def to_friend_xml
|
||||
friend = Friend.new
|
||||
|
|
@ -19,8 +19,12 @@ class FriendRequest
|
|||
friend.to_xml
|
||||
end
|
||||
|
||||
def shoot_off
|
||||
push_friend_request_to_url(self.url)
|
||||
def self.for(url)
|
||||
friend_request = FriendRequest.new(:url => url)
|
||||
friend_request.sender = User.first
|
||||
friend_request.save
|
||||
|
||||
friend_request.push_friend_request_to_url(friend_request.url)
|
||||
end
|
||||
|
||||
def check_for_friend_requests
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ describe FriendRequest do
|
|||
friend_xml.include?(user.profile.last_name).should be true
|
||||
end
|
||||
|
||||
it 'should be sent to the url upon save' do
|
||||
it 'should be sent to the url upon for action' do
|
||||
FriendRequest.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
|
||||
friend_request = FriendRequest.new(:url => "http://www.google.com")
|
||||
friend_request.sender = Factory.create(:user)
|
||||
friend_request.save
|
||||
Factory.create(:user)
|
||||
FriendRequest.for("http://www.google.com")
|
||||
end
|
||||
|
||||
it "should activate a friend if it exists on creation of a request for that url" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue