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

Merge branch 'master' of github.com:diaspora/diaspora

parents 24d957cb f6b67203
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -16,7 +16,6 @@ class Person
key :serialized_key, String
key :owner_id, ObjectId
key :user_refs, Integer, :default => 0
one :profile, :class_name => 'Profile'
many :albums, :class_name => 'Album', :foreign_key => :person_id
......
......@@ -46,12 +46,10 @@ module Diaspora
request = Request.find_by_id(friend_request_id)
person = request.person
person.user_refs -= 1
self.pending_requests.delete(request)
self.save
(person.user_refs > 0 || person.owner.nil? == false) ? person.save : person.destroy
person.save
request.destroy
end
......@@ -66,9 +64,6 @@ module Diaspora
friend_request.destroy
else
friend_request.person.reload
friend_request.person.user_refs += 1
friend_request.person.save
self.pending_requests << friend_request
self.save
Rails.logger.info("#{self.real_name} has received a friend request")
......@@ -95,8 +90,7 @@ module Diaspora
}
self.save
bad_friend.user_refs -= 1
(bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy
bad_friend.save
end
def unfriended_by(bad_friend)
......@@ -105,11 +99,9 @@ module Diaspora
end
def activate_friend(person, aspect)
person.user_refs += 1
aspect.people << person
friends << person
save
person.save
aspect.save
end
......
......@@ -9,8 +9,9 @@ describe RequestsController do
@evan = Redfinger.finger('evan@status.net')
@max = Redfinger.finger('mbs348@gmail.com')
sign_in :user, @user
stub!(:current_user).and_return @user
end
it 'should return the correct tag and url for a given address' do
relationship_flow('tom@tom.joindiaspora.com')[:friend].include?("receive/user").should == true
relationship_flow('tom@tom.joindiaspora.com')[:friend].receive_url.include?("receive/user").should == true
end
end
......@@ -26,6 +26,7 @@ describe SocketsController do
end
it 'should actionhash photos' do
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
@album = @user.post(:album, :name => "Loser faces", :to => @aspect.id)
photo = @user.post(:photo, :album_id => @album.id, :user_file => [File.open(@fixture_name)])
json = @controller.action_hash(@user.id, photo, :aspect_ids => @user.aspects_with_post(@album.id).map{|g| g.id})
......
......@@ -136,7 +136,6 @@ describe Diaspora::Parser do
Person.count.should == person_count
@user.receive retraction_xml
Person.count.should == person_count-1
@aspect.reload
@aspect.people.size.should == aspect_people_count -1
......
......@@ -59,7 +59,7 @@ describe Person do
end
describe "unfriending" do
it 'should delete an orphaned friend' do
it 'should not delete an orphaned friend' do
request = @user.send_friend_request_to @person, @aspect
@user.activate_friend(@person, @aspect)
......@@ -70,7 +70,7 @@ describe Person do
@user.unfriend(@person)
@user.reload
@user.friends.count.should == 0
Person.all.count.should == 2
Person.all.count.should == 3
end
it 'should not delete an un-orphaned friend' do
......
......@@ -15,7 +15,8 @@ describe Photo do
end
it 'should have a constructor' do
image = File.open(@fixture_name)
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
image = File.open(@fixture_name)
photo = Photo.instantiate(:person => @user.person, :album => @album, :user_file => [image])
photo.created_at.nil?.should be false
photo.image.read.nil?.should be false
......@@ -87,6 +88,7 @@ describe Photo do
end
it 'should save a signed photo' do
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
photo = @user.post(:photo, :album_id => @album.id, :user_file => [File.open(@fixture_name)])
photo.save.should == true
photo.signature_valid?.should be true
......
......@@ -38,7 +38,7 @@ describe User do
@user.ignore_friend_request(r.id)
Person.count.should == 1
Person.count.should == 2
Request.count.should == 0
end
......@@ -125,7 +125,7 @@ describe User do
Person.all.count.should be 3
end
it 'should not keep the person around if the users ignores them' do
it 'should keep the person around if the users ignores them' do
@user.receive @req_xml
@user.pending_requests.size.should be 1
@user.ignore_friend_request @user.pending_requests.first.id
......@@ -135,7 +135,7 @@ describe User do
@user2.pending_requests.size.should be 1
@user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id
@user2.friends.include?(@person_one).should be false
Person.all.count.should be 2
Person.all.count.should be 3
end
......@@ -196,21 +196,11 @@ describe User do
@user.friends.count.should == 1
@user2.friends.count.should == 1
@user.person.user_refs.should == 1
@user2.person.user_refs.should == 1
@user2.unfriend @user.person
@user2.friends.count.should be 0
@user.person.reload
@user.person.user_refs.should == 0
@user.unfriended_by @user2.person
@user2.person.reload
@user2.person.user_refs.should == 0
@aspect.reload
@aspect2.reload
@aspect.people.count.should == 0
......
......@@ -58,7 +58,7 @@ end
end
def message_queue
Post.send(:class_variable_get, :@@queue)
User::QUEUE
end
def friend_users(user1, aspect1, user2, aspect2)
......
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