diff options
author | maxwell <maxwell@joindiaspora.com> | 2010-09-13 23:21:04 +0400 |
---|---|---|
committer | maxwell <maxwell@joindiaspora.com> | 2010-09-13 23:21:04 +0400 |
commit | a9b64232df6613cd739a45e91979dfb0f1c2002d (patch) | |
tree | 32254087b1da304c478992c68c81c43ce076ae1f | |
parent | 24d957cb3276d44a9d1da9ced39dcde5c830947a (diff) | |
parent | f6b6720349510cc5e12c31b70aa9b861e53396ee (diff) |
Merge branch 'master' of github.com:diaspora/diaspora
-rw-r--r-- | app/models/person.rb | 1 | ||||
-rw-r--r-- | lib/diaspora/user/friending.rb | 12 | ||||
-rw-r--r-- | spec/controllers/requests_controller_spec.rb | 3 | ||||
-rw-r--r-- | spec/controllers/sockets_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/lib/diaspora_parser_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/person_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/photo_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/user/user_friending_spec.rb | 16 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 |
9 files changed, 14 insertions, 30 deletions
diff --git a/app/models/person.rb b/app/models/person.rb index ff1455010..d2e90485d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a32e1439c..175558514 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -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 diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index f6ddb849a..eaa0b72de 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -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 diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index 78e84c6d1..3e60c62e7 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -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}) diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index 8f8ca877a..feec817f2 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -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 diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index a816a84d5..6cc3a8716 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -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 diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 77e4e3208..1fccdd6c8 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -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 diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 59fe300ab..bd7293358 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d354cce6e..b85fc7f5a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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) |