From e881edab96cce520b58f488360f7c8df6ee737b3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Dec 2010 18:05:18 -0800 Subject: [PATCH] Fix missing partials on last commit, you can now accept a request from the requestor's profile page --- app/controllers/aspects_controller.rb | 6 ++++++ app/views/people/_share_with_pane.html.haml | 20 ++++++++++++++++++++ app/views/people/share_with.html.haml | 18 ++++++++++++++++++ spec/controllers/aspects_controller_spec.rb | 21 +++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 app/views/people/_share_with_pane.html.haml create mode 100644 app/views/people/share_with.html.haml diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index cdb1d80ef..dda2ed1ee 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -116,6 +116,12 @@ class AspectsController < ApplicationController current_user.add_contact_to_aspect(@contact, @aspect) else current_user.send_contact_request_to(@person, @aspect) + contact = current_user.contact_for(@person) + + if request = Request.from(@person).to(current_user).first + request.destroy + contact.update_attributes(:pending => false) + end end flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success' diff --git a/app/views/people/_share_with_pane.html.haml b/app/views/people/_share_with_pane.html.haml new file mode 100644 index 000000000..fade052ad --- /dev/null +++ b/app/views/people/_share_with_pane.html.haml @@ -0,0 +1,20 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +.contact_list#aspects_list + %ul + - for aspect in aspects_with_person + %li{:data=>{:guid=>aspect.id}} + %span.name + = link_to aspect.name, aspect + .right + = aspect_membership_button(aspect.id, contact, person) + + - for aspect in aspects_without_person + %li{:data=>{:guid=>aspect.id}} + %span.name + = link_to aspect.name, aspect + .right + = aspect_membership_button(aspect.id, contact, person) + diff --git a/app/views/people/share_with.html.haml b/app/views/people/share_with.html.haml new file mode 100644 index 000000000..9d535847e --- /dev/null +++ b/app/views/people/share_with.html.haml @@ -0,0 +1,18 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +#share_with + .share_with_header + = person_image_link(@person, :size => :thumb_medium) + %h3 + = "Start sharing with #{@person.name}" + %p + = "Once #{@person.first_name} accepts, you'll start seeing each other's posts on Diaspora" + + = render :partial => 'share_with_pane', + :locals => {:person => @person, + :contact => @contact, + :aspects_with_person => @aspects_with_person, + :aspects_without_person => @aspects_without_person} + diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 4a23fabc0..0fd1ff1e7 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -227,6 +227,27 @@ describe AspectsController do end describe "#add_to_aspect" do + context 'with an incoming request' do + before do + @user3 = make_user + @user3.send_contact_request_to(@user.person, @user3.aspects.create(:name => "Walruses")) + end + it 'deletes the request' do + post 'add_to_aspect', + :format => 'js', + :person_id => @user3.person.id, + :aspect_id => @aspect1.id + Request.from(@user3).to(@user).first.should be_nil + end + it 'does not leave the contact pending' do + post 'add_to_aspect', + :format => 'js', + :person_id => @user3.person.id, + :aspect_id => @aspect1.id + @user.contact_for(@user3.person).should_not be_pending + + end + end context 'with a non-contact' do before do @person = Factory(:person)