Skip to content
Extraits de code Groupes Projets
Valider 79c0e960 rédigé par ilya's avatar ilya
Parcourir les fichiers

DG IZ; friend now has an active flag

parent d5d4d4ae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class Friend < Person
key :active, Boolean, :default => false
end
......@@ -8,7 +8,7 @@ class FriendRequest
validates_presence_of :url
before_save :shoot_off
before_save :shoot_off, :check_for_friend_requests
def to_friend_xml
friend = Friend.new
......@@ -23,4 +23,12 @@ class FriendRequest
push_friend_request_to_url(self.url)
end
def check_for_friend_requests
f = Friend.where(:url => self.url).first
if f
f.active = true
f.save
end
end
end
......@@ -34,6 +34,9 @@ module Diaspora
if p.is_a? Retraction
p.perform
elsif p.is_a? Friend
if FriendRequest.where(:url => p.url).first
p.active = true
end
p.save
#This line checks if the sender was in the database, among other things?
elsif p.respond_to?(:person) && !(p.person.nil?) #WTF
......
......@@ -123,6 +123,25 @@ describe "parser in application helper" do
store_objects_from_xml(xml)
Friend.count.should be 1
end
it "should activate the Friend if I initiated a request to that url" do
friend_request = FriendRequest.create(:url => @friend.url, :sender => @user)
friend_request_remote = FriendRequest.new(:url => "http://www.yahoo.com/")
friend_request_remote.sender = @friend.clone
xml = "<XML>
<posts><post>
#{friend_request_remote.to_friend_xml.to_s}
</post></posts>
</XML>"
@friend.destroy
Friend.count.should be 0
store_objects_from_xml(xml)
Friend.count.should be 1
Friend.first.active.should be true
end
end
end
......@@ -26,7 +26,13 @@ describe FriendRequest do
friend_request = FriendRequest.new(:url => "http://www.google.com")
friend_request.sender = Factory.create(:user)
friend_request.save
end
it "should activate a friend if it exists on creation of a request for that url" do
user = Factory.create(:user)
friend = Factory.create(:friend, :url => "http://google.com/")
FriendRequest.create(:url => friend.url, :sender => user)
Friend.first.active.should be true
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter