Merge branch 'master' of github.com:diaspora/diaspora into contact-refactor
Conflicts: app/controllers/aspects_controller.rb
This commit is contained in:
commit
1024b8a3a7
8 changed files with 50 additions and 37 deletions
|
|
@ -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!
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -88,7 +92,7 @@ $(function() {
|
|||
'aspect_id' : person.attr('data-aspect_id') }
|
||||
});
|
||||
}
|
||||
person.fadeOut('slow', $(this).remove());
|
||||
person.fadeOut(400, function(){person.remove();});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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/ "
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ describe Diaspora::UserModules::Friending do
|
|||
|
||||
|
||||
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)
|
||||
|
|
@ -70,21 +70,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
|
||||
|
|
@ -204,20 +225,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.contact_for(person_one).should_not be_nil
|
||||
|
||||
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.contact_for(person_two).should be_nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue