fixed disconnecting logic. specs&cucumber green

This commit is contained in:
danielgrippi 2011-04-11 15:10:51 -07:00
parent 1b8257e960
commit 352d1c6abf
8 changed files with 57 additions and 39 deletions

View file

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

View file

@ -34,6 +34,11 @@
:aspects_without_person => @all_aspects.reject{ |aspect| @aspects_with_person.include?(aspect)}}
%br
%hr{:style=>"width:300px;"}
- if user_signed_in? && contact.sharing?
%br
%h4
#{person.name} is sharing with you.
-if user_signed_in? && ((contact.persisted? && contact.mutual?) || person == current_user.person || @incoming_request)
%ul#profile_information

View file

@ -52,7 +52,7 @@
%span.diaspora_handle
= @person.diaspora_handle
.description
- if !@person.profile.tag_string.blank? && user_signed_in? && ((@contact.persisted? && !@contact.pending?) || @person == current_user.person || @incoming_request)
- if !@person.profile.tag_string.blank? && user_signed_in? && (@contact.persisted? || @person == current_user.person || @incoming_request)
= @person.profile.format_tags(@person.profile.tag_string)
- if user_signed_in? && @person == current_user.person
%span.hover_edit

View file

@ -96,6 +96,8 @@ Feature: sending and receiving requests
Then I should see "Mention"
Then I should not see "Message"
Then I should not see "is sharing with you."
Scenario: should see start sharing and not see mention if on a follower's page
When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page
@ -105,6 +107,8 @@ Feature: sending and receiving requests
Then I should not see "Mention"
Then I should not see "Message"
Then I should see "is sharing with you."
Scenario: should see start sharing & mention & message on mutual contacts
When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page
@ -119,3 +123,5 @@ Feature: sending and receiving requests
Then I should see "edit aspect membership"
Then I should see "Mention"
Then I should see "Message"
Then I should see "is sharing with you."

View file

@ -5,15 +5,16 @@ Feature: disconnecting users
I want to be able to disconnect from others
Background:
Given a user with email "bob@bob.bob"
Given a user with email "bob@bob.bob"
And a user with email "alice@alice.alice"
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
When I sign in as "bob@bob.bob"
And I am on the manage aspects page
Then I should see 1 contact in "Besties"
Scenario Outline: remove contact from the contact show page
When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
And I press the first ".share_with.button"
And I wait for the ajax to finish
And I add the person to my first aspect
Scenario Outline: remove non-mutual contact from the contact show page
When I am on "alice@alice.alice"'s page
And I follow "edit aspect membership"
And I preemptively <accept> the alert
@ -23,12 +24,18 @@ Feature: disconnecting users
And I am on the manage aspects page
Then I should see <contacts> in "Besties"
Examples:
| accept | contacts |
| confirm | no contacts |
| reject | 1 contact |
Then I go to the destroy user session page
When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page
Scenario Outline: remove the contact from the last aspect on the contact show page
Then I should <see> "is sharing with you."
Examples:
| accept | contacts | see |
| confirm | no contacts | not see |
| reject | 1 contact | see |
Scenario Outline: remove a non-mutual contact from the last aspect on the contact show page
When I am on "alice@alice.alice"'s page
And I follow "edit aspect membership"
And I press the first ".added" within "#facebox #aspects_list ul > li:first-child"
@ -36,8 +43,14 @@ Feature: disconnecting users
And I wait for the ajax to finish
And I am on the manage aspects page
Then I should see no contacts in "Besties"
Then I go to the destroy user session page
When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page
Scenario: remove contact from the aspect edit page
Then I should not see "is sharing with you."
Scenario: remove a non-mutual contact from the aspect edit page
When I go to the home page
And I press the first ".contact-count" within "#aspect_listings"
@ -49,3 +62,8 @@ Feature: disconnecting users
And I am on the manage aspects page
Then I should see no contacts in "Besties"
Then I go to the destroy user session page
When I sign in as "alice@alice.alice"
And I am on "bob@bob.bob"'s page
Then I should not see "is sharing with you."

View file

@ -31,7 +31,6 @@ module Diaspora
contact.destroy
else
contact.update_attributes(:mutual => false)
AspectMembership.where(:contact_id => contact.id).delete_all
end
posts.each do |p|
@ -47,6 +46,8 @@ module Diaspora
retraction = Retraction.for(self)
retraction.subscribers = [person]#HAX
Postzord::Dispatch.new(self, retraction).post
AspectMembership.where(:contact_id => bad_contact.id).delete_all
remove_contact(bad_contact)
end

View file

@ -355,18 +355,6 @@ describe 'a user receives a post' do
zord.parse_and_receive(xml)
}.should change(StatusMessage, :count).by(-1)
end
it 'should process retraction for a person' do
retraction = Retraction.for(bob)
retraction_xml = retraction.to_diaspora_xml
lambda {
zord = Postzord::Receiver.new(alice, :person => bob.person)
zord.parse_and_receive(retraction_xml)
}.should change {
@aspect.contacts(true).size }.by(-1)
end
end
it 'should marshal a profile for a person' do

View file

@ -32,16 +32,6 @@ describe Diaspora::UserModules::Connecting do
bob.remove_contact(bob.contact_for(alice.person))
bob.contacts(true).find_by_person_id(alice.person.id).mutual.should be_false
end
it 'should remove the contact from all aspects they are in' do
contact = alice.contact_for(bob.person)
new_aspect = alice.aspects.create(:name => 'new')
alice.add_contact_to_aspect(contact, new_aspect)
lambda {
alice.remove_contact(contact)
}.should change(contact.aspects(true), :count).from(2).to(0)
end
end
describe '#disconnected_by' do
@ -66,6 +56,16 @@ describe Diaspora::UserModules::Connecting do
bob.disconnect bob.contact_for(eve.person)
end
it 'should remove the contact from all aspects they are in' do
contact = alice.contact_for(bob.person)
new_aspect = alice.aspects.create(:name => 'new')
alice.add_contact_to_aspect(contact, new_aspect)
lambda {
alice.disconnect(contact)
}.should change(contact.aspects(true), :count).from(2).to(0)
end
end
end