From c8663b45e2d46a3c45f08b8d6ed8139eeaad6054 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 24 Oct 2010 15:17:15 -0700 Subject: [PATCH 1/5] readme added link to our convention --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a512f74d..8215e6c16 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You can find an introduction to the source code [here](http://github.com/diaspor Bugs and pending features are on our [issue tracker](http://bugs.joindiaspora.com). Here are a few good places to start: - Run "rake spec" to run our [Rspec](http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/) -unit test suite. Take a look at the pending specs, make one pass! +unit test suite. [Here](http://github.com/diaspora/diaspora/wiki/Introduction-to-Our-Rspec-Convention) is an introduction to our Rspec convention. Take a look at the pending specs, make one pass! - Run "rake cucumber" to run our [Cucumber](http://rubylearning.com/blog/2010/10/05/outside-in-development/) integration test suite. As you can see, we need more integration tests. Pick a feature and write one! From ff13cad116edc5875bfd9147ecf697392400008b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 12:19:32 -0700 Subject: [PATCH 2/5] names of people display immediately on aspect#manage page --- public/javascripts/aspect-edit.js | 4 ++++ public/javascripts/view.js | 1 + 2 files changed, 5 insertions(+) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 9e565e4b2..4b6f1c421 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -25,8 +25,12 @@ $(function() { revert: true, start: function(event,ui){ $(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200); + $(this).children("img").tipsy("hide"); $(".draggable_info").fadeIn(100); }, + drag: function(event,ui){ + $(this).children("img").tipsy("hide"); //ensure this is hidden + }, stop: function(event,ui){ $(this).children("img").animate({'height':70, 'width':70, 'opacity':1},200); $(".draggable_info").fadeOut(100); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 0b3987d53..26b3fea55 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -76,6 +76,7 @@ $(document).ready(function(){ $("img", "#left_pane").tipsy({live:true}); $(".add_aspect_button", "#aspect_nav").tipsy({gravity:'w'}); + $(".person img", ".dropzone").tipsy({live:true}); });//end document ready From 7f1d87f4241206ccaf3e6626e4e2d2110c2e92b8 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 12:57:43 -0700 Subject: [PATCH 3/5] fixed pagination bug on aspect#show (re: #445) --- app/controllers/aspects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 0129c0abf..985fb68a9 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -48,7 +48,7 @@ class AspectsController < ApplicationController render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @friends = @aspect.people - @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' + @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' respond_with @aspect end end From d8ca91769fbe1068b3a5c3ea06bd127065e98b94 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 13:03:45 -0700 Subject: [PATCH 4/5] dragging a person to Remove from Aspect on aspect#manage fades person correctly (re: #442) --- public/javascripts/aspect-edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 4b6f1c421..e4a581d57 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -92,7 +92,7 @@ $(function() { 'aspect_id' : person.attr('data-aspect_id') } }); } - person.fadeOut('slow', $(this).remove()); + person.fadeOut(400, function(){person.remove();}); } } }); From 8acdf212345e9c73d221a8d024d19b9b4af2a833 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Tue, 26 Oct 2010 14:49:37 -0700 Subject: [PATCH 5/5] MS IZ got rid of the requests for me scope in the user --- app/models/request.rb | 2 - app/models/user.rb | 10 ++--- lib/diaspora/user/friending.rb | 11 +++-- spec/models/request_spec.rb | 11 ----- spec/models/user/user_friending_spec.rb | 53 +++++++++++++++++-------- spec/spec_helper.rb | 1 + 6 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/models/request.rb b/app/models/request.rb index a6efdc987..2226a7b45 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -26,8 +26,6 @@ class Request validates_presence_of :destination_url, :callback_url before_validation :clean_link - scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) } - def self.instantiate(options = {}) person = options[:from] self.new(:destination_url => options[:to], diff --git a/app/models/user.rb b/app/models/user.rb index 6a184b156..850a2bb66 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,11 +32,11 @@ class User key :invites, Integer, :default => 5 key :invitation_token, String key :invitation_sent_at, DateTime - key :inviter_ids, Array - key :friend_ids, Array - key :pending_request_ids, Array - key :visible_post_ids, Array - key :visible_person_ids, Array + key :inviter_ids, Array, :typecast => 'ObjectId' + key :friend_ids, Array, :typecast => 'ObjectId' + key :pending_request_ids, Array, :typecast => 'ObjectId' + key :visible_post_ids, Array, :typecast => 'ObjectId' + key :visible_person_ids, Array, :typecast => 'ObjectId' key :invite_messages, Hash diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index 4a19ffd68..131b5b96a 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -29,9 +29,8 @@ module Diaspora end def accept_friend_request(friend_request_id, aspect_id) - request = Request.find_by_id(friend_request_id) - pending_requests.delete(request) - + request = pending_requests.find!(friend_request_id) + pending_request_ids.delete(request.id.to_id) activate_friend(request.person, aspect_by_id(aspect_id)) request.reverse_for(self) @@ -45,16 +44,16 @@ module Diaspora end def accept_and_respond(friend_request_id, aspect_id) - requester = Request.find_by_id(friend_request_id).person + requester = pending_requests.find!(friend_request_id).person reversed_request = accept_friend_request(friend_request_id, aspect_id) dispatch_friend_acceptance reversed_request, requester end def ignore_friend_request(friend_request_id) - request = Request.find_by_id(friend_request_id) + request = pending_requests.find!(friend_request_id) person = request.person - self.pending_requests.delete(request) + self.pending_request_ids.delete(request.id) self.save person.save diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 6483c45fa..6e5dfbf57 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -31,17 +31,6 @@ describe Request do xml.should include user.exported_key end - it 'should allow me to see only friend requests sent to me' do - remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/") - - Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save - Request.instantiate(:into => aspect.id, :from => remote_person, :to => user.receive_url).save - - Request.for_user(user).all.count.should == 1 - end - it 'should strip the destination url' do person_request = Request.new person_request.destination_url = " http://google.com/ " diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 63a472031..8a4386601 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -25,7 +25,7 @@ describe Diaspora::UserModules::Friending do end context 'friend requesting' do - it "should assign a request to a aspect" do + it "should assign a request to a aspect for the user that sent it out" do aspect.requests.size.should == 0 user.send_friend_request_to(friend, aspect) @@ -34,21 +34,42 @@ describe Diaspora::UserModules::Friending do aspect.requests.size.should == 1 end - it "should be able to accept a pending friend request" do - r = Request.instantiate(:to => user.receive_url, :from => friend) - r.save + describe '#receive_friend_request' do + it 'adds a request to pending if it was not sent by user' do + r = Request.instantiate(:to => user.receive_url, :from => friend) + r.save + user.receive_friend_request(r) + user.reload.pending_requests.should include r + end + + it 'should autoaccept a request the user sent' do + request = user.send_friend_request_to(user2.person, aspect) + request.reverse_for(user2) + proc{user.receive_friend_request(request)}.should change(user.reload.friends, :count).by(1) + end - proc { user.accept_friend_request(r.id, aspect.id) }.should change { - Request.for_user(user).all.count }.by(-1) end - it 'should be able to ignore a pending friend request' do - friend = Factory.create(:person) - r = Request.instantiate(:to => user.receive_url, :from => friend) - r.save + context 'received a friend request' do - proc { user.ignore_friend_request(r.id) }.should change { - Request.for_user(user).count }.by(-1) + let(:request_for_user) {Request.instantiate(:to => user.receive_url, :from => friend)} + let(:request2_for_user) {Request.instantiate(:to => user.receive_url, :from => person_one)} + before do + request_for_user.save + user.receive_friend_request(request_for_user) + user.receive_friend_request(request2_for_user) + user.reload + end + + it "should delete an accepted friend request" do + proc { user.accept_friend_request(request2_for_user.id, aspect.id) }.should change( + user.reload.pending_requests, :count ).by(-1) + end + + it 'should be able to ignore a pending friend request' do + proc { user.ignore_friend_request(request_for_user.id) }.should change ( + user.reload.pending_requests, :count ).by(-1) + end end it 'should not be able to friend request an existing friend' do @@ -168,20 +189,20 @@ describe Diaspora::UserModules::Friending do user.receive_friend_request @request person_two.destroy - user.pending_requests.size.should be 1 + user.reload.pending_requests.size.should be 1 user.friends.size.should be 0 user.receive_friend_request @request_two - user.pending_requests.size.should be 2 + user.reload.pending_requests.size.should be 2 user.friends.size.should be 0 user.accept_friend_request @request.id, aspect.id - user.pending_requests.size.should be 1 + user.reload.pending_requests.size.should be 1 user.friends.size.should be 1 user.friends.include?(person_one).should be true user.ignore_friend_request @request_two.id - user.pending_requests.size.should be 0 + user.reload.pending_requests.size.should be 0 user.friends.size.should be 1 user.friends.include?(person_two).should be false end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29d731b29..11f18d8d2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,6 +67,7 @@ ImageUploader.enable_processing = false def friend_users(user1, aspect1, user2, aspect2) request = user1.send_friend_request_to(user2.person, aspect1) + user2.receive_friend_request(request) reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.reload user1.receive reversed_request.to_diaspora_xml, user2.person