All green except invite connecting +2 misc.

This commit is contained in:
danielgrippi 2011-04-04 15:16:19 -07:00
parent c800b0bfef
commit 590e1fd93f
27 changed files with 262 additions and 616 deletions

View file

@ -123,7 +123,6 @@ class AspectsController < ApplicationController
def manage def manage
@aspect = :manage @aspect = :manage
@contacts = current_user.contacts.includes(:person => :profile) @contacts = current_user.contacts.includes(:person => :profile)
@remote_requests = Request.where(:recipient_id => current_user.person.id).includes(:sender => :profile)
@aspects = @all_aspects.includes(:contacts => {:person => :profile}) @aspects = @all_aspects.includes(:contacts => {:person => :profile})
end end

View file

@ -17,9 +17,7 @@ class ContactsController < ApplicationController
@person = Person.find(params[:person_id]) @person = Person.find(params[:person_id])
@aspect = current_user.aspects.where(:id => params[:aspect_id]).first @aspect = current_user.aspects.where(:id => params[:aspect_id]).first
@contact = request_to_aspect(@aspect, @person) if @contact = share_in_aspect(@aspect, @person)
if @contact && @contact.persisted?
flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success' flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success'
respond_to do |format| respond_to do |format|
@ -40,15 +38,11 @@ class ContactsController < ApplicationController
end end
def edit def edit
@all_aspects ||= current_user.aspects @contact = current_user.contacts.unscoped.find(params[:id])
@contact = Contact.unscoped.where(:id => params[:id], :user_id => current_user.id).first
@person = @contact.person @person = @contact.person
@aspects_with_person = []
if @contact @all_aspects ||= current_user.aspects
@aspects_with_person = @contact.aspects @aspects_with_person = @contact.aspects || []
end
@aspects_without_person = @all_aspects - @aspects_with_person @aspects_without_person = @all_aspects - @aspects_with_person
@ -56,7 +50,8 @@ class ContactsController < ApplicationController
end end
def destroy def destroy
contact = Contact.unscoped.where(:id => params[:id], :user_id => current_user.id).first contact = current_user.contacts.unscoped.find(params[:id])
if current_user.disconnect(contact) if current_user.disconnect(contact)
flash[:notice] = I18n.t('contacts.destroy.success', :name => contact.person.name) flash[:notice] = I18n.t('contacts.destroy.success', :name => contact.person.name)
else else
@ -67,13 +62,7 @@ class ContactsController < ApplicationController
private private
def request_to_aspect(aspect, person) def share_in_aspect(aspect, person)
current_user.send_contact_request_to(person, aspect) current_user.share_with(person, aspect)
contact = current_user.contact_for(person)
if request = Request.where(:sender_id => person.id, :recipient_id => current_user.person.id).first
request.destroy
contact.update_attributes(:pending => false)
end
contact
end end
end end

View file

@ -39,10 +39,6 @@ class PeopleController < ApplicationController
def hashes_for_people people, aspects def hashes_for_people people, aspects
ids = people.map{|p| p.id} ids = people.map{|p| p.id}
requests = {}
Request.where(:sender_id => ids, :recipient_id => current_user.person.id).each do |r|
requests[r.id] = r
end
contacts = {} contacts = {}
Contact.unscoped.where(:user_id => current_user.id, :person_id => ids).each do |contact| Contact.unscoped.where(:user_id => current_user.id, :person_id => ids).each do |contact|
contacts[contact.person_id] = contact contacts[contact.person_id] = contact
@ -51,7 +47,6 @@ class PeopleController < ApplicationController
people.map{|p| people.map{|p|
{:person => p, {:person => p,
:contact => contacts[p.id], :contact => contacts[p.id],
:request => requests[p.id],
:aspects => aspects} :aspects => aspects}
} }
end end
@ -63,17 +58,14 @@ class PeopleController < ApplicationController
return return
end end
@post_type = :all @post_type = :all
@aspect = :profile @aspect = :profile
@share_with = (params[:share_with] == 'true') @share_with = (params[:share_with] == 'true')
if @person if @person
@profile = @person.profile @profile = @person.profile
if current_user if current_user
@incoming_request = current_user.request_from(@person)
@contact = current_user.contact_for(@person) @contact = current_user.contact_for(@person)
@aspects_with_person = [] @aspects_with_person = []
if @contact if @contact

View file

@ -1,59 +0,0 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib/webfinger')
class RequestsController < ApplicationController
before_filter :authenticate_user!
include RequestsHelper
respond_to :html
def destroy
if notification = Notification.where(:recipient_id => current_user.id, :target_id=> params[:id]).first
notification.update_attributes(:unread=>false)
end
if params[:accept]
if params[:aspect_id]
@contact = current_user.accept_and_respond( params[:id], params[:aspect_id])
flash[:notice] = I18n.t 'requests.destroy.success'
respond_with @contact, :location => requests_url
else
flash[:error] = I18n.t 'requests.destroy.error'
respond_with @contact, :location => requests_url
end
else
current_user.ignore_contact_request params[:id]
flash[:notice] = I18n.t 'requests.destroy.ignore'
head :ok
end
end
def create
aspect = current_user.aspects.where(:id => params[:request][:into]).first
account = params[:request][:to].strip
person = Person.by_account_identifier(account)
existing_request = Request.where(:sender_id => person.id, :recipient_id => current_user.person.id).first if person
if existing_request
current_user.accept_and_respond(existing_request.id, aspect.id)
redirect_to :back
else
@contact = Contact.new(:user => current_user,
:person => person,
:aspect_ids => [aspect.id],
:pending => true)
if @contact.save
@contact.dispatch_request
flash.now[:notice] = I18n.t('requests.create.sent')
redirect_to :back
else
flash.now[:error] = @contact.errors.full_messages.join(', ')
redirect_to :back
end
end
end
end

View file

@ -85,9 +85,9 @@ class Invitation < ActiveRecord::Base
recipient.invite! recipient.invite!
end end
def to_request! def share_with!
request = sender.send_contact_request_to(recipient.person, aspect) contact = sender.share_with(recipient.person, aspect)
destroy if request destroy if contact
request contact
end end
end end

View file

