edited subscribers to include all contacts on public posts. added the ability to drop an aspect regardless of contacts contained. wip.

This commit is contained in:
danielgrippi 2011-04-05 18:53:10 -07:00
parent 68375fdb02
commit 847f4fd260
7 changed files with 40 additions and 20 deletions

View file

@ -113,7 +113,7 @@ class UsersController < ApplicationController
end
if @step == 3 && @requests.length == 0 && @friends.length == 0
if @step == 3 && @friends.length == 0
@user.update_attributes(:getting_started => false)
flash[:notice] = I18n.t('users.getting_started.could_not_find_anyone')
redirect_to root_path

View file

@ -9,4 +9,11 @@ class AspectMembership < ActiveRecord::Base
has_one :user, :through => :contact
has_one :person, :through => :contact
before_destroy do
unless self.contact.aspects.size > 1
self.user.disconnect(self.contact)
end
true
end
end

View file

@ -65,7 +65,11 @@ class Post < ActiveRecord::Base
end
def subscribers(user)
user.people_in_aspects(user.aspects_with_post(self.id))
if self.public?
user.contact_people
else
user.people_in_aspects(user.aspects_with_post(self.id))
end
end
def receive(user, person)

View file

@ -1,6 +1,6 @@
- if person.owner_id == current_user.id
= t('people.person.thats_you')
- elsif contact && !contact.pending
- elsif contact && contact.mutual
= t('people.person.already_connected')
- else
= link_to t('people.show.start_sharing'),

View file

@ -37,14 +37,5 @@ Feature: invitation acceptance
And I should see "Would you like to find your Facebook friends on Diaspora?"
When I follow "Skip"
Then I should see "People already on Diaspora"
And I press the first ".share_with.button"
And I press the first ".add.button" within "#facebox #aspects_list ul > li:first-child"
And I wait for the ajax to finish
When I go to the home page
Then I go to the manage aspects page
Then I should see 1 contact in "Family"
Then I should be on the aspects page

View file

@ -6,13 +6,26 @@ require 'spec_helper'
describe AspectMembership do
describe '#before_delete' do
it 'calls disconnect' do
pending
alice.should_receive(:disconnect).with(alice.contact_for(bob))
describe '#before_destroy' do
before do
@aspect = alice.aspects.create(:name => "two")
@contact = alice.contact_for(bob.person)
alice.aspects.create(:name => "two")
alice.aspects.first.destroy
@am = alice.aspects.first.aspect_memberships.first
@am.stub!(:user).and_return(alice)
end
it 'calls disconnect if its the last aspect for the contact' do
alice.should_receive(:disconnect).with(@contact)
@am.destroy
end
it 'does not call disconnect if its not the last aspect for the contact' do
alice.should_not_receive(:disconnect)
alice.add_contact_to_aspect(@contact, @aspect)
@am.destroy
end
end

View file

@ -39,11 +39,16 @@ describe Post do
describe '#subscribers' do
it 'returns the people contained in the aspects the post appears in' do
post = @user.post :status_message, :text => "hello", :to => @aspect.id
post.subscribers(@user).should == []
end
it 'returns all a users contacts if the post is public' do
post = @user.post :status_message, :text => "hello", :to => @aspect.id, :public => true
post.subscribers(@user).to_set.should == @user.contact_people.to_set
end
end
describe '#receive' do