diff --git a/app/models/aspect_membership.rb b/app/models/aspect_membership.rb index f02ce4a0f..163dc6182 100644 --- a/app/models/aspect_membership.rb +++ b/app/models/aspect_membership.rb @@ -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 diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml index d05849730..f9e3fd441 100644 --- a/app/views/people/_profile_sidebar.html.haml +++ b/app/views/people/_profile_sidebar.html.haml @@ -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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index ffd2dd290..c4c75ac3f 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -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 diff --git a/features/connects_users.feature b/features/connects_users.feature index 8daab72ee..de1cfad1d 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -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." diff --git a/features/disconnects_users.feature b/features/disconnects_users.feature index dd3414ade..a8fb4e074 100644 --- a/features/disconnects_users.feature +++ b/features/disconnects_users.feature @@ -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 the alert @@ -23,12 +24,18 @@ Feature: disconnecting users And I am on the manage aspects page Then I should see 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 "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." diff --git a/lib/diaspora/user/connecting.rb b/lib/diaspora/user/connecting.rb index b3830806f..250291b24 100644 --- a/lib/diaspora/user/connecting.rb +++ b/lib/diaspora/user/connecting.rb @@ -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 diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index c218b4a60..47bc6cfdb 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -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 diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 7c687224c..4ff3d86a4 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -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