@ -66,7 +66,10 @@ class Request < ActiveRecord::Base
def receive(user, person) def receive(user, person)
Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}") Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}")
user.receive_contact_request(self)
user.contacts.create(:person_id => person.id, :pending => false)
#user.receive_contact_request(self)
self.save self.save
self self
end end

View file

@ -261,7 +261,7 @@ class User < ActiveRecord::Base
self.password = opts[:password] self.password = opts[:password]
self.password_confirmation = opts[:password_confirmation] self.password_confirmation = opts[:password_confirmation]
self.save! self.save!
invitations_to_me.each{|invitation| invitation.to_request!} invitations_to_me.each{|invitation| invitation.share_with!}
log_string << "success" log_string << "success"
Rails.logger.info log_string Rails.logger.info log_string

View file

@ -16,32 +16,7 @@
=t('.manage_aspects') =t('.manage_aspects')
#manage_aspect_zones #manage_aspect_zones
.span-4.append-1.last .span-24.last
.requests
%h3=t('.requests')
%ul.dropzone
- if @remote_requests.size < 1
%li=t('.no_requests')
- else
- for req in @remote_requests
%li.person.request{:data=>{:guid=> req.id, :person_id=> req.sender.id}}
.delete
.x
X
.circle
= link_to person_image_tag(req.sender), req.sender
- if @remote_requests.size > 0
%p
%i= "#{t('.drag_to_add')} =>"
= render 'shared/invitations', :invites => @invites
%div{:style=>"color:rgb(252,252,252);"}
\.
.span-19.last
- for aspect in @aspects - for aspect in @aspects
.aspect.span-9{:data=>{:guid => aspect.id}} .aspect.span-9{:data=>{:guid => aspect.id}}
.aspect_name .aspect_name

View file

@ -8,10 +8,10 @@
= t('.share_with', :name => person.name) = t('.share_with', :name => person.name)
.description .description
= t('.accepts', :name => person.first_name) = t('.following', :name => person.first_name)
= render :partial => 'contacts/share_with_list', = render :partial => 'contacts/share_with_list',
:locals => {:person => person, :contact => contact, :locals => {:person => person, :contact => contact,
:aspects_with_person => aspects_with_person, :aspects_with_person => aspects_with_person,
:aspects_without_person => aspects_without_person} :aspects_without_person => aspects_without_person}

View file

@ -2,15 +2,6 @@
= t('people.person.thats_you') = t('people.person.thats_you')
- elsif contact && !contact.pending - elsif contact && !contact.pending
= t('people.person.already_connected') = t('people.person.already_connected')
- elsif (contact && contact.pending) || (request && request.recipient == person)
= t('people.person.pending_request')
- elsif request && request.sender == person
= link_to t('people.show.incoming_request', :name => truncate(person.name, :length => 20, :separator => ' ', :omission => '')),
{:controller => "contacts",
:action => "new",
:person_id => person.id},
:class => 'share_with button',
:rel => 'facebox'
- else - else
= link_to t('people.show.start_sharing'), = link_to t('people.show.start_sharing'),
{:controller => "contacts", {:controller => "contacts",

View file

@ -26,23 +26,14 @@
#author_info #author_info
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person) - if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
.right .right
- if @incoming_request = link_to t('.start_sharing'),
= link_to t('.incoming_request', :name => truncate(@person.name, :length => 20, :separator => ' ', :omission => '')), {:controller => "contacts",
{:controller => "contacts", :action => "new",
:action => "new", :person_id => @person.id},
:person_id => @person.id}, :class => 'share_with button',
:class => 'share_with button', :rel => 'facebox'
:rel => 'facebox' - if @share_with
-else = javascript_tag "$(document).ready(function() {jQuery.facebox({ ajax: '#{new_contact_path(:person_id => @person.id)}' });});"
= link_to t('.start_sharing'),
{:controller => "contacts",
:action => "new",
:person_id => @person.id},
:class => 'share_with button',
:rel => 'facebox'
- if @share_with
= javascript_tag "$(document).ready(function() {jQuery.facebox({ ajax: '#{new_contact_path(:person_id => @person.id)}' });});"
- else - else
- if user_signed_in? && @contact.person && @contact.pending? == false - if user_signed_in? && @contact.person && @contact.pending? == false

View file

@ -174,12 +174,11 @@ en:
failure: "Failed to disconnect from %{name}" failure: "Failed to disconnect from %{name}"
share_with_pane: share_with_pane:
share_with: "Start sharing with %{name}" share_with: "Start sharing with %{name}"
accepts: "Once %{name} accepts, you'll start seeing each other's posts on Diaspora" following: "By placing %{name} in an aspect, you'll start following and sending posts to them."
add_new_aspect: "add to new aspect" add_new_aspect: "add to new aspect"
create: create:
failure: "Failed to create contact" failure: "Failed to create contact"
conversations: conversations:
index: index:
message_inbox: "Message Inbox" message_inbox: "Message Inbox"

View file

@ -68,8 +68,6 @@ Diaspora::Application.routes.draw do
get 'bookmarklet' => 'status_messages#bookmarklet' get 'bookmarklet' => 'status_messages#bookmarklet'
resource :profile resource :profile
resources :requests, :only => [:destroy, :create]
resources :contacts, :except => [:index, :update] resources :contacts, :except => [:index, :update]
resources :aspect_memberships, :only => [:destroy, :create, :update] resources :aspect_memberships, :only => [:destroy, :create, :update]
resources :post_visibilities, :only => [:update] resources :post_visibilities, :only => [:update]

View file

@ -8,26 +8,23 @@ Feature: sending and receiving requests
And I am on "alice@alice.alice"'s page And I am on "alice@alice.alice"'s page
And I press the first ".share_with.button" within "#author_info" And I press the first ".share_with.button" within "#author_info"
And I add the person to my first aspect And I add the person to my first aspect
And I am on the home page
Given I expand the publisher
When I fill in "status_message_fake_text" with "I am following you"
And I press "Share"
Then I go to the destroy user session page Then I go to the destroy user session page
Scenario: accepting a contact request Scenario: see follower's posts on their profile page and not on the home page
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I am on the manage aspects page And I am on "bob@bob.bob"'s page
Then I should see 1 contact request Then I should see "I am following you"
When I drag the contact request to the "Besties" aspect
And I wait for the ajax to finish
Then I should see 1 contact in "Besties"
When I go to the home page And I am on the home page
Then I go to the manage aspects page Then I should not see "I am following you"
Then I should see 1 contact in "Besties"
Then I go to the destroy user session page
When I sign in as "bob@bob.bob" Scenario: mutual following the original follower should see private posts on their stream
And I am on the manage aspects page
Then I should see 1 contact in "Besties"
Scenario: accepting a contact request to multiple aspects
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page And I am on "bob@bob.bob"'s page
And I press the 1st ".share_with.button" within "#author_info" And I press the 1st ".share_with.button" within "#author_info"
@ -36,19 +33,25 @@ Feature: sending and receiving requests
And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:nth-child(2)" And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:nth-child(2)"
And I wait for the ajax to finish And I wait for the ajax to finish
When I go to the home page When I go to the home page
Then I go to the manage aspects page Then I go to the manage aspects page
Then I should see 1 contact in "Unicorns" Then I should see 1 contact in "Unicorns"
Then I should see 1 contact in "Besties" Then I should see 1 contact in "Besties"
Then I go to the destroy user session page
When I sign in as "bob@bob.bob" And I am on the home page
And I am on the manage aspects page Given I expand the publisher
Then I should see 1 contact in "Besties" When I fill in "status_message_fake_text" with "I am following you back"
And I press "Share"
Then I go to the destroy user session page
When I sign in as "bob@bob.bob"
And I am on the manage aspects page
Then I should see 1 contact in "Besties"
And I am on the home page
Then I should see "I am following you back"
Scenario: accepting a contact request into a new aspect Scenario: accepting a contact request into a new aspect
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page And I am on "bob@bob.bob"'s page

View file

@ -5,10 +5,22 @@
module Diaspora module Diaspora
module UserModules module UserModules
module Connecting module Connecting
def share_with(person, aspect)
contact = self.contacts.find_or_initialize_by_person_id(person.id)
unless contact.persisted?
contact.dispatch_request
end
contact.aspects << aspect
contact.save
contact
end
#begin
def send_contact_request_to(desired_contact, aspect) def send_contact_request_to(desired_contact, aspect)
contact = Contact.new(:person => desired_contact, self.contacts.new(:person => desired_contact,
:user => self, :pending => true)
:pending => true)
contact.aspects << aspect contact.aspects << aspect
if contact.save! if contact.save!
@ -19,6 +31,11 @@ module Diaspora
end end
end end
def dispatch_contact_acceptance(request, requester)
Postzord::Dispatch.new(self, request).post
request.destroy unless request.sender.owner
end
def accept_contact_request(request, aspect) def accept_contact_request(request, aspect)
activate_contact(request.sender, aspect) activate_contact(request.sender, aspect)
@ -30,12 +47,6 @@ module Diaspora
request.reverse_for(self) request.reverse_for(self)
end end
def dispatch_contact_acceptance(request, requester)
Postzord::Dispatch.new(self, request).post
request.destroy unless request.sender.owner
end
def accept_and_respond(contact_request_id, aspect_id) def accept_and_respond(contact_request_id, aspect_id)
request = Request.where(:recipient_id => self.person.id, :id => contact_request_id).first request = Request.where(:recipient_id => self.person.id, :id => contact_request_id).first
requester = request.sender requester = request.sender
@ -72,6 +83,14 @@ module Diaspora
received_request.destroy received_request.destroy
self.save self.save
end end
def activate_contact(person, aspect)
new_contact = Contact.create!(:user => self,
:person => person,
:aspects => [aspect],
:pending => false)
end
#end
def disconnect(bad_contact) def disconnect(bad_contact)
person = bad_contact.person person = bad_contact.person
@ -102,12 +121,6 @@ module Diaspora
end end
end end
def activate_contact(person, aspect)
new_contact = Contact.create!(:user => self,
:person => person,
:aspects => [aspect],
:pending => false)
end
end end
end end
end end

View file

@ -78,11 +78,6 @@ module Diaspora
self.aspects.all.collect{|x| x.id} self.aspects.all.collect{|x| x.id}
end end
def request_from(person)
Request.where(:sender_id => person.id,
:recipient_id => self.person.id).first
end
def posts_from(person) def posts_from(person)
return self.person.posts.where(:pending => false).order("created_at DESC") if person == self.person return self.person.posts.where(:pending => false).order("created_at DESC") if person == self.person
con = Contact.arel_table con = Contact.arel_table

View file

@ -45,20 +45,6 @@ var AspectEdit = {
var dropzone = $(this); var dropzone = $(this);
var person = ui.draggable; var person = ui.draggable;
if (person.hasClass('request')) {
$.ajax({
type: "DELETE",
url: "/requests/" + person.attr('data-guid'),
data: {
"accept": true,
"aspect_id": dropzone.attr('data-aspect_id')
},
success: function() {
AspectEdit.onDeleteRequestSuccess(person, dropzone);
}
});
}
if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing contact does if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing contact does
dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
var aspect_id = person.attr('data-aspect_id') var aspect_id = person.attr('data-aspect_id')
@ -95,16 +81,6 @@ var AspectEdit = {
if( $(".person[data-guid='"+ person_id +"']").length == 1) { if( $(".person[data-guid='"+ person_id +"']").length == 1) {
Diaspora.widgets.alert.alert("Error removing contact", "You cannot remove the person from the last aspect"); Diaspora.widgets.alert.alert("Error removing contact", "You cannot remove the person from the last aspect");
} else { } else {
if (!person.hasClass('request')) {
var aspect_id = person.attr('data-aspect_id')
$.ajax({
type: "DELETE",
url: "/aspect_memberships/" + aspect_id,
data: {
'person_id': person_id
}
});
}
person.fadeOut(400, function() { person.fadeOut(400, function() {
person.remove(); person.remove();
}); });

View file

@ -249,10 +249,6 @@ describe AspectsController do
get :manage get :manage
assigns(:aspect).should == :manage assigns(:aspect).should == :manage
end end
it "assigns remote_requests" do
get :manage
assigns(:remote_requests).should be_empty
end
it "assigns contacts to only non-pending" do it "assigns contacts to only non-pending" do
contact = @alice.contact_for(bob.person) contact = @alice.contact_for(bob.person)
Contact.unscoped.where(:user_id => @alice.id).count.should == 1 Contact.unscoped.where(:user_id => @alice.id).count.should == 1
@ -264,33 +260,6 @@ describe AspectsController do
contacts.count.should == 1 contacts.count.should == 1
contacts.first.should == contact contacts.first.should == contact
end end
context "when the user has pending requests" do
before do
requestor = Factory.create(:user)
requestor_aspect = requestor.aspects.create(:name => "Meh")
requestor.send_contact_request_to(@alice.person, requestor_aspect)
requestor.reload
requestor_aspect.reload
@alice.reload
end
it "succeeds" do
get :manage
response.should be_success
end
it "assigns aspect to manage" do
get :manage
assigns(:aspect).should == :manage
end
it "assigns remote_requests" do
get :manage
assigns(:remote_requests).count.should == 1
end
it "generates a jasmine fixture" do
get :manage
save_fixture(html_for("body"), "aspects_manage")
end
end
end end
describe "#update" do describe "#update" do

View file

@ -9,84 +9,45 @@ describe ContactsController do
render_views render_views
before do before do
@user = alice @aspect = alice.aspects.first
@user2 = bob @contact = alice.contact_for(bob.person)
@aspect0 = @user.aspects.first sign_in :user, alice
@aspect1 = @user.aspects.create(:name => "another aspect") @controller.stub(:current_user).and_return(alice)
@aspect2 = @user2.aspects.first
@contact = @user.contact_for(@user2.person)
@user.getting_started = false
@user.save
sign_in :user, @user
@controller.stub(:current_user).and_return(@user)
request.env["HTTP_REFERER"] = 'http://' + request.host
end end
describe '#new' do describe '#new' do
it 'assigns a person' do it 'assigns a person' do
get :new, :person_id => @user2.person.id get :new, :person_id => bob.person.id
assigns[:person].should == @user2.person assigns[:person].should == bob.person
end end
it 'assigns aspects without person' do it 'assigns aspects without person' do
get :new, :person_id => @user2.person.id get :new, :person_id => bob.person.id
assigns[:aspects_without_person].should =~ @user.aspects assigns[:aspects_without_person].should =~ alice.aspects
end end
end end
describe '#create' do describe '#create' do
before do
context 'with an incoming request' do @person = eve.person
before do
@user3 = Factory.create(:user)
@user3.send_contact_request_to(@user.person, @user3.aspects.create(:name => "Walruses"))
end
it 'deletes the request' do
post :create,
:format => 'js',
:person_id => @user3.person.id,
:aspect_id => @aspect1.id
Request.where(:sender_id => @user3.person.id, :recipient_id => @user.person.id).first.should be_nil
end
it 'does not leave the contact pending' do
post :create,
:format => 'js',
:person_id => @user3.person.id,
:aspect_id => @aspect1.id
@user.contact_for(@user3.person).should_not be_pending
end
end end
context 'with a non-contact' do
before do
@person = Factory(:person)
end
it 'calls send_contact_request_to' do it 'calls share_in_aspect' do
@user.should_receive(:send_contact_request_to).with(@person, @aspect1) @controller.should_receive(:share_in_aspect).with(@aspect, @person)
post :create, post :create,
:format => 'js', :format => 'js',
:person_id => @person.id, :person_id => @person.id,
:aspect_id => @aspect1.id :aspect_id => @aspect.id
end end
it 'does not call add_contact_to_aspect' do it 'failure flashes error' do
@user.should_not_receive(:add_contact_to_aspect) @controller.should_receive(:share_in_aspect).and_return(nil)
post :create, post :create,
:format => 'js', :format => 'js',
:person_id => @person.id, :person_id => @person.id,
:aspect_id => @aspect1.id :aspect_id => @aspect.id
end flash[:error].should_not be_empty
it 'failure flashes error' do
@controller.should_receive(:request_to_aspect).and_return(nil)
post :create,
:format => 'js',
:person_id => @person.id,
:aspect_id => @aspect1.id
flash[:error].should_not be_empty
end
end end
end end
@ -104,18 +65,18 @@ describe ContactsController do
describe '#destroy' do describe '#destroy' do
it 'disconnects from the person' do it 'disconnects from the person' do
@user.should_receive(:disconnect).with(@contact) alice.should_receive(:disconnect).with(@contact)
delete :destroy, :id => @contact.id delete :destroy, :id => @contact.id
end end
it 'flases success if the contact is not destroyed' do it 'flases success if the contact is not destroyed' do
@user.stub!(:disconnect).and_return(true) alice.stub!(:disconnect).and_return(true)
delete :destroy, :id => @contact.id delete :destroy, :id => @contact.id
flash[:notice].should_not be_empty flash[:notice].should_not be_empty
end end
it 'flases failure if the contact is not destroyed' do it 'flases failure if the contact is not destroyed' do
@user.stub!(:disconnect).and_return(false) alice.stub!(:disconnect).and_return(false)
delete :destroy, :id => @contact.id delete :destroy, :id => @contact.id
flash[:error].should_not be_empty flash[:error].should_not be_empty
end end
@ -125,4 +86,15 @@ describe ContactsController do
response.should redirect_to(@contact.person) response.should redirect_to(@contact.person)
end end
end end
describe '#share_in_aspect' do
it 'calls share_with' do
aspect = alice.aspects.first
person = eve.person
@controller.current_user.should_receive(:share_with).with(person, aspect)
@controller.send(:share_in_aspect, aspect, person)
end
end
end end

View file

@ -89,21 +89,24 @@ describe InvitationsController do
invited.aspects.count.should == 2 invited.aspects.count.should == 2
end end
it 'adds a pending request' do it 'adds a contact' do
put :update, @accept_params lambda {
Request.where(:recipient_id => invited.person.id).count.should == 1 put :update, @accept_params
}.should change(@user.contacts, :count).by(1)
end end
end end
context 'failure' do context 'failure' do
before do before do
@fail_params = @accept_params @fail_params = @accept_params
@fail_params[:user][:username] = @user.username @fail_params[:user][:username] = @user.username
end end
it 'stays on the invitation accept form' do it 'stays on the invitation accept form' do
put :update, @fail_params put :update, @fail_params
response.location.include?(accept_user_invitation_path).should be_true response.location.include?(accept_user_invitation_path).should be_true
end end
it 'keeps the invitation token' do it 'keeps the invitation token' do
put :update, @fail_params put :update, @fail_params
response.location.include?("invitation_token=#{@invited_user.invitation_token}").should be_true response.location.include?("invitation_token=#{@invited_user.invitation_token}").should be_true

View file

@ -1,141 +0,0 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe RequestsController do
render_views
before do
@user = alice
@other_user = eve
@controller.stub!(:current_user).and_return(@user)
sign_in :user, @user
request.env["HTTP_REFERER"] = "http://test.host"
end
describe '#destroy' do
before do
@other_user.send_contact_request_to(@user.person, @other_user.aspects.first)
@friend_request = Request.where(:recipient_id => @user.person.id).first
end
describe 'when accepting a contact request' do
it "succeeds" do
xhr :delete, :destroy,
:accept => "true",
:aspect_id => @user.aspects.first.id.to_s,
:id => @friend_request.id.to_s
response.should redirect_to(requests_path)
end
it "marks the notification as read" do
notification = Notification.where(:recipient_id => @user.id, :target_id=> @friend_request.id).first
notification.unread = true
notification.save
xhr :delete, :destroy,
:accept => "true",
:aspect_id => @user.aspects.first.id.to_s,
:id => @friend_request.id.to_s
notification.reload.unread.should == false
end
end
describe 'when ignoring a contact request' do
it "succeeds" do
xhr :delete, :destroy,
:id => @friend_request.id.to_s
response.should be_success
end
it "removes the request object" do
lambda {
xhr :delete, :destroy,
:id => @friend_request.id.to_s
}.should change(Request, :count).by(-1)
end
it "marks the notification as read" do
notification = Notification.where(:recipient_id => @user.id, :target_id=> @friend_request.id).first
notification.unread = true
notification.save
xhr :delete, :destroy,
:id => @friend_request.id.to_s
notification.reload.unread.should == false
end
end
end
describe '#create' do
context 'valid new request' do
before do
@params = {:request => {
:to => @other_user.diaspora_handle,
:into => @user.aspects[0].id
}}
end
it 'creates a contact' do
@user.contact_for(@other_user).should be_nil
lambda {
post :create, @params
}.should change(Contact.unscoped,:count).by(1)
new_contact = @user.reload.contact_for(@other_user.person)
new_contact.should_not be_nil
new_contact.should be_pending
end
it 'does not persist a Request' do
lambda {
post :create, @params
}.should_not change(Request, :count)
end
end
it 'autoaccepts and when sending a request to someone who sent me a request' do
@other_user.send_contact_request_to(@user.person, @other_user.aspects[0])
post(:create, :request => {
:to => @other_user.diaspora_handle,
:into => @user.aspects[0].id}
)
Request.where(:recipient_id => @user.person.id).first.should be_nil
@user.contact_for(@other_user.person).should be_true
@user.aspects[0].contacts.where(:person_id => @other_user.person.id).first.should be_true
end
it "redirects when requesting to be contacts with yourself" do
post(:create, :request => {
:to => @user.diaspora_handle,
:into => @user.aspects[0].id
}
)
flash[:error].should_not be_blank
response.should redirect_to :back
end
it "flashes and redirects when requesting an invalid identity" do
post(:create, :request => {
:to => "not_a_@valid_email",
:into => @user.aspects[0].id
}
)
flash[:error].should_not be_blank
response.should redirect_to :back
end
it "accepts no port numbers" do
post(:create, :request => {
:to => "johndoe@email.com:3000",
:into => @user.aspects[0].id
}
)
flash[:error].should_not be_blank
response.should redirect_to :back
end
it "redirects when requesting an identity from an invalid server" do
post(:create, :request => {
:to => "johndoe@notadiasporaserver.com",
:into => @user.aspects[0].id
}
)
flash[:error].should_not be_blank
response.should redirect_to :back
end
end
end

View file

@ -3,15 +3,13 @@ module HelperMethods
connect_users(u1, u1.aspects.first, u2, u2.aspects.first) connect_users(u1, u1.aspects.first, u2, u2.aspects.first)
end end
def connect_users(user1, aspect1, user2, aspect2) def connect_users(user1, aspect1, user2, aspect2)
Contact.create!(:user => user1, user1.contacts.create!(:person => user2.person,
:person => user2.person, :aspects => [aspect1],
:aspects => [aspect1], :pending => false)
:pending => false)
Contact.create!(:user => user2, user2.contacts.create!(:person => user1.person,
:person => user1.person, :aspects => [aspect2],
:aspects => [aspect2], :pending => false)
:pending => false)
user1.reload user1.reload
user2.reload user2.reload
aspect1.reload aspect1.reload

View file

@ -358,19 +358,6 @@ describe 'a user receives a post' do
}.should change(StatusMessage, :count).by(-1) }.should change(StatusMessage, :count).by(-1)
end end
it "should activate the Person if I initiated a request to that url" do
@user1.send_contact_request_to(@user3.person, @aspect)
request = @user3.request_from(@user1.person)
fantasy_resque do
@user3.accept_and_respond(request.id, @aspect3.id)
end
@user1.reload
@aspect.reload
new_contact = @user1.contact_for(@user3.person)
@aspect.contacts.include?(new_contact).should be true
@user1.contacts.include?(new_contact).should be true
end
it 'should process retraction for a person' do it 'should process retraction for a person' do
retraction = Retraction.for(@user2) retraction = Retraction.for(@user2)
retraction_xml = retraction.to_diaspora_xml retraction_xml = retraction.to_diaspora_xml

View file

@ -8,6 +8,7 @@ describe Invitation do
let(:user) { alice } let(:user) { alice }
let(:aspect) { user.aspects.first } let(:aspect) { user.aspects.first }
let(:user2) { eve } let(:user2) { eve }
before do before do
user.invites = 20 user.invites = 20
user.save user.save
@ -73,50 +74,47 @@ describe Invitation do
describe '.find_existing_user' do describe '.find_existing_user' do
let(:inv) { Invitation.find_existing_user(@type, @identifier) } let(:inv) { Invitation.find_existing_user(@type, @identifier) }
before do
@users = []
8.times do
@users << Factory.create(:user)
end
@user_fb_id = 'abc123'
@user_fb = Factory.create(:user, :invitation_service => "facebook", :invitation_identifier => @user_fb_id)
end
context 'send a request to an existing' do context 'send a request to an existing' do
context 'active user' do context 'active user' do
it 'by email' do it 'by email' do
@identifier = @users[3].email @identifier = alice.email
@type = 'email' @type = 'email'
inv.should == @users[3] inv.should == alice
end end
it 'by service' do it 'by service' do
uid = '123324234' uid = '123324234'
@users[0].services << Services::Facebook.new(:uid => uid) alice.services << Services::Facebook.new(:uid => uid)
@users[0].save alice.save
@type = 'facebook' @type = 'facebook'
@identifier = uid @identifier = uid
inv.should == @users[0] inv.should == alice
end end
end end
context 'invitated user' do context 'invitated user' do
it 'by email' do it 'by email' do
@identifier = @users[3].email @identifier = alice.email
@type = 'email' @type = 'email'
@users[3].invitation_identifier = @identifier alice.invitation_identifier = @identifier
@users[3].invitation_service = @type alice.invitation_service = @type
@users[3].save alice.save
inv.should == @users[3] inv.should == alice
end end
it 'by service' do it 'by service' do
@identifier = @user_fb_id fb_id = 'abc123'
alice.invitation_service = 'facebook'
alice.invitation_identifier = fb_id
alice.save
@identifier = fb_id
@type = 'facebook' @type = 'facebook'
inv.should == @user_fb inv.should == alice
end end
end end
end end
@ -303,7 +301,7 @@ describe Invitation do
end end
end end
describe '#to_request!' do describe '#share_with!' do
before do before do
@new_user = Invitation.invite(:from => user, :service => 'email', :identifier => @email, :into => aspect) @new_user = Invitation.invite(:from => user, :service => 'email', :identifier => @email, :into => aspect)
acceptance_params = {:invitation_token => "abc", acceptance_params = {:invitation_token => "abc",
@ -317,38 +315,17 @@ describe Invitation do
@new_user.save @new_user.save
@invitation = @new_user.invitations_to_me.first @invitation = @new_user.invitations_to_me.first
end end
it 'destroys the invitation' do it 'destroys the invitation' do
lambda { lambda {
@invitation.to_request! @invitation.share_with!
}.should change(Invitation, :count).by(-1) }.should change(Invitation, :count).by(-1)
end end
it 'creates a request, and sends it to the new user' do
it 'creates a contact for the inviter' do
lambda { lambda {
@invitation.to_request! @invitation.share_with!
}.should change(Request, :count).by(1)
end
it 'creates a pending contact for the inviter' do
lambda {
@invitation.to_request!
}.should change(Contact.unscoped, :count).by(1) }.should change(Contact.unscoped, :count).by(1)
@invitation.sender.contact_for(@new_user.person).should be_pending
end
describe 'return values' do
before do
@request = @invitation.to_request!
end
it 'returns the sent request' do
@request.is_a?(Request).should be_true
end
it 'sets the receiving user' do
@request.recipient.should == @new_user.person
end
it 'sets the sending user' do
@request.sender.should == user.person
end
it 'sets the aspect' do
@request.aspect.should == aspect
end
end end
end end
end end

View file

@ -73,10 +73,9 @@ describe Request do
end end
describe '#receive' do describe '#receive' do
it 'calls receive_contact_request on user' do it 'creates a contact' do
request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect) request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
@user2.contacts.should_receive(:create).with(hash_including(:person_id => @user.person.id))
@user2.should_receive(:receive_contact_request).with(request)
request.receive(@user2, @user.person) request.receive(@user2, @user.person)
end end
end end

View file

@ -5,98 +5,97 @@
require 'spec_helper' require 'spec_helper'
describe Diaspora::UserModules::Connecting do describe Diaspora::UserModules::Connecting do
let(:user) { alice }
let(:aspect) { user.aspects.create(:name => 'heroes') } let(:aspect) { alice.aspects.first }
let(:aspect1) { user.aspects.create(:name => 'other') } let(:aspect1) { alice.aspects.create(:name => 'other') }
let(:person) { Factory.create(:person) } let(:person) { Factory.create(:person) }
let(:aspect2) { eve.aspects.create(:name => "aspect two") }
let(:person_one) { Factory.create :person } let(:person_one) { Factory.create :person }
let(:person_two) { Factory.create :person } let(:person_two) { Factory.create :person }
let(:person_three) { Factory.create :person } let(:person_three) { Factory.create :person }
let(:user2) { eve }
let(:aspect2) { user2.aspects.create(:name => "aspect two") }
describe '#send_contact_request_to' do describe '#send_contact_request_to' do
it 'should not be able to contact request an existing contact' do it 'should not be able to contact request an existing contact' do
user.activate_contact(user2.person, aspect1) alice.activate_contact(eve.person, aspect1)
proc { proc {
user.send_contact_request_to(user2.person, aspect1) alice.send_contact_request_to(eve.person, aspect1)
}.should raise_error(ActiveRecord::RecordInvalid) }.should raise_error(ActiveRecord::RecordInvalid)
end end
it 'should not be able to contact request no-one' do it 'should not be able to contact request no-one' do
proc { proc {
user.send_contact_request_to(nil, aspect) alice.send_contact_request_to(nil, aspect)
}.should raise_error(ActiveRecord::RecordInvalid) }.should raise_error(ActiveRecord::RecordInvalid)
end end
it 'creates a pending contact' do it 'creates a pending contact' do
proc { proc {
user.send_contact_request_to(user2.person, aspect1) alice.send_contact_request_to(eve.person, aspect1)
}.should change(Contact.unscoped, :count).by(1) }.should change(Contact.unscoped, :count).by(1)
user.contact_for(user2.person).pending.should == true alice.contact_for(eve.person).pending.should == true
user.contact_for(user2.person).should be_pending alice.contact_for(eve.person).should be_pending
end end
it 'persists no request for requester' do it 'persists no request for requester' do
proc { proc {
user.send_contact_request_to(user2.person, aspect1) alice.send_contact_request_to(eve.person, aspect1)
}.should_not change{Request.where(:recipient_id => user.person.id).count} }.should_not change{Request.where(:recipient_id => alice.person.id).count}
end end
it 'persists a request for the recipient' do it 'persists a request for the recipient' do
user.send_contact_request_to(user2.person, aspect1) alice.send_contact_request_to(eve.person, aspect1)
user2.request_from(user.person).should_not be_nil eve.request_from(alice.person).should_not be_nil
end end
end end
context 'contact requesting' do context 'contact requesting' do
describe '#receive_contact_request' do describe '#receive_contact_request' do
before do before do
@r = Request.diaspora_initialize(:to => user.person, :from => person) @r = Request.diaspora_initialize(:to => alice.person, :from => person)
end end
it 'adds a request to pending if it was not sent by user' do it 'adds a request to pending if it was not sent by user' do
user.receive_contact_request(@r) alice.receive_contact_request(@r)
Request.where(:recipient_id => user.person.id).all.should include @r Request.where(:recipient_id => alice.person.id).all.should include @r
end end
it 'creates no contact' do it 'creates no contact' do
lambda { lambda {
received_req = @r.receive(user, person_one) received_req = @r.receive(alice, person_one)
}.should_not change(Contact, :count) }.should_not change(Contact, :count)
end end
end end
describe '#receive_request_acceptance' do describe '#receive_request_acceptance' do
before do before do
@original_request = user.send_contact_request_to(user2.person, aspect) @original_request = alice.send_contact_request_to(eve.person, aspect)
@acceptance = @original_request.reverse_for(user2) @acceptance = @original_request.reverse_for(eve)
end end
it 'connects to the acceptor' do it 'connects to the acceptor' do
user.receive_contact_request(@acceptance) alice.receive_contact_request(@acceptance)
user.contact_for(user2.person).should_not be_nil alice.contact_for(eve.person).should_not be_nil
end end
it 'deletes the acceptance' do it 'deletes the acceptance' do
user.receive_contact_request(@acceptance) alice.receive_contact_request(@acceptance)
Request.where(:sender_id => user2.person.id, :recipient_id => user.person.id).should be_empty Request.where(:sender_id => eve.person.id, :recipient_id => alice.person.id).should be_empty
end end
end end
context 'received a contact request' do context 'received a contact request' do
let(:request_for_user) {Request.diaspora_initialize(:to => user.person, :from => person)} let(:request_for_user) {Request.diaspora_initialize(:to => alice.person, :from => person)}
let(:request2_for_user) {Request.diaspora_initialize(:to => user.person, :from => person_one)} let(:request2_for_user) {Request.diaspora_initialize(:to => alice.person, :from => person_one)}
let(:request_from_myself) {Request.diaspora_initialize(:to => user.person, :from => user.person)} let(:request_from_myself) {Request.diaspora_initialize(:to => alice.person, :from => alice.person)}
before do before do
Request.diaspora_initialize(:from => person, :to => user.person).save Request.diaspora_initialize(:from => person, :to => alice.person).save
Request.diaspora_initialize(:from => person_one, :to => user.person).save Request.diaspora_initialize(:from => person_one, :to => alice.person).save
@received_request = Request.where(:sender_id => person.id, :recipient_id => user.person.id).first @received_request = Request.where(:sender_id => person.id, :recipient_id => alice.person.id).first
@received_request2 = Request.where(:sender_id => person_one.id, :recipient_id => user.person.id).first @received_request2 = Request.where(:sender_id => person_one.id, :recipient_id => alice.person.id).first
end end
it "should delete an accepted contact request" do it "should delete an accepted contact request" do
proc { proc {
user.accept_contact_request(@received_request, aspect) alice.accept_contact_request(@received_request, aspect)
}.should change(Request, :count ).by(-1) }.should change(Request, :count ).by(-1)
end end
@ -104,19 +103,19 @@ describe Diaspora::UserModules::Connecting do
notification = Factory.create(:notification, :target => @received_request) notification = Factory.create(:notification, :target => @received_request)
Notification.where(:target_id=>@received_request.id).first.unread.should be_true Notification.where(:target_id=>@received_request.id).first.unread.should be_true
user.accept_contact_request(@received_request, aspect) alice.accept_contact_request(@received_request, aspect)
Notification.where(:target_id=>@received_request.id).first.unread.should be_false Notification.where(:target_id=>@received_request.id).first.unread.should be_false
end end
it 'should be able to ignore a pending contact request' do it 'should be able to ignore a pending contact request' do
proc { user.ignore_contact_request(@received_request.id) proc { alice.ignore_contact_request(@received_request.id)
}.should change(Request, :count ).by(-1) }.should change(Request, :count ).by(-1)
end end
it 'should ignore a contact request from yourself' do it 'should ignore a contact request from yourself' do
reversed_request = request_from_myself.reverse_for(user) reversed_request = request_from_myself.reverse_for(alice)
user.receive_contact_request(reversed_request) alice.receive_contact_request(reversed_request)
reversed_request.persisted?.should be false reversed_request.persisted?.should be false
end end
end end
@ -124,9 +123,9 @@ describe Diaspora::UserModules::Connecting do
describe 'multiple users accepting/rejecting the same person' do describe 'multiple users accepting/rejecting the same person' do
before do before do
@request1 = Request.diaspora_initialize(:to => user.person, :from => person_one) @request1 = Request.diaspora_initialize(:to => alice.person, :from => person_one)
@request2 = Request.diaspora_initialize(:to => user2.person, :from => person_one) @request2 = Request.diaspora_initialize(:to => eve.person, :from => person_one)
@request3 = Request.diaspora_initialize(:to => user2.person, :from => user.person) @request3 = Request.diaspora_initialize(:to => eve.person, :from => alice.person)
@req1_xml = @request1.to_diaspora_xml @req1_xml = @request1.to_diaspora_xml
@req2_xml = @request2.to_diaspora_xml @req2_xml = @request2.to_diaspora_xml
@ -139,94 +138,94 @@ describe Diaspora::UserModules::Connecting do
context 'request from one remote person to one local user' do context 'request from one remote person to one local user' do
before do before do
zord = Postzord::Receiver.new(user, :person => user.person) zord = Postzord::Receiver.new(alice, :person => alice.person)
@received_request = zord.parse_and_receive(@req3_xml) @received_request = zord.parse_and_receive(@req3_xml)
@received_request.reload @received_request.reload
end end
it 'should connect the user other user on the same pod' do it 'should connect the user other user on the same pod' do
proc { proc {
user2.accept_contact_request(@received_request, aspect2) eve.accept_contact_request(@received_request, aspect2)
}.should_not change(Person, :count) }.should_not change(Person, :count)
user2.contact_for(user.person).should_not be_nil eve.contact_for(alice.person).should_not be_nil
end end
it 'should not delete the ignored user on the same pod' do it 'should not delete the ignored user on the same pod' do
proc { proc {
user2.ignore_contact_request(@received_request.id) eve.ignore_contact_request(@received_request.id)
}.should_not change(Person, :count) }.should_not change(Person, :count)
user2.contact_for(user.person).should be_nil eve.contact_for(alice.person).should be_nil
end end
end end
context 'Two users receiving requests from one person' do context 'Two users receiving requests from one person' do
before do before do
zord1 = Postzord::Receiver.new(user, :person => person_one) zord1 = Postzord::Receiver.new(alice, :person => person_one)
zord2 = Postzord::Receiver.new(user, :person => person_one) zord2 = Postzord::Receiver.new(alice, :person => person_one)
@req_to_user = zord1.parse_and_receive(@req1_xml) @req_to_user = zord1.parse_and_receive(@req1_xml)
@req_to_user2 = zord2.parse_and_receive(@req2_xml) @req_to_eve = zord2.parse_and_receive(@req2_xml)
end end
describe '#accept_contact_request' do describe '#accept_contact_request' do
it 'should both users should connect the same person' do it 'should both users should connect the same person' do
user.accept_contact_request @req_to_user, aspect alice.accept_contact_request @req_to_user, aspect
user.contact_for(person_one).should_not be_nil alice.contact_for(person_one).should_not be_nil
user2.accept_contact_request @req_to_user2, aspect2 eve.accept_contact_request @req_to_eve, aspect2
user2.contact_for(person_one).should_not be_nil eve.contact_for(person_one).should_not be_nil
end end
it 'should keep the person around if one of the users rejects him' do it 'should keep the person around if one of the users rejects him' do
user.accept_contact_request @req_to_user, aspect alice.accept_contact_request @req_to_user, aspect
user.contact_for(person_one).should_not be_nil alice.contact_for(person_one).should_not be_nil
user2.ignore_contact_request @req_to_user2.id eve.ignore_contact_request @req_to_eve.id
user2.contact_for(person_one).should be_nil eve.contact_for(person_one).should be_nil
end end
end end
it 'should keep the person around if the users ignores them' do it 'should keep the person around if the users ignores them' do
user.ignore_contact_request Request.where(:recipient_id => user.person.id).first.id alice.ignore_contact_request Request.where(:recipient_id => alice.person.id).first.id
user.contact_for(person_one).should be_nil alice.contact_for(person_one).should be_nil
user2.ignore_contact_request Request.where(:recipient_id => user2.person.id).first.id eve.ignore_contact_request Request.where(:recipient_id => eve.person.id).first.id
user2.contact_for(person_one).should be_nil eve.contact_for(person_one).should be_nil
end end
end end
end end
describe 'a user accepting rejecting multiple people' do describe 'a user accepting & rejecting multiple people' do
before do before do
request = Request.diaspora_initialize(:to => user.person, :from => person_one) request = Request.diaspora_initialize(:to => alice.person, :from => person_one)
@received_request = request.receive(user, person_one) @received_request = request.receive(alice, person_one)
end end
describe '#accept_contact_request' do describe '#accept_contact_request' do
it "deletes the received request" do it "deletes the received request" do
lambda { lambda {
user.accept_contact_request(@received_request, aspect) alice.accept_contact_request(@received_request, aspect)
}.should change(Request, :count).by(-1) }.should change(Request, :count).by(-1)
end end
it "creates a new contact" do it "creates a new contact" do
lambda { lambda {
user.accept_contact_request(@received_request, aspect) alice.accept_contact_request(@received_request, aspect)
}.should change(Contact, :count).by(1) }.should change(Contact, :count).by(1)
user.contact_for(person_one).should_not be_nil alice.contact_for(person_one).should_not be_nil
end end
end end
describe '#ignore_contact_request' do describe '#ignore_contact_request' do
it "removes the request" do it "removes the request" do
lambda { lambda {
user.ignore_contact_request(@received_request.id) alice.ignore_contact_request(@received_request.id)
}.should change(Request, :count).by(-1) }.should change(Request, :count).by(-1)
end end
it "creates no new contact" do it "creates no new contact" do
lambda { lambda {
user.ignore_contact_request(@received_request) alice.ignore_contact_request(@received_request)
}.should_not change(Contact, :count) }.should_not change(Contact, :count)
end end
end end
@ -283,4 +282,37 @@ describe Diaspora::UserModules::Connecting do
end end
end end
end end
describe '#share_with' do
it 'finds or creates a contact' do
lambda {
alice.share_with(eve.person, alice.aspects.first)
}.should change(alice.contacts, :count).by(1)
end
it 'adds a contact to an aspect' do
contact = alice.contacts.create(:person => eve.person)
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
lambda {
alice.share_with(eve.person, alice.aspects.first)
}.should change(contact.aspects, :count).by(1)
end
it 'dispatches a request' do
contact = alice.contacts.new(:person => eve.person)
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
contact.should_receive(:dispatch_request)
alice.share_with(eve.person, alice.aspects.first)
end
it 'does not dispatch a request' do
contact = alice.contacts.create(:person => eve.person)
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
contact.should_not_receive(:dispatch_request)
alice.share_with(eve.person, alice.aspects.first)
end
end
end end

View file

@ -182,21 +182,6 @@ describe User do
end end
end end
describe "#request_from" do
let!(:user5) {Factory(:user)}
it 'should not have a pending request before connecting' do
request = alice.request_from(user5.person)
request.should be_nil
end
it 'should have a pending request after sending a request' do
alice.send_contact_request_to(user5.person, alice.aspects.first)
request = user5.request_from(alice.person)
request.should_not be_nil
end
end
describe '#posts_from' do describe '#posts_from' do
before do before do
@user3 = Factory(:user) @user3 = Factory(:user)