Skip to content
Extraits de code Groupes Projets
Valider c2c64d99 rédigé par maxwell's avatar maxwell
Parcourir les fichiers

MS DG more friend request tests pass

parent 2142ad27
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,9 @@ class Request
key :destination_url, String
key :callback_url, String
key :person, Person
key :person_id, ObjectId
belongs_to :person
validates_presence_of :destination_url, :callback_url
......
......@@ -4,7 +4,7 @@ class User < Person
:recoverable, :rememberable, :trackable, :validatable
before_create :assign_key
#before_create :assign_key
validates_presence_of :profile
before_validation :do_bad_things
......@@ -43,7 +43,7 @@ class User < Person
request = Request.where(:id => friend_request_id).first
request.activate_friend
request.person = self
request.push_to(self.callback_url)
request.push_to_url(request.callback_url)
request.destroy
end
......@@ -52,6 +52,7 @@ class User < Person
friend_request.activate_friend
friend_request.destroy
else
#does this actually save as the same id?
friend_request.save
end
end
......
......@@ -127,7 +127,7 @@ describe "parser in application helper" do
request_remote = Request.new(:_id => request.id)#
request_remote.destination_url = @user.url
request_remote.callback_url = @user.url
request_remote.person = @person.clone
request_remote.person = @person
xml = Request.build_xml_for [request_remote]
......
......@@ -11,10 +11,21 @@ describe Request do
end
it 'should generate xml for the User as a Person' do
user = Factory.create(:user)
request = Request.new(:url => "http://www.google.com/", :person => user)
user = User.create(:email => "rob@bob.com")
user.profile = Factory.create(:profile)
user.save(:validate => false)
user.profile.save
request = Request.instantiate(:to => "http://www.google.com/", :from => user)
xml = request.to_xml.to_s
puts xml
puts user.profile.first_name
puts user.profile.last_name
xml.include?(user.email).should be true
xml.include?(user.url).should be true
xml.include?(user.profile.first_name).should be true
......
......@@ -6,4 +6,20 @@ describe User do
Factory.create(:user)
Person.count.should == n+1
end
it "should be able to accept a pending friend request" do
@user = Factory.create(:user)
@friend = Factory.create(:person)
r = Request.instantiate(:to => @user.url, :from => @friend)
r.save
Person.all.count.should == 2
Request.for_user(@user).all.count.should == 1
@user.accept_friend_request(r.id)
Request.for_user(@user).all.count.should == 0
Person.where(:id => @friend.id).first.active.should == true
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter