From aa9966ea26c042aa9302c57bd7bc5046897ee72c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 12 Nov 2010 17:42:49 -0800 Subject: [PATCH] removed the word friend everywhere minus translation files --- app/controllers/application_controller.rb | 7 +- app/controllers/aspects_controller.rb | 18 +-- app/controllers/dev_utilities_controller.rb | 7 +- app/controllers/invitations_controller.rb | 4 +- app/controllers/people_controller.rb | 2 +- app/controllers/publics_controller.rb | 2 +- app/controllers/requests_controller.rb | 8 +- app/helpers/people_helper.rb | 2 +- app/models/invitation.rb | 6 +- app/models/user.rb | 28 ++-- ...message.haml => _no_contacts_message.haml} | 6 +- app/views/aspects/_no_posts_message.haml | 2 +- app/views/aspects/index.html.haml | 6 +- app/views/aspects/index.mobile.haml | 2 +- app/views/aspects/manage.html.haml | 2 +- app/views/aspects/show.html.haml | 6 +- app/views/people/_person.html.haml | 2 +- app/views/people/show.html.haml | 2 +- app/views/photos/_index.html.haml | 4 - .../requests/_manage_aspect_contacts.haml | 4 +- .../requests/_new_request_to_person.haml | 2 +- ...ect_friends.haml => _aspect_contacts.haml} | 10 +- app/views/shared/_contact_list.html.haml | 4 +- app/views/shared/_invitations.haml | 2 +- app/views/users/edit.html.haml | 2 +- .../users/getting_started/_step_2.html.haml | 8 +- config/routes.rb | 2 +- lib/diaspora/exporter.rb | 12 +- lib/diaspora/user.rb | 4 +- lib/diaspora/user/connecting.rb | 140 +++++++++++++++++ lib/diaspora/user/friending.rb | 143 ------------------ lib/diaspora/user/querying.rb | 10 +- lib/diaspora/user/receiving.rb | 10 +- public/javascripts/aspect-edit.js | 8 +- public/javascripts/publisher.js | 6 +- public/stylesheets/sass/application.sass | 4 +- spec/controllers/aspects_controller_spec.rb | 20 +-- spec/controllers/comments_controller_spec.rb | 2 +- spec/controllers/people_controller_spec.rb | 8 +- spec/controllers/photos_controller_spec.rb | 2 +- spec/controllers/publics_controller_spec.rb | 4 +- spec/controllers/requests_controller_spec.rb | 2 +- spec/fixtures/users.yaml | 20 +-- spec/helper_methods.rb | 2 +- spec/javascripts/aspect-edit-spec.js | 4 +- spec/lib/diaspora/exporter_spec.rb | 4 +- spec/lib/diaspora/parser_spec.rb | 6 +- spec/misc_spec.rb | 10 +- spec/models/aspect_spec.rb | 52 +++---- spec/models/comment_spec.rb | 6 +- spec/models/invitation_spec.rb | 4 +- spec/models/person_spec.rb | 76 +++++----- spec/models/request_spec.rb | 4 +- spec/models/retraction_spec.rb | 2 +- spec/models/user/attack_vectors_spec.rb | 22 +-- .../{friending_spec.rb => connecting_spec.rb} | 121 ++++++++------- spec/models/user/invite_spec.rb | 10 +- spec/models/user/posting_spec.rb | 2 +- spec/models/user/querying_spec.rb | 18 +-- spec/models/user/receive_spec.rb | 14 +- spec/models/user_spec.rb | 18 +-- 61 files changed, 455 insertions(+), 465 deletions(-) rename app/views/aspects/{_no_friends_message.haml => _no_contacts_message.haml} (68%) rename app/views/shared/{_aspect_friends.haml => _aspect_contacts.haml} (63%) create mode 100644 lib/diaspora/user/connecting.rb delete mode 100644 lib/diaspora/user/friending.rb rename spec/models/user/{friending_spec.rb => connecting_spec.rb} (63%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3d931e4a2..ae970dd67 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,13 +6,12 @@ class ApplicationController < ActionController::Base has_mobile_fu protect_from_forgery :except => :receive - - before_filter :set_friends_and_status, :except => [:create, :update] + before_filter :set_contacts_and_status, :except => [:create, :update] before_filter :count_requests before_filter :set_invites before_filter :set_locale - def set_friends_and_status + def set_contacts_and_status if current_user if params[:aspect] == nil || params[:aspect] == 'all' @aspect = :all @@ -22,7 +21,7 @@ class ApplicationController < ActionController::Base @aspects = current_user.aspects @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} - @friends = current_user.person_objects + @contacts = current_user.contacts end end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index b2c3cddcb..46d7690c9 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -50,8 +50,8 @@ class AspectsController < ApplicationController unless @aspect render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else - @friends = @aspect.person_objects - @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' + @contacts = @aspect.contacts + @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' respond_with @aspect end end @@ -69,21 +69,21 @@ class AspectsController < ApplicationController respond_with @aspect end - def move_friend - unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to]) - flash[:error] = I18n.t 'aspects.move_friend.error',:inspect => params.inspect + def move_contact + unless current_user.move_contact( :person_id => params[:person_id], :from => params[:from], :to => params[:to][:to]) + flash[:error] = I18n.t 'aspects.move_contact.error',:inspect => params.inspect end if aspect = current_user.aspect_by_id(params[:to][:to]) - flash[:notice] = I18n.t 'aspects.move_friend.success' + flash[:notice] = I18n.t 'aspects.move_contact.success' render :nothing => true else - flash[:notice] = I18n.t 'aspects.move_friend.failure' + flash[:notice] = I18n.t 'aspects.move_contact.failure' render aspects_manage_path end end def add_to_aspect - if current_user.add_person_to_aspect( params[:friend_id], params[:aspect_id]) + if current_user.add_person_to_aspect( params[:person_id], params[:aspect_id]) flash[:notice] = I18n.t 'aspects.add_to_aspect.success' else flash[:error] = I18n.t 'aspects.add_to_aspect.failure' @@ -97,7 +97,7 @@ class AspectsController < ApplicationController end def remove_from_aspect - if current_user.delete_person_from_aspect( params[:friend_id], params[:aspect_id]) + if current_user.delete_person_from_aspect( params[:person_id], params[:aspect_id]) flash[:notice] = I18n.t 'aspects.remove_from_aspect.success' else flash[:error] = I18n.t 'aspects.remove_from_aspect.failure' diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index c0f368833..8eb7b788c 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -1,6 +1,7 @@ # 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/em-webfinger') class DevUtilitiesController < ApplicationController before_filter :authenticate_user!, :except => [:set_backer_number, :log] @@ -20,13 +21,13 @@ class DevUtilitiesController < ApplicationController webfinger.on_person { |person| puts person.inspect if person.respond_to? :diaspora_handle - rel_hash = {:friend => person} + rel_hash = {:person => person} logger.info "Zombiefriending #{backer['given_name']} #{backer['family_name']}" - logger.info "Calling send_friend_request with #{rel_hash[:friend]} and #{current_user.aspects.first}" + logger.info "Calling send_contact_request with #{rel_hash[:person]} and #{current_user.aspects.first}" begin - current_user.send_friend_request_to(rel_hash[:friend], current_user.aspects.first) + current_user.send_contact_request_to(rel_hash[:person], current_user.aspects.first) rescue Exception => e logger.info e.inspect puts e.inspect diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 7ee7e8f92..2059368b8 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -19,8 +19,8 @@ class InvitationsController < Devise::InvitationsController flash[:error] = I18n.t 'invitations.create.no_more' elsif e.message == "You already invited this person" flash[:error] = I18n.t 'invitations.create.already_sent' - elsif e.message == "You are already friends with this person" - flash[:error] = I18n.t 'invitations.create.already_friends' + elsif e.message == "You are already connected to this person" + flash[:error] = I18n.t 'invitations.create.already_contacts' else raise e end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index bcea6fb76..6f2634be0 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -41,7 +41,7 @@ class PeopleController < ApplicationController end def destroy - current_user.unfriend(current_user.visible_person_by_id(params[:id])) + current_user.disconnect(current_user.visible_person_by_id(params[:id])) respond_with :location => root_url end diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index f4d567317..a4566b44d 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -6,7 +6,7 @@ class PublicsController < ApplicationController require File.join(Rails.root, '/lib/diaspora/parser') include Diaspora::Parser - skip_before_filter :set_friends_and_status, :except => [:create, :update] + skip_before_filter :set_contacts_and_status, :except => [:create, :update] skip_before_filter :count_requests skip_before_filter :set_invites skip_before_filter :set_locale diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index d2e3a8175..271211557 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -13,7 +13,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] if params[:aspect_id] - @friend = current_user.accept_and_respond( params[:id], params[:aspect_id]) + @contact = current_user.accept_and_respond( params[:id], params[:aspect_id]) flash[:notice] = I18n.t 'requests.destroy.success' respond_with :location => current_user.aspect_by_id(params[:aspect_id]) else @@ -21,7 +21,7 @@ class RequestsController < ApplicationController respond_with :location => requests_url end else - current_user.ignore_friend_request params[:id] + current_user.ignore_contact_request params[:id] flash[:notice] = I18n.t 'requests.destroy.ignore' respond_with :location => requests_url end @@ -40,12 +40,12 @@ class RequestsController < ApplicationController finger.on_person{ |person| if person.class == Person - rel_hash = {:friend => person} + rel_hash = {:person => person} Rails.logger.debug("Sending request: #{rel_hash}") begin - @request = current_user.send_friend_request_to(rel_hash[:friend], aspect) + @request = current_user.send_contact_request_to(rel_hash[:person], aspect) rescue Exception => e Rails.logger.debug("error: #{e.message}") flash[:error] = e.message diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index f9a84da22..485fdc1d6 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -14,7 +14,7 @@ module PeopleHelper def action_link(person, is_contact) if is_contact - link_to t('people.profile_sidebar.remove_friend'), person, :confirm => t('are_you_sure'), :method => :delete + link_to t('people.profile_sidebar.remove_contact'), person, :confirm => t('are_you_sure'), :method => :delete elsif person == current_user.person link_to t('people.profile_sidebar.edit_my_profile'), edit_person_path(person) end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 2cd29fa22..7ee8705c7 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -16,9 +16,9 @@ class Invitation existing_user = User.find_by_email(opts[:email]) if existing_user if opts[:from].contact_for(opts[:from].person) - raise "You are already friends with this person" + raise "You are already connceted to this person" elsif not existing_user.invited? - opts[:from].send_friend_request_to(existing_user.person, opts[:into]) + opts[:from].send_contact_request_to(existing_user.person, opts[:into]) return elsif Invitation.first(:from_id => opts[:from].id, :to_id => existing_user.id) raise "You already invited this person" @@ -54,7 +54,7 @@ class Invitation end def to_request! - request = from.send_friend_request_to(to.person, into) + request = from.send_contact_request_to(to.person, into) destroy if request request end diff --git a/app/models/user.rb b/app/models/user.rb index 642d1366c..e657b48d5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -46,7 +46,7 @@ class User many :invitations_from_me, :class => Invitation, :foreign_key => :from_id many :invitations_to_me, :class => Invitation, :foreign_key => :to_id - many :friends, :class_name => 'Contact', :foreign_key => :user_id + many :contacts, :class_name => 'Contact', :foreign_key => :user_id many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go many :pending_requests, :in => :pending_request_ids, :class_name => 'Request' many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post' @@ -56,7 +56,7 @@ class User #after_create :seed_aspects - before_destroy :unfriend_everyone, :remove_person + before_destroy :disconnect_everyone, :remove_person before_save do person.save if person end @@ -97,13 +97,13 @@ class User end end - def move_friend(opts = {}) + def move_contact(opts = {}) return true if opts[:to] == opts[:from] - if opts[:friend_id] && opts[:to] && opts[:from] + if opts[:person_id] && opts[:to] && opts[:from] from_aspect = self.aspects.first(:_id => opts[:from]) - posts_to_move = from_aspect.posts.find_all_by_person_id(opts[:friend_id]) - if add_person_to_aspect(opts[:friend_id], opts[:to], :posts => posts_to_move) - delete_person_from_aspect(opts[:friend_id], opts[:from], :posts => posts_to_move) + posts_to_move = from_aspect.posts.find_all_by_person_id(opts[:person_id]) + if add_person_to_aspect(opts[:person_id], opts[:to], :posts => posts_to_move) + delete_person_from_aspect(opts[:person_id], opts[:from], :posts => posts_to_move) return true end end @@ -113,7 +113,7 @@ class User def add_person_to_aspect(person_id, aspect_id, opts = {}) contact = contact_for(Person.find(person_id)) raise "Can not add person to an aspect you do not own" unless aspect = self.aspects.find_by_id(aspect_id) - raise "Can not add person you are not friends with" unless contact + raise "Can not add person you are not connected to" unless contact raise 'Can not add person who is already in the aspect' if aspect.people.include?(contact) contact.aspects << aspect opts[:posts] ||= self.raw_visible_posts.all(:person_id => person_id) @@ -388,8 +388,8 @@ class User { :user => { :posts => self.raw_visible_posts.each { |post| post.as_json }, - :friends => self.friends.each { |friend| friend.as_json }, - :aspects => self.aspects.each { |aspect| aspect.as_json }, + :contacts => self.contacts.each { |contact| contact.as_json }, + :aspects => self.aspects.each { |aspect| aspect.as_json }, :pending_requests => self.pending_requests.each { |request| request.as_json }, } } @@ -411,12 +411,12 @@ class User self.person.destroy end - def unfriend_everyone - friends.each { |contact| + def disconnect_everyone + contacts.each { |contact| if contact.person.owner? - contact.person.owner.unfriended_by self.person + contact.person.owner.disconnected_by self.person else - self.unfriend contact + self.disconnect contact end } end diff --git a/app/views/aspects/_no_friends_message.haml b/app/views/aspects/_no_contacts_message.haml similarity index 68% rename from app/views/aspects/_no_friends_message.haml rename to app/views/aspects/_no_contacts_message.haml index 51babc7fe..dfb7506cf 100644 --- a/app/views/aspects/_no_friends_message.haml +++ b/app/views/aspects/_no_contacts_message.haml @@ -2,13 +2,13 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -#no_friends.floating.empty_message{:style => ("display:none" unless friend_count == 0)} +#no_contacts.floating.empty_message{:style => ("display:none" unless contact_count == 0)} - if aspect == :all %h3=t('.nobody') - %h4= link_to t('.add_friend'), aspects_manage_path + %h4= link_to t('.add_contact'), aspects_manage_path %h4= link_to t('.invite'), "#invite_user_pane", :class => "invite_user_button", :class => "invite_user_button", :title => t('.invite') - else %h3=t('.nobody_in_aspect', :aspect_name => aspect.name) - %h4= link_to t('.add_friend_to', :aspect_name => aspect.name), "#add_request_pane", :class => "add_request_button" + %h4= link_to t('.add_contact_to', :aspect_name => aspect.name), "#add_request_pane", :class => "add_request_button" %h4= link_to t('.invite', :aspect_name => aspect.name), "#invite_user_pane", :class => "invite_user_button", :class => "invite_user_button", :title => t('.invite') diff --git a/app/views/aspects/_no_posts_message.haml b/app/views/aspects/_no_posts_message.haml index b6334a18e..55627ccd7 100644 --- a/app/views/aspects/_no_posts_message.haml +++ b/app/views/aspects/_no_posts_message.haml @@ -2,7 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -#no_posts.floating.empty_message{:style => ("display:none" unless post_count == 0 && friend_count > 0)} +#no_posts.floating.empty_message{:style => ("display:none" unless post_count == 0 && contact_count > 0)} .null_arrow ⇧ %h3=t('.start_talking') diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index a05a5d14b..53b5a44e5 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -3,12 +3,12 @@ -# the COPYRIGHT file. .span-4.append-1.last - = render 'shared/aspect_friends', :people => @friends, :aspect => @aspect + = render 'shared/aspect_contacts', :people => @contacts, :aspect => @aspect .span-15.last - = render 'aspects/no_friends_message', :aspect => @aspect, :friend_count => @friends.count + = render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count = render 'shared/publisher', :aspect => @aspect - = render 'aspects/no_posts_message', :post_count => @posts.count, :friend_count => @friends.count + = render 'aspects/no_posts_message', :post_count => @posts.count, :contact_cont => @contacts.count = render 'shared/stream', :posts => @posts diff --git a/app/views/aspects/index.mobile.haml b/app/views/aspects/index.mobile.haml index 15b710e51..a9c155a04 100644 --- a/app/views/aspects/index.mobile.haml +++ b/app/views/aspects/index.mobile.haml @@ -10,4 +10,4 @@ %li{:class => 'ui-btn-active'} = link_to 'posts', '#' %li - =link_to 'friends', '#' + =link_to 'contacts', '#' diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index 762ef84c0..cef6d3a2f 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -41,7 +41,7 @@ %span.tip click to edit %ul.tools - %li= link_to t('.add_a_new_friend'), "#manage_aspect_contacts_pane_#{aspect.id}", :class => 'manage_aspect_contacts_button' + %li= link_to t('.add_a_new_contact'), "#manage_aspect_contacts_pane_#{aspect.id}", :class => 'manage_aspect_contacts_button' %li!= remove_link(aspect) %ul.dropzone{:data=>{:aspect_id=>aspect.id}} diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index a05a5d14b..ef8173ebc 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -3,12 +3,12 @@ -# the COPYRIGHT file. .span-4.append-1.last - = render 'shared/aspect_friends', :people => @friends, :aspect => @aspect + = render 'shared/aspect_contacts', :people => @contacts, :aspect => @aspect .span-15.last - = render 'aspects/no_friends_message', :aspect => @aspect, :friend_count => @friends.count + = render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count = render 'shared/publisher', :aspect => @aspect - = render 'aspects/no_posts_message', :post_count => @posts.count, :friend_count => @friends.count + = render 'aspects/no_posts_message', :post_count => @posts.count, :contact_count=> @contacts.count = render 'shared/stream', :posts => @posts diff --git a/app/views/people/_person.html.haml b/app/views/people/_person.html.haml index 1c737d7dc..0a441452d 100644 --- a/app/views/people/_person.html.haml +++ b/app/views/people/_person.html.haml @@ -14,7 +14,7 @@ - if person.id == current_user.person.id = t('.thats_you') - elsif current_user.person_objects.include?(person) - = t('.already_friends') + = t('.already_connected') - elsif current_user.pending_requests.find_by_person_id(person.id) = link_to =t('.pending_request'), aspects_manage_path - else diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index f88e45c08..ffdc11362 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -23,7 +23,7 @@ - else .floating %h3 - = t('.not_friends', :name => @person.real_name) + = t('.not_connected', :name => @person.real_name) - unless @pending_request %h3 diff --git a/app/views/photos/_index.html.haml b/app/views/photos/_index.html.haml index 7f38bcd2b..3660266fa 100644 --- a/app/views/photos/_index.html.haml +++ b/app/views/photos/_index.html.haml @@ -17,7 +17,3 @@ .image_thumb = link_to (image_tag photo.url(:thumb_medium)), photo_path(photo) -/.span-24.last -/ #add_photo_pane -/ = render "photos/new_photo", :aspect_id => :all - diff --git a/app/views/requests/_manage_aspect_contacts.haml b/app/views/requests/_manage_aspect_contacts.haml index 498398471..c64e3b18b 100644 --- a/app/views/requests/_manage_aspect_contacts.haml +++ b/app/views/requests/_manage_aspect_contacts.haml @@ -10,7 +10,7 @@ .span-6.append-1.last %h3 Existing contacts - = render 'shared/contact_list', :aspect => aspect, :contacts => current_user.friends, :manage => defined?(manage) + = render 'shared/contact_list', :aspect => aspect, :contacts => @contacts, :manage => defined?(manage) .span-7.last %h3 Add a new contact @@ -20,7 +20,7 @@ %i= t '.your_diaspora_username_is', :diaspora_handle => current_user.diaspora_handle %p - = label_tag :destination_handle, t('.friends_username'), :for => "request_d_handle_to_#{aspect.id}" + = label_tag :destination_handle, t('.contacts_username'), :for => "request_d_handle_to_#{aspect.id}" = text_field_tag :destination_handle,'', :id => "request_d_handle_to_#{aspect.id}" = hidden_field_tag :aspect_id, aspect.id diff --git a/app/views/requests/_new_request_to_person.haml b/app/views/requests/_new_request_to_person.haml index cc4e8d698..564d4e4f7 100644 --- a/app/views/requests/_new_request_to_person.haml +++ b/app/views/requests/_new_request_to_person.haml @@ -5,4 +5,4 @@ = form_tag(requests_path) do = select_tag(:aspect_id, options_from_collection_for_select(aspects, "id", "name")) = hidden_field_tag :destination_handle, person.diaspora_handle - = submit_tag t('people.person.add_friend') + = submit_tag t('people.person.add_connection') diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_contacts.haml similarity index 63% rename from app/views/shared/_aspect_friends.haml rename to app/views/shared/_aspect_contacts.haml index 4fbb289e0..21423ee47 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_contacts.haml @@ -6,14 +6,14 @@ #left_pane %h2= aspect == :all ? t('.everyone') : aspect - .friend_pictures + .contact_pictures = owner_image_link - - for friend in people - = person_image_link(friend) + - for contact in people + = person_image_link(contact) -unless (aspect == :all) - = link_to (image_tag('add_friend_button.png', :title => "manage #{@aspect}")), "#manage_aspect_contacts_pane", :class => 'manage_aspect_contacts_button' + = link_to (image_tag('add_contact_button.png', :title => "manage #{@aspect}")), "#manage_aspect_contacts_pane", :class => 'manage_aspect_contacts_button' .fancybox_content #manage_aspect_contacts_pane @@ -21,7 +21,7 @@ -else .clear %br - = link_to t('.add_friends'), aspects_manage_path + = link_to t('.add_connections'), aspects_manage_path %br %br diff --git a/app/views/shared/_contact_list.html.haml b/app/views/shared/_contact_list.html.haml index 8e26cb6b9..a2b1ffc2e 100644 --- a/app/views/shared/_contact_list.html.haml +++ b/app/views/shared/_contact_list.html.haml @@ -36,7 +36,7 @@ = contact.person.real_name .right = hidden_field_tag :aspect_id, aspect.id - = hidden_field_tag :friend_id, contact.person.id + = hidden_field_tag :contact_id, contact.person.id - if defined?(manage) && manage = hidden_field_tag :manage, true = submit_tag '+', :class => 'add', :title => "Add #{contact.person.real_name} to #{aspect}" @@ -48,7 +48,7 @@ = contact.person.real_name .right = hidden_field_tag :aspect_id, aspect.id - = hidden_field_tag :friend_id, contact.person.id + = hidden_field_tag :contact_id, contact.person.id - if defined?(manage) && manage = hidden_field_tag :manage, true = submit_tag 'x', :class => 'remove', :title => "Remove #{contact.person.real_name} from #{aspect}" diff --git a/app/views/shared/_invitations.haml b/app/views/shared/_invitations.haml index 8ef2ba877..98be2bda4 100644 --- a/app/views/shared/_invitations.haml +++ b/app/views/shared/_invitations.haml @@ -1,6 +1,6 @@ %h4 = t('.invites') -= link_to t('.invite_a_friend'), "#invite_user_pane", :class => "invite_user_button", :title => "Invite a friend" += link_to t('.invite_a_contact'), "#invite_user_pane", :class => "invite_user_button", :title => "Invite a contact" = t('.invitations_left', :count => invites) %br .yo{ :style => "display:none;"} diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 887e51edc..57984a55b 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -24,7 +24,7 @@ %h2 = t('account') - = link_to t('.invite_friends'), new_user_invitation_path(current_user) + = link_to t('.invite_contacts'), new_user_invitation_path(current_user) %br %br diff --git a/app/views/users/getting_started/_step_2.html.haml b/app/views/users/getting_started/_step_2.html.haml index 63028ffc7..bf20f3ee8 100644 --- a/app/views/users/getting_started/_step_2.html.haml +++ b/app/views/users/getting_started/_step_2.html.haml @@ -18,11 +18,11 @@ - for aspect in @aspects %li{:style=>"position:relative;"} = aspect - .friend_pictures.horizontal - - for friend in aspect.person_objects - = person_image_link(friend) + .contact_pictures.horizontal + - for contact in aspect.person_objects + = person_image_link(contact) - = link_to (image_tag('add_friend_button.png', :title => t('shared.aspect_friends.add_to', :aspect => aspect))), '#manage_aspect_contacts_pane', :class => 'manage_aspect_contacts_button' + = link_to (image_tag('add_contact_button.png', :title => t('shared.aspect_contactss.add_to', :aspect => aspect))), '#manage_aspect_contacts_pane', :class => 'manage_aspect_contacts_button' .fancybox_content #manage_aspect_contacts_pane diff --git a/config/routes.rb b/config/routes.rb index 4b637aa90..315364e28 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,7 +28,7 @@ Diaspora::Application.routes.draw do match 'users/export_photos', :to => 'users#export_photos' resources :users, :except => [:create, :new, :show] - match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' + match 'aspects/move_contact', :to => 'aspects#move_contact', :as => 'move_contact' match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect' match 'aspects/remove_from_aspect',:to => 'aspects#remove_from_aspect', :as => 'remove_from_aspect' match 'aspects/manage', :to => 'aspects#manage' diff --git a/lib/diaspora/exporter.rb b/lib/diaspora/exporter.rb index c435749e3..9fcc5fb45 100644 --- a/lib/diaspora/exporter.rb +++ b/lib/diaspora/exporter.rb @@ -46,13 +46,13 @@ module Diaspora } xml.contacts { - user.friends.each do |friend| + user.contacts.each do |contact| xml.contact { - xml.user_id friend.user_id - xml.person_id friend.person_id + xml.user_id contact.user_id + xml.person_id contact.person_id xml.aspects { - friend.aspects.each do |aspect| + contact.aspects.each do |aspect| xml.aspect { xml.name aspect.name } @@ -73,8 +73,8 @@ module Diaspora } xml.people { - user.friends.each do |friend| - person = friend.person + user.contacts.each do |contact| + person = contact.person xml.parent << person.to_xml end diff --git a/lib/diaspora/user.rb b/lib/diaspora/user.rb index 94da947f8..0c7c26cc6 100644 --- a/lib/diaspora/user.rb +++ b/lib/diaspora/user.rb @@ -1,10 +1,10 @@ -require File.join(Rails.root, 'lib/diaspora/user/friending') +require File.join(Rails.root, 'lib/diaspora/user/connecting') require File.join(Rails.root, 'lib/diaspora/user/querying') require File.join(Rails.root, 'lib/diaspora/user/receiving') module Diaspora module UserModules - include Friending + include Connecting include Querying include Receiving end diff --git a/lib/diaspora/user/connecting.rb b/lib/diaspora/user/connecting.rb new file mode 100644 index 000000000..40d05c1f2 --- /dev/null +++ b/lib/diaspora/user/connecting.rb @@ -0,0 +1,140 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module Diaspora + module UserModules + module Connecting + def send_contact_request_to(desired_contact, aspect) + # should have different exception types for these? + raise "You cannot connect yourself" if desired_contact.nil? + raise "You have already sent a contact request to that person!" if self.pending_requests.detect{ + |x| x.to == desired_contact} + raise "You are already connected to that person!" if contact_for desired_contact + request = Request.instantiate( + :to => desired_contact, + :from => self.person, + :into => aspect) + if request.save + self.pending_requests << request + self.save + + aspect.requests << request + aspect.save + push_to_people request, [desired_contact] + end + request + end + + def accept_contact_request(request, aspect) + pending_request_ids.delete(request.id.to_id) + activate_contact(request.from, aspect) + + request.reverse_for(self) + end + + def dispatch_contact_acceptance(request, requester) + push_to_people request, [requester] + request.destroy unless request.from.owner + end + + def accept_and_respond(contact_request_id, aspect_id) + request = pending_requests.find!(contact_request_id) + requester = request.from + reversed_request = accept_contact_request(request, aspect_by_id(aspect_id)) + dispatch_contact_acceptance reversed_request, requester + end + + def ignore_contact_request(contact_request_id) + request = pending_requests.find!(contact_request_id) + person = request.from + + self.pending_request_ids.delete(request.id) + self.save + + person.save + request.destroy + end + + def receive_contact_request(contact_request) + Rails.logger.info("receiving contact request #{contact_request.to_json}") + + #response from a contact request you sent + if original_request = original_request(contact_request) + destination_aspect = self.aspect_by_id(original_request.into_id) + activate_contact(contact_request.from, destination_aspect) + Rails.logger.info("#{self.real_name}'s contact request has been accepted") + + contact_request.destroy + + pending_requests.delete(original_request) + original_request.destroy + self.save + Request.send_request_accepted(self, contact_request.from, destination_aspect) + + #this is a new contact request + elsif !request_from_me?(contact_request) + self.pending_requests << contact_request + self.save! + Rails.logger.info("#{self.real_name} has received a contact request") + contact_request.save + Request.send_new_request(self, contact_request.from) + else + raise "#{self.real_name} is trying to receive a contact request from himself." + end + contact_request + end + + def disconnect(bad_contact) + Rails.logger.info("#{self.real_name} is disconnecting #{bad_contact.inspect}") + retraction = Retraction.for(self) + push_to_people retraction, [bad_contact] + remove_contact(bad_contact) + end + + def remove_contact(bad_contact) + contact = contact_for(bad_contact) + contact.aspects.each{|aspect| + contact.aspects.delete(aspect) + aspect.posts.each { |post| + aspect.post_ids.delete(post.id) if post.person == bad_contact + } + aspect.save + } + + self.raw_visible_posts.find_all_by_person_id( bad_contact.id ).each{|post| + self.visible_post_ids.delete( post.id ) + post.user_refs -= 1 + (post.user_refs > 0 || post.person.owner.nil? == false) ? post.save : post.destroy + } + self.save + raise "Contact not deleted" unless contact.destroy + bad_contact.save + end + + def disconnected_by(bad_contact) + Rails.logger.info("#{self.real_name} is being disconnected by #{bad_contact.inspect}") + remove_contact bad_contact + end + + def activate_contact(person, aspect) + new_contact = Contact.create!(:user => self, :person => person, :aspects => [aspect]) + new_contact.aspects << aspect + save! + aspect.save! + end + + def request_from_me?(request) + request.from == self.person + end + + def original_request(response) + pending_requests.first(:from_id => self.person.id, :to_id => response.from.id) + end + + def requests_for_me + pending_requests.select{|req| req.to == self.person} + end + end + end +end diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb deleted file mode 100644 index f0a8020f0..000000000 --- a/lib/diaspora/user/friending.rb +++ /dev/null @@ -1,143 +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. - -module Diaspora - module UserModules - module Friending - def send_friend_request_to(desired_friend, aspect) - # should have different exception types for these? - raise "You cannot befriend yourself" if desired_friend.nil? - raise "You have already sent a friend request to that person!" if self.pending_requests.detect{ - |x| x.to == desired_friend} - raise "You are already friends with that person!" if contact_for desired_friend - request = Request.instantiate( - :to => desired_friend, - :from => self.person, - :into => aspect) - if request.save - self.pending_requests << request - self.save - - aspect.requests << request - aspect.save - push_to_people request, [desired_friend] - end - request - end - - def accept_friend_request(request, aspect) - pending_request_ids.delete(request.id.to_id) - activate_friend(request.from, aspect) - - request.reverse_for(self) - end - - def dispatch_friend_acceptance(request, requester) - push_to_people request, [requester] - request.destroy unless request.from.owner - end - - def accept_and_respond(friend_request_id, aspect_id) - request = pending_requests.find!(friend_request_id) - requester = request.from - reversed_request = accept_friend_request(request, aspect_by_id(aspect_id)) - dispatch_friend_acceptance reversed_request, requester - end - - def ignore_friend_request(friend_request_id) - request = pending_requests.find!(friend_request_id) - person = request.from - - self.pending_request_ids.delete(request.id) - self.save - - person.save - request.destroy - end - - def receive_friend_request(friend_request) - Rails.logger.info("receiving friend request #{friend_request.to_json}") - - #response from a friend request you sent - if original_request = original_request(friend_request) - destination_aspect = self.aspect_by_id(original_request.into_id) - #pp original_request - #pp friend_request - #pp friend_request.person - activate_friend(friend_request.from, destination_aspect) - Rails.logger.info("#{self.real_name}'s friend request has been accepted") - - friend_request.destroy - - pending_requests.delete(original_request) - original_request.destroy - self.save - Request.send_request_accepted(self, friend_request.from, destination_aspect) - - #this is a new friend request - elsif !request_from_me?(friend_request) - self.pending_requests << friend_request - self.save! - Rails.logger.info("#{self.real_name} has received a friend request") - friend_request.save - Request.send_new_request(self, friend_request.from) - else - raise "#{self.real_name} is trying to receive a friend request from himself." - end - friend_request - end - - def unfriend(bad_friend) - Rails.logger.info("#{self.real_name} is unfriending #{bad_friend.inspect}") - retraction = Retraction.for(self) - push_to_people retraction, [bad_friend] - remove_friend(bad_friend) - end - - def remove_friend(bad_friend) - contact = contact_for(bad_friend) - contact.aspects.each{|aspect| - contact.aspects.delete(aspect) - aspect.posts.each { |post| - aspect.post_ids.delete(post.id) if post.person == bad_friend - } - aspect.save - } - - self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post| - self.visible_post_ids.delete( post.id ) - post.user_refs -= 1 - (post.user_refs > 0 || post.person.owner.nil? == false) ? post.save : post.destroy - } - self.save - raise "Friend not deleted" unless contact.destroy - bad_friend.save - end - - def unfriended_by(bad_friend) - Rails.logger.info("#{self.real_name} is being unfriended by #{bad_friend.inspect}") - remove_friend bad_friend - end - - def activate_friend(person, aspect) - new_contact = Contact.create!(:user => self, :person => person, :aspects => [aspect]) - new_contact.aspects << aspect - save! - aspect.save! - end - - def request_from_me?(request) - request.from == self.person - end - - def original_request(response) - pending_requests.first(:from_id => self.person.id, :to_id => response.from.id) - end - - def requests_for_me - pending_requests.select{|req| req.to == self.person} - end - end - end -end diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 981d6028f..60cc79c5a 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -25,8 +25,8 @@ module Diaspora id = id.to_id if id == self.person.id self.person - elsif friend = friends.first(:person_id => id) - friend.person + elsif contact = contacts.first(:person_id => id) + contact.person else visible_people.detect{|x| x.id == id } end @@ -42,16 +42,16 @@ module Diaspora end def contact_for_person_id(person_id) - friends.first(:person_id => person_id.to_id) if person_id + contacts.first(:person_id => person_id.to_id) if person_id end - def friends_not_in_aspect( aspect ) + def contacts_not_in_aspect( aspect ) person_ids = Contact.all(:user_id => self.id, :aspect_ids.ne => aspect._id).collect{|x| x.person_id } Person.all(:id.in => person_ids) end - def person_objects(contacts = self.friends) + def person_objects(contacts = self.contacts) person_ids = contacts.collect{|x| x.person_id} Person.all(:id.in => person_ids) end diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index 655d42f8c..b6cdf27ab 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -48,7 +48,7 @@ module Diaspora object.person = person if object.respond_to? :person= unless object.is_a?(Request) || self.contact_for(salmon_author) - raise "Not friends with that person" + raise "Not connected to that person" else return receive_object(object,person) @@ -80,10 +80,10 @@ module Diaspora def receive_retraction retraction if retraction.type == 'Person' unless retraction.person.id.to_s == retraction.post_id.to_s - raise "#{retraction.diaspora_handle} trying to unfriend #{retraction.post_id} from #{self.id}" + raise "#{retraction.diaspora_handle} trying to disconnect #{retraction.post_id} from #{self.id}" end - Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}") - unfriended_by visible_person_by_id(retraction.post_id) + Rails.logger.info( "the person id is #{retraction.post_id} the contact found is #{visible_person_by_id(retraction.post_id).inspect}") + disconnected_by visible_person_by_id(retraction.post_id) else retraction.perform self.id aspects = self.aspects_with_person(retraction.person) @@ -95,7 +95,7 @@ module Diaspora def receive_request request, person request.save! - receive_friend_request(request) + receive_contact_request(request) end def receive_profile profile, person diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 54d8cb028..452780fa6 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -54,12 +54,12 @@ var AspectEdit = { }); } - if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing friend 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')) { $.ajax({ - url: "/aspects/move_friend/", + url: "/aspects/move_contact/", data: { - "friend_id" : person.attr('data-guid'), + "person_id" : person.attr('data-guid'), "from" : person.attr('data-aspect_id'), "to" : { "to" : dropzone.attr('data-aspect_id') } }, @@ -92,7 +92,7 @@ var AspectEdit = { type: "POST", url: "/aspects/remove_from_aspect", data:{ - 'friend_id' : person_id, + 'person_id' : person_id, 'aspect_id' : person.attr('data-aspect_id') } }); } diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index cda3dfd9d..df8f3a1b4 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -59,8 +59,8 @@ var Publisher = { if (dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { $.ajax({ - url: "/aspects/move_friend/", - data: {"friend_id" : person.attr('data-guid'), + url: "/aspects/move_contact/", + data: {"person_id" : person.attr('data-guid'), "from" : person.attr('data-aspect_id'), "to" : { "to" : dropzone.attr('data-aspect_id') }}, success: function(data) { @@ -85,7 +85,7 @@ var Publisher = { type: "POST", url: "/aspects/remove_from_aspect", data:{ - 'friend_id' : person_id, + 'person_id' : person_id, 'aspect_id' : person.attr('data-aspect_id') } }); } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 65f9ba1c7..4e0f9d3ae 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1152,7 +1152,7 @@ ul#settings_nav :color transparent -.friend_pictures +.contact_pictures :margin :top 12px :line-height 1em @@ -1161,7 +1161,7 @@ ul#settings_nav :width 30px :height 30px -.friend_pictures.horizontal +.contact_pictures.horizontal img :margin-right -5px diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 78cfc1d92..f0a2dcfc4 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -20,10 +20,10 @@ describe AspectsController do end describe "#index" do - it "assigns @friends to all the user's friends" do + it "assigns @contacts to all the user's contacts" do Factory.create :person get :index - assigns[:friends].should == @user.person_objects + assigns[:contacts].should == @user.contacts end end @@ -69,7 +69,7 @@ describe AspectsController do before do requestor = make_user requestor_aspect = requestor.aspects.create(:name => "Meh") - requestor.send_friend_request_to(@user.person, requestor_aspect) + requestor.send_contact_request_to(@user.person, requestor_aspect) requestor.reload requestor_aspect.reload @@ -90,13 +90,13 @@ describe AspectsController do end end - describe "#move_friend" do - let(:opts) { {:friend_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}} } - it 'calls the move_friend_method' do + describe "#move_contact" do + let(:opts) { {:person_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}} } + it 'calls the move_contact_method' do pending "need to figure out what is the deal with remote requests" @controller.stub!(:current_user).and_return(@user) - @user.should_receive(:move_friend).with(:friend_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id") - post :move_friend, opts + @user.should_receive(:move_contact).with(:person_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id") + post :move_contact, opts end end @@ -117,7 +117,7 @@ describe AspectsController do it 'adds the users to the aspect' do @aspect1.reload @aspect1.people.include?(@contact).should be false - post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id} + post 'add_to_aspect', {:person_id => @user2.person.id, :aspect_id => @aspect1.id} @aspect1.reload @aspect1.people.include?(@contact).should be true end @@ -127,7 +127,7 @@ describe AspectsController do it 'adds the users to the aspect' do @aspect.reload @aspect.people.include?(@contact).should be true - post 'remove_from_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id} + post 'remove_from_aspect', {:person_id => @user2.person.id, :aspect_id => @aspect1.id} @aspect1.reload @aspect1.people.include?(@contact).should be false end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 26a825b40..ae4257be7 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -24,7 +24,7 @@ describe CommentsController do :post_id =>"#{@post.id}"}} } - context "on a post from a friend" do + context "on a post from a contact" do before do connect_users(user, aspect, user2, aspect2) @post = user2.post :status_message, :message => 'GIANTS', :to => aspect2.id diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 3bda1130d..b2d699a70 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -21,7 +21,7 @@ describe PeopleController do assigns[:people].should include eugene end - it 'shows a friend' do + it 'shows a contact' do user2 = make_user connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) get :index @@ -29,7 +29,7 @@ describe PeopleController do response.should be_success end - it 'shows a non-friend' do + it 'shows a non-contact' do user2 = make_user user2.person.profile.searchable = true user2.save @@ -55,14 +55,14 @@ describe PeopleController do response.should redirect_to people_path end - it "renders the show page of a friend" do + it "renders the show page of a contact" do user2 = make_user connect_users(user, aspect, user2, user2.aspects.create(:name => 'Neuroscience')) get :show, :id => user2.person.id response.should be_success end - it "renders the show page of a non-friend" do + it "renders the show page of a non-contact" do user2 = make_user get :show, :id => user2.person.id response.should be_success diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 58bd342bd..92667b7bc 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -41,7 +41,7 @@ describe PhotosController do assigns[:posts].should == [photo] end - it 'sets the person to a friend if person_id is set' do + it 'sets the person to a contact if person_id is set' do get :index, :person_id => user2.person.id.to_s assigns[:person].should == user2.person diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index ebbb10ee1..c729c95eb 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -12,7 +12,7 @@ describe PublicsController do let!(:aspect1) { user.aspects.create(:name => "foo") } let!(:aspect2) { user2.aspects.create(:name => "far") } let!(:aspect2) { user2.aspects.create(:name => 'disciples') } - let!(:req) { user2.send_friend_request_to(user.person, aspect2) } + let!(:req) { user2.send_contact_request_to(user.person, aspect2) } let!(:xml) { user2.salmon(req).xml_for(user.person) } let(:person){Factory(:person)} @@ -99,7 +99,7 @@ describe PublicsController do end context 'intergration tests that should not be in this file' do - describe 'friend requests' do + describe 'contact requests' do before do req.delete user2.reload diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index bee25b881..9d6684292 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -14,7 +14,7 @@ describe RequestsController do end describe '#create' do - it "redirects when requesting to be friends with yourself" do + it "redirects when requesting to be contacts with yourself" do put(:create, { :destination_handle => @user.diaspora_handle, :aspect_id => @user.aspects[0].id diff --git a/spec/fixtures/users.yaml b/spec/fixtures/users.yaml index 5c90e0040..b7c016bec 100644 --- a/spec/fixtures/users.yaml +++ b/spec/fixtures/users.yaml @@ -25,7 +25,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id001 !ruby/object:BSON::ObjectId data: @@ -118,7 +118,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id003 !ruby/object:BSON::ObjectId data: @@ -211,7 +211,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id004 !ruby/object:BSON::ObjectId data: @@ -304,7 +304,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id005 !ruby/object:BSON::ObjectId data: @@ -397,7 +397,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id006 !ruby/object:BSON::ObjectId data: @@ -490,7 +490,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id007 !ruby/object:BSON::ObjectId data: @@ -583,7 +583,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id008 !ruby/object:BSON::ObjectId data: @@ -676,7 +676,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id009 !ruby/object:BSON::ObjectId data: @@ -769,7 +769,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id010 !ruby/object:BSON::ObjectId data: @@ -862,7 +862,7 @@ last_sign_in_ip: invites: 5 - friend_ids: [] + contact_ids: [] _id: &id011 !ruby/object:BSON::ObjectId data: diff --git a/spec/helper_methods.rb b/spec/helper_methods.rb index cd3718d7e..74b950d3f 100644 --- a/spec/helper_methods.rb +++ b/spec/helper_methods.rb @@ -27,7 +27,7 @@ module HelperMethods end def connect_users(user1, aspect1, user2, aspect2) - request = user1.send_friend_request_to(user2.person, aspect1) + request = user1.send_contact_request_to(user2.person, aspect1) user1.reload aspect1.reload diff --git a/spec/javascripts/aspect-edit-spec.js b/spec/javascripts/aspect-edit-spec.js index 1ecb5da5f..04e2ef913 100644 --- a/spec/javascripts/aspect-edit-spec.js +++ b/spec/javascripts/aspect-edit-spec.js @@ -123,7 +123,7 @@ describe("AspectEdit", function() { expect($.ajax).toHaveBeenCalled(); var args = $.ajax.mostRecentCall.args[0]; expect(args["url"]).toEqual("/aspects/move_friend/"); - expect(args["data"]["friend_id"]).toEqual("guid-of-this-person"); + expect(args["data"]["person_id"]).toEqual("guid-of-this-person"); expect(args["data"]["from"]).toEqual("guid-of-current-aspect"); expect(args["data"]["to"]).toEqual({"to": "guid-of-target-aspect" }); }); @@ -239,4 +239,4 @@ describe("AspectEdit", function() { }); }); }); -}); \ No newline at end of file +}); diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index b8ee527da..538d58c07 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -56,8 +56,8 @@ describe Diaspora::Exporter do it 'should include an aspects names of all aspects they are in' do #contact specific xml needs to be tested - user1.friends.find_by_person_id(user3.person.id).aspects.count.should > 0 - user1.friends.find_by_person_id(user3.person.id).aspects.each { |aspect| + user1.contacts.find_by_person_id(user3.person.id).aspects.count.should > 0 + user1.contacts.find_by_person_id(user3.person.id).aspects.each { |aspect| contacts_xml.should include aspect.name } end diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 9ed0e9bd2..c4e14d62c 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -33,7 +33,7 @@ describe Diaspora::Parser do proc { user.receive xml, user2.person }.should change(StatusMessage, :count).by(-1) end - context "friending" do + context "connecting" do let(:good_request) { FakeHttpRequest.new(:success)} it "should create a new person upon getting a person request" do @@ -58,7 +58,7 @@ describe Diaspora::Parser do end it "should activate the Person if I initiated a request to that url" do - user.send_friend_request_to(user2.person, aspect) + user.send_contact_request_to(user2.person, aspect) request = user2.reload.pending_requests.find_by_to_id!(user2.person.id) user2.accept_and_respond(request.id, aspect2.id) @@ -66,7 +66,7 @@ describe Diaspora::Parser do aspect.reload new_contact = user.contact_for(user2.person) aspect.people.include?(new_contact).should be true - user.friends.include?(new_contact).should be true + user.contacts.include?(new_contact).should be true end it 'should process retraction for a person' do diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 0e790000f..964e4565c 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -53,24 +53,24 @@ describe 'making sure the spec runner works' do connect_users(@user1, @aspect1, @user2, @aspect2) end - it 'makes the first user friends with the second' do + it 'connects the first user to the second' do contact = @user1.contact_for @user2.person contact.should_not be_nil - @user1.friends.include?(contact).should be_true + @user1.contacts.include?(contact).should be_true @aspect1.people.include?(contact).should be_true contact.aspects.include?( @aspect1 ).should be true end - it 'makes the second user friends with the first' do + it 'connects the second user to the first' do contact = @user2.contact_for @user1.person contact.should_not be_nil - @user2.friends.include?(contact).should be_true + @user2.contacts.include?(contact).should be_true @aspect2.people.include?(contact).should be_true contact.aspects.include?( @aspect2 ).should be true end it 'allows posting after running' do - message = @user1.post(:status_message, :message => "Friendship!", :to => @aspect1.id) + message = @user1.post(:status_message, :message => "Connection!", :to => @aspect1.id) @user2.reload.visible_posts.should include message end end diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index adb61bc0e..745ed0ecc 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -6,14 +6,14 @@ require 'spec_helper' describe Aspect do let(:user ) { make_user } - let(:friend) { Factory.create(:person) } + let(:connected_person) { Factory.create(:person) } let(:user2) { make_user } - let(:friend_2) { Factory.create(:person) } + let(:connected_person_2) { Factory.create(:person) } let(:aspect) {user.aspects.create(:name => 'losers')} let(:aspect2) {user2.aspects.create(:name => 'failures')} let(:aspect1) {user.aspects.create(:name => 'cats')} - let(:not_friend) { Factory(:person, :diaspora_handle => "not@person.com")} + let(:not_contact) { Factory(:person, :diaspora_handle => "not@person.com")} let(:user3) {make_user} let(:aspect3) {user3.aspects.create(:name => "lala")} @@ -35,7 +35,7 @@ describe Aspect do end it 'should not be creatable with people' do - aspect = user.aspects.create(:name => 'losers', :people => [friend, friend_2]) + aspect = user.aspects.create(:name => 'losers', :people => [connected_person, connected_person_2]) aspect.people.size.should == 0 end @@ -48,7 +48,7 @@ describe Aspect do it 'should be able to have users and people' do contact1 = Contact.create(:user => user, :person => user2.person, :aspects => [aspect]) - contact2 = Contact.create(:user => user, :person => friend_2, :aspects => [aspect]) + contact2 = Contact.create(:user => user, :person => connected_person_2, :aspects => [aspect]) aspect.people.include?(contact1).should be_true aspect.people.include?(contact2).should be_true aspect.save.should be_true @@ -73,7 +73,7 @@ describe Aspect do describe 'querying' do before do aspect - user.activate_friend(friend, aspect) + user.activate_contact(connected_person, aspect) end it 'belong to a user' do @@ -82,27 +82,27 @@ describe Aspect do end it 'should have people' do - aspect.people.first(:person_id => friend.id).should be_true + aspect.people.first(:person_id => connected_person.id).should be_true aspect.people.size.should == 1 end describe '#aspects_with_person' do - let!(:aspect_without_friend) {user.aspects.create(:name => "Another aspect")} - it 'should return the aspects with given friend' do + let!(:aspect_without_contact) {user.aspects.create(:name => "Another aspect")} + it 'should return the aspects with given contact' do user.reload - aspects = user.aspects_with_person(friend) + aspects = user.aspects_with_person(connected_person) aspects.size.should == 1 aspects.first.should == aspect end it 'returns multiple aspects if the person is there' do user.reload - user.add_person_to_aspect(friend.id, aspect1.id) - aspects = user.aspects_with_person(friend) + user.add_person_to_aspect(connected_person.id, aspect1.id) + aspects = user.aspects_with_person(connected_person) aspects.count.should == 2 - contact = user.contact_for(friend) + contact = user.contact_for(connected_person) aspects.each{ |asp| asp.people.include?(contact).should be_true } - aspects.include?(aspect_without_friend).should be_false + aspects.include?(aspect_without_contact).should be_false end end end @@ -110,7 +110,7 @@ describe Aspect do describe 'posting' do it 'should add post to aspect via post method' do - aspect = user.aspects.create(:name => 'losers', :people => [friend]) + aspect = user.aspects.create(:name => 'losers', :people => [connected_person]) status_message = user.post( :status_message, :message => "hey", :to => aspect.id ) @@ -168,7 +168,7 @@ describe Aspect do end it 'does not allow to have duplicate people in an aspect' do - proc{user.add_person_to_aspect(not_friend.id, aspect1.id) }.should raise_error /Can not add person you are not friends with/ + proc{user.add_person_to_aspect(not_contact.id, aspect1.id) }.should raise_error /Can not add person you are not connected to/ end it 'does not allow you to add a person if they are already in the aspect' do @@ -223,9 +223,9 @@ describe Aspect do aspect.posts.should == [@message] end - describe '#move_friend' do - it 'should be able to move a friend from one of users existing aspects to another' do - user.move_friend(:friend_id => user2.person.id, :from => aspect.id, :to => aspect1.id) + describe '#move_contact' do + it 'should be able to move a contact from one of users existing aspects to another' do + user.move_contact(:person_id => user2.person.id, :from => aspect.id, :to => aspect1.id) aspect.reload aspect1.reload @@ -233,16 +233,16 @@ describe Aspect do aspect1.people.include?(contact).should be_true end - it "should not move a person who is not a friend" do - proc{ user.move_friend(:friend_id => friend.id, :from => aspect.id, :to => aspect1.id) }.should raise_error /Can not add person you are not friends with/ + it "should not move a person who is not a contact" do + proc{ user.move_contact(:person_id => connected_person.id, :from => aspect.id, :to => aspect1.id) }.should raise_error /Can not add person you are not connected to/ aspect.reload aspect1.reload - aspect.people.first(:person_id => friend.id).should be_nil - aspect1.people.first(:person_id => friend.id).should be_nil + aspect.people.first(:person_id => connected_person.id).should be_nil + aspect1.people.first(:person_id => connected_person.id).should be_nil end it "should not move a person to a aspect that's not his" do - proc {user.move_friend(:friend_id => user2.person.id, :from => aspect.id, :to => aspect2.id )}.should raise_error /Can not add person to an aspect you do not own/ + proc {user.move_contact(:person_id => user2.person.id, :from => aspect.id, :to => aspect2.id )}.should raise_error /Can not add person to an aspect you do not own/ aspect.reload aspect2.reload aspect.people.include?(contact).should be true @@ -250,7 +250,7 @@ describe Aspect do end it 'should move all posts by that user to the new aspect' do - user.move_friend(:friend_id => user2.person.id, :from => aspect.id, :to => aspect1.id) + user.move_contact(:person_id => user2.person.id, :from => aspect.id, :to => aspect1.id) aspect.reload aspect1.reload @@ -261,7 +261,7 @@ describe Aspect do it 'does not try to delete if add person did not go through' do user.should_receive(:add_person_to_aspect).and_return(false) user.should_not_receive(:delete_person_from_aspect) - user.move_friend(:friend_id => user2.person.id, :from => aspect.id, :to => aspect1.id) + user.move_contact(:person_id => user2.person.id, :from => aspect.id, :to => aspect1.id) end end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index bd16bef2e..39f8550a7 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -11,7 +11,7 @@ describe Comment do let(:user2) {make_user} let(:aspect2) {user2.aspects.create(:name => "Lame-faces")} - let!(:friending) { connect_users(user, aspect, user2, aspect2) } + let!(:connecting) { connect_users(user, aspect, user2, aspect2) } it 'validates that the handle belongs to the person' do user_status = user.post(:status_message, :message => "hello", :to => aspect.id) @@ -47,7 +47,7 @@ describe Comment do describe 'comment propagation' do before do @person = Factory.create(:person) - user.activate_friend(@person, Aspect.first(:id => aspect.id)) + user.activate_contact(@person, Aspect.first(:id => aspect.id)) @person2 = Factory.create(:person) @person_status = Factory.build(:status_message, :person => @person) @@ -151,7 +151,7 @@ describe Comment do message.comments.first.verify_post_creator_signature.should be true end - it 'should verify a comment made on a remote post by a different friend' do + it 'should verify a comment made on a remote post by a different contact' do comment = Comment.new(:person => user2.person, :text => "cats", :post => @remote_message) comment.creator_signature = comment.send(:sign_with_key,user2.encryption_key) comment.signature_valid?.should be true diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index ebe9e3e11..ce8e6584d 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -78,9 +78,9 @@ describe Invitation do new_user.invitations_to_me.first.message.should == message end - it 'sends a friend request to a user with that email into the aspect' do + it 'sends a contact request to a user with that email into the aspect' do user2 - user.should_receive(:send_friend_request_to){ |a, b| + user.should_receive(:send_contact_request_to){ |a, b| a.should == user2.person b.should == aspect } diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index a7ba0ca0d..8d43e1def 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -125,68 +125,68 @@ describe Person do lambda {person.destroy}.should_not change(Comment, :count) end - describe "unfriending" do - it 'should not delete an orphaned friend' do - @user.activate_friend(@person, @aspect) + describe "disconnecting" do + it 'should not delete an orphaned contact' do + @user.activate_contact(@person, @aspect) - lambda {@user.unfriend(@person)}.should_not change(Person, :count) + lambda {@user.disconnect(@person)}.should_not change(Person, :count) end - it 'should not delete an un-orphaned friend' do - @user.activate_friend(@person, @aspect) - @user2.activate_friend(@person, @aspect2) + it 'should not delete an un-orphaned contact' do + @user.activate_contact(@person, @aspect) + @user2.activate_contact(@person, @aspect2) - lambda {@user.unfriend(@person)}.should_not change(Person, :count) + lambda {@user.disconnect(@person)}.should_not change(Person, :count) end end describe '#search' do before do - @friend_one = Factory.create(:person) - @friend_two = Factory.create(:person) - @friend_three = Factory.create(:person) - @friend_four = Factory.create(:person) + @connected_person_one = Factory.create(:person) + @connected_person_two = Factory.create(:person) + @connected_person_three = Factory.create(:person) + @connected_person_four = Factory.create(:person) - @friend_one.profile.first_name = "Robert" - @friend_one.profile.last_name = "Grimm" - @friend_one.profile.save + @connected_person_one.profile.first_name = "Robert" + @connected_person_one.profile.last_name = "Grimm" + @connected_person_one.profile.save - @friend_two.profile.first_name = "Eugene" - @friend_two.profile.last_name = "Weinstein" - @friend_two.save + @connected_person_two.profile.first_name = "Eugene" + @connected_person_two.profile.last_name = "Weinstein" + @connected_person_two.save - @friend_three.profile.first_name = "Yevgeniy" - @friend_three.profile.last_name = "Dodis" - @friend_three.save + @connected_person_three.profile.first_name = "Yevgeniy" + @connected_person_three.profile.last_name = "Dodis" + @connected_person_three.save - @friend_four.profile.first_name = "Casey" - @friend_four.profile.last_name = "Grippi" - @friend_four.save + @connected_person_four.profile.first_name = "Casey" + @connected_person_four.profile.last_name = "Grippi" + @connected_person_four.save end it 'should yield search results on partial names' do people = Person.search("Eu") - people.include?(@friend_two).should == true - people.include?(@friend_one).should == false - people.include?(@friend_three).should == false - people.include?(@friend_four).should == false + people.include?(@connected_person_two).should == true + people.include?(@connected_person_one).should == false + people.include?(@connected_person_three).should == false + people.include?(@connected_person_four).should == false people = Person.search("wEi") - people.include?(@friend_two).should == true - people.include?(@friend_one).should == false - people.include?(@friend_three).should == false - people.include?(@friend_four).should == false + people.include?(@connected_person_two).should == true + people.include?(@connected_person_one).should == false + people.include?(@connected_person_three).should == false + people.include?(@connected_person_four).should == false people = Person.search("gri") - people.include?(@friend_one).should == true - people.include?(@friend_four).should == true - people.include?(@friend_two).should == false - people.include?(@friend_three).should == false + people.include?(@connected_person_one).should == true + people.include?(@connected_person_four).should == true + people.include?(@connected_person_two).should == false + people.include?(@connected_person_three).should == false end it 'should yield results on full names' do people = Person.search("Casey Grippi") - people.should == [@friend_four] + people.should == [@connected_person_four] end it 'should only display searchable people' do @@ -196,7 +196,7 @@ describe Person do end it 'should search on handles' do - Person.search(@friend_one.diaspora_handle).should include @friend_one + Person.search(@connected_person_one.diaspora_handle).should include @connected_person_one end end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 8da4153c9..6e381f46a 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -9,7 +9,7 @@ describe Request do let(:user2) { make_user } let(:person) { Factory :person } let(:aspect) { user.aspects.create(:name => "dudes") } - let(:request){ user.send_friend_request_to user2.person, aspect } + let(:request){ user.send_contact_request_to user2.person, aspect } describe 'validations' do before do @@ -123,7 +123,7 @@ describe Request do end context 'mailers' do - context 'suger around friends' do + context 'sugar around contacts' do before do Request.should_receive(:async).and_return(Request) @mock_request = mock() diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index b5dcc1523..178c1d3d0 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -9,7 +9,7 @@ describe Retraction do let(:user) { make_user } let(:person) { Factory(:person) } let(:aspect) { user.aspects.create(:name => "Bruisers") } - let!(:activation) { user.activate_friend(person, aspect) } + let!(:activation) { user.activate_contact(person, aspect) } let!(:post) { user.post :status_message, :message => "Destroy!", :to => aspect.id } describe 'serialization' do diff --git a/spec/models/user/attack_vectors_spec.rb b/spec/models/user/attack_vectors_spec.rb index cbe68b599..d10d2f97f 100644 --- a/spec/models/user/attack_vectors_spec.rb +++ b/spec/models/user/attack_vectors_spec.rb @@ -17,19 +17,19 @@ describe "attack vectors" do let(:user3) { make_user } let(:aspect3) { user3.aspects.create(:name => 'heroes') } - context 'non-friend valid user' do + context 'non-contact valid user' do - it 'raises if receives post by non-friend' do - post_from_non_friend = bad_user.build_post( :status_message, :message => 'hi') - xml = bad_user.salmon(post_from_non_friend).xml_for(user.person) + it 'raises if receives post by non-contact' do + post_from_non_contact = bad_user.build_post( :status_message, :message => 'hi') + xml = bad_user.salmon(post_from_non_contact).xml_for(user.person) - post_from_non_friend.delete + post_from_non_contact.delete bad_user.delete post_count = Post.count - proc{ user.receive_salmon(xml) }.should raise_error /Not friends with that person/ + proc{ user.receive_salmon(xml) }.should raise_error /Not connected to that person/ - user.raw_visible_posts.include?(post_from_non_friend).should be false + user.raw_visible_posts.include?(post_from_non_contact).should be false Post.count.should == post_count end @@ -46,7 +46,7 @@ describe "attack vectors" do user3.reload.visible_posts.should_not include(original_message) end - context 'malicious friend attack vector' do + context 'malicious contact attack vector' do before do connect_users(user, aspect, user2, aspect2) connect_users(user, aspect, user3, aspect3) @@ -144,9 +144,9 @@ describe "attack vectors" do proc{ user.receive_salmon(user3.salmon(ret).xml_for(user.person)) - }.should raise_error /#{user3.diaspora_handle} trying to unfriend #{user2.person.id} from #{user.id}/ + }.should raise_error /#{user3.diaspora_handle} trying to disconnect #{user2.person.id} from #{user.id}/ - user.reload.friends.count.should == 2 + user.reload.contacts.count.should == 2 end it 'it should not allow you to send retractions with xml and salmon handle mismatch' do @@ -159,7 +159,7 @@ describe "attack vectors" do user.receive_salmon(user3.salmon(ret).xml_for(user.person)) }.should raise_error /Malicious Post/ - user.reload.friends.count.should == 2 + user.reload.contacts.count.should == 2 end it 'does not let me update other persons post' do diff --git a/spec/models/user/friending_spec.rb b/spec/models/user/connecting_spec.rb similarity index 63% rename from spec/models/user/friending_spec.rb rename to spec/models/user/connecting_spec.rb index c33a3e7b0..3607d541b 100644 --- a/spec/models/user/friending_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -1,15 +1,14 @@ - # 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 Diaspora::UserModules::Friending do +describe Diaspora::UserModules::Connecting do let(:user) { make_user } let(:aspect) { user.aspects.create(:name => 'heroes') } let(:aspect1) { user.aspects.create(:name => 'other') } - let(:friend) { Factory.create(:person) } + let(:person) { Factory.create(:person) } let(:person_one) { Factory.create :person } let(:person_two) { Factory.create :person } @@ -19,79 +18,77 @@ describe Diaspora::UserModules::Friending do let(:aspect2) { user2.aspects.create(:name => "aspect two") } - context 'friend requesting' do + context 'contact requesting' do it "should assign a request to a aspect for the user that sent it out" do aspect.requests.size.should == 0 - user.send_friend_request_to(friend, aspect) + user.send_contact_request_to(person, aspect) aspect.reload aspect.requests.size.should == 1 end - describe '#receive_friend_request' do + describe '#receive_contact_request' do it 'adds a request to pending if it was not sent by user' do - r = Request.instantiate(:to => user.person, :from => friend) + r = Request.instantiate(:to => user.person, :from => person) r.save - user.receive_friend_request(r) + user.receive_contact_request(r) user.reload.pending_requests.should include r end it 'should autoaccept a request the user sent' do - request = user.send_friend_request_to(user2.person, aspect) + request = user.send_contact_request_to(user2.person, aspect) user.contact_for(user2.person).should be_nil - #proc{ - user.receive_request(request.reverse_for(user2), user2.person) - #}.should change(user.reload.friends, :count).by(1) + user.receive_request(request.reverse_for(user2), user2.person) user.contact_for(user2.person).should_not be_nil end end - context 'received a friend request' do + context 'received a contact request' do - let(:request_for_user) {Request.instantiate(:to => user.person, :from => friend)} + let(:request_for_user) {Request.instantiate(:to => user.person, :from => person)} let(:request2_for_user) {Request.instantiate(:to => user.person, :from => person_one)} let(:request_from_myself) {Request.instantiate(:to => user.person, :from => user.person)} before do request_for_user.save - user.receive_request(request_for_user, friend) + user.receive_request(request_for_user, person) user.receive_request(request2_for_user, person_one) user.reload end - it "should delete an accepted friend request" do - proc { user.accept_friend_request(request2_for_user, aspect) }.should change( + it "should delete an accepted contact request" do + proc { user.accept_contact_request(request2_for_user, aspect) }.should change( user.reload.pending_requests, :count ).by(-1) end - it 'should be able to ignore a pending friend request' do - proc { user.ignore_friend_request(request_for_user.id) }.should change( + it 'should be able to ignore a pending contact request' do + proc { user.ignore_contact_request(request_for_user.id) }.should change( user.reload.pending_requests, :count ).by(-1) end - it 'should ignore a friend request from yourself' do + it 'should ignore a contact request from yourself' do reversed_request = request_from_myself.reverse_for(user) user.pending_requests.delete_all user.save - proc { user.receive_friend_request(reversed_request) + proc { user.receive_contact_request(reversed_request) }.should raise_error /request from himself/ end end - it 'should not be able to friend request an existing friend' do + it 'should not be able to contact request an existing contact' do connect_users(user, aspect, user2, aspect2) - proc { user.send_friend_request_to(user2.person, aspect1) }.should raise_error /already friends/ + proc { user.send_contact_request_to(user2.person, aspect1) }.should raise_error /already connected/ end - it 'should not be able to friend request yourself' do - proc { user.send_friend_request_to(nil, aspect) }.should raise_error(RuntimeError, /befriend yourself/) + it 'should not be able to contact request yourself' do + proc { user.send_contact_request_to(nil, aspect) }.should raise_error(RuntimeError, /connect yourself/) end - it 'should send an email on acceptance if a friend request' do + it 'should send an email on acceptance if a contact request' do Request.should_receive(:send_request_accepted) - request = user.send_friend_request_to(user2.person, aspect) + request = user.send_contact_request_to(user2.person, aspect) user.receive_request(request.reverse_for(user2), user2.person) end @@ -100,9 +97,9 @@ describe Diaspora::UserModules::Friending do before do user.pending_requests.empty?.should be true - user.friends.empty?.should be true + user.contacts.empty?.should be true user2.pending_requests.empty?.should be true - user2.friends.empty?.should be true + user2.contacts.empty?.should be true @request = Request.instantiate(:to => user.person, :from => person_one) @request_two = Request.instantiate(:to => user2.person, :from => person_one) @@ -121,16 +118,16 @@ describe Diaspora::UserModules::Friending do before do @received_request = user2.receive @req_three_xml, user.person end - it 'should befriend the user other user on the same pod' do + it 'should connect the user other user on the same pod' do proc { - user2.accept_friend_request @received_request, aspect2 + user2.accept_contact_request @received_request, aspect2 }.should_not change(Person, :count) user2.contact_for(user.person).should_not be_nil end it 'should not delete the ignored user on the same pod' do proc { - user2.ignore_friend_request @received_request.id + user2.ignore_contact_request @received_request.id }.should_not change(Person, :count) user2.contact_for(user.person).should be_nil end @@ -147,30 +144,30 @@ describe Diaspora::UserModules::Friending do @req_to_user2 = user2.receive @req_two_xml, person_one end - describe '#accept_friend_request' do - it 'should both users should befriend the same person' do - user.accept_friend_request @req_to_user, aspect + describe '#accept_contact_request' do + it 'should both users should connect the same person' do + user.accept_contact_request @req_to_user, aspect user.contact_for(person_one).should_not be_nil - user2.accept_friend_request @req_to_user2, aspect2 + user2.accept_contact_request @req_to_user2, aspect2 user2.contact_for(person_one).should_not be_nil end it 'should keep the person around if one of the users rejects him' do - user.accept_friend_request @req_to_user, aspect + user.accept_contact_request @req_to_user, aspect user.contact_for(person_one).should_not be_nil - user2.ignore_friend_request @req_to_user2.id + user2.ignore_contact_request @req_to_user2.id user2.contact_for(person_one).should be_nil end end it 'should keep the person around if the users ignores them' do - user.ignore_friend_request user.pending_requests.first.id + user.ignore_contact_request user.pending_requests.first.id user.contact_for(person_one).should be_nil - user2.ignore_friend_request user2.pending_requests.first.id #@request_two.id + user2.ignore_contact_request user2.pending_requests.first.id #@request_two.id user2.contact_for(person_one).should be_nil end end @@ -181,58 +178,58 @@ describe Diaspora::UserModules::Friending do describe 'a user accepting rejecting multiple people' do before do user.pending_requests.empty?.should be true - user.friends.empty?.should be true + user.contacts.empty?.should be true @request = Request.instantiate(:to => user.person, :from => person_one) @request_two = Request.instantiate(:to => user.person, :from => person_two) end - it "keeps the right counts of friends" do + it "keeps the right counts of contacts" do received_req = user.receive @request.to_diaspora_xml, person_one user.reload.pending_requests.size.should == 1 - user.friends.size.should be 0 + user.contacts.size.should be 0 received_req2 = user.receive @request_two.to_diaspora_xml, person_two user.reload.pending_requests.size.should == 2 - user.friends.size.should be 0 + user.contacts.size.should be 0 - user.accept_friend_request received_req, aspect + user.accept_contact_request received_req, aspect user.reload.pending_requests.size.should == 1 - user.friends.size.should be 1 + user.contacts.size.should be 1 user.contact_for(person_one).should_not be_nil - user.ignore_friend_request received_req2.id + user.ignore_contact_request received_req2.id user.reload.pending_requests.size.should == 0 - user.friends.size.should be 1 + user.contacts.size.should be 1 user.contact_for(person_two).should be_nil end end - describe 'unfriending' do + describe 'disconnecting' do before do connect_users(user, aspect, user2, aspect2) end - it 'should unfriend the other user on the same seed' do + it 'should disconnect the other user on the same seed' do lambda { - user2.unfriend user.person }.should change { - user2.reload.friends.count }.by(-1) + user2.disconnect user.person }.should change { + user2.reload.contacts.count }.by(-1) aspect2.reload.people.count.should == 0 end - it 'is unfriended by another user' do - lambda { user.unfriended_by user2.person }.should change { - user.friends.count }.by(-1) + it 'is disconnected by another user' do + lambda { user.disconnected_by user2.person }.should change { + user.contacts.count }.by(-1) aspect.reload.people.count.should == 0 end - it 'should remove the friend from all aspects they are in' do + it 'should remove the contact from all aspects they are in' do user.add_person_to_aspect(user2.person.id, aspect1.id) aspect.reload.people.count.should == 1 aspect1.reload.people.count.should == 1 - lambda { user.unfriended_by user2.person }.should change { - user.friends.count }.by(-1) + lambda { user.disconnected_by user2.person }.should change { + user.contacts.count }.by(-1) aspect.reload.people.count.should == 0 aspect1.reload.people.count.should == 0 end @@ -242,16 +239,16 @@ describe Diaspora::UserModules::Friending do @message = user.post(:status_message, :message => "hi", :to => aspect.id) end - it "deletes the unfriended user's posts from visible_posts" do + it "deletes the disconnected user's posts from visible_posts" do user2.reload.raw_visible_posts.include?(@message).should be_true - user2.unfriend user.person + user2.disconnect user.person user2.reload.raw_visible_posts.include?(@message).should be_false end - it "deletes the unfriended user's posts from the aspect's posts" do + it "deletes the disconnected user's posts from the aspect's posts" do Post.count.should == 1 aspect2.reload.posts.include?(@message).should be_true - user2.unfriend user.person + user2.disconnect user.person aspect2.reload.posts.include?(@message).should be_false Post.count.should == 1 end diff --git a/spec/models/user/invite_spec.rb b/spec/models/user/invite_spec.rb index a8bc9154f..8b27c0dca 100644 --- a/spec/models/user/invite_spec.rb +++ b/spec/models/user/invite_spec.rb @@ -39,10 +39,10 @@ describe User do end - it 'throws if you try to add someone you"re friends with' do + it 'throws if you try to add someone you"re connected to' do connect_users(inviter, aspect, another_user, wrong_aspect) inviter.reload - proc{inviter.invite_user(:email => another_user.email, :aspect_id => aspect.id)}.should raise_error /already friends/ + proc{inviter.invite_user(:email => another_user.email, :aspect_id => aspect.id)}.should raise_error /already connected/ end end @@ -88,7 +88,7 @@ describe User do invited_user.person.profile.first_name.should == "Bob" end - it 'resolves incoming invitations into friend requests' do + it 'resolves incoming invitations into contact requests' do invited_user.reload.pending_requests.count.should == 1 inviter.reload.pending_requests.count.should == 1 end @@ -101,12 +101,12 @@ describe User do invited_user.reload inviter.reload end - it 'successfully makes invited_user friends with inviter' do + it 'successfully connects invited_user to inviter' do invited_user.contact_for(inviter.person).should_not be_nil invited_user.pending_requests.count.should == 0 end - it 'successfully makes inviter friends with invited_user' do + it 'successfully connects inviter to invited_user' do inviter.contact_for(invited_user.person).should_not be_nil inviter.pending_requests.size.should == 0 end diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 5af4fa15a..47d8eb54b 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -118,7 +118,7 @@ describe User do user.push_to_aspects(post, aspect.id) end - it 'should push a post to friends in all aspects' do + it 'should push a post to contacts in all aspects' do user.should_receive(:push_to_person).exactly(3).times user.push_to_aspects(post, :all) end diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index a436c1bfb..e981b436e 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -97,15 +97,15 @@ describe User do connect_users(user, second_aspect, user2, user2.aspects.first) end - describe '#friends_not_in_aspect' do + describe '#contacts_not_in_aspect' do it 'finds the people who are not in the given aspect' do - people = user.friends_not_in_aspect(first_aspect) + people = user.contacts_not_in_aspect(first_aspect) people.should == [user2.person] end end describe '#person_objects' do - it 'returns "person" objects for all of my friends' do + it 'returns "person" objects for all of my contacts' do people = user.person_objects people.size.should == 2 [user4.person, user2.person].each{ |p| people.should include p } @@ -120,7 +120,7 @@ describe User do end describe '#people_in_aspects' do - it 'should return people objects for a users friend in each aspect' do + it 'should return people objects for a users contact in each aspect' do people = user.people_in_aspects([first_aspect]) people.should == [user4.person] people = user.people_in_aspects([second_aspect]) @@ -137,19 +137,19 @@ describe User do describe '#contact_for_person_id' do it 'returns a contact' do contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect]) - user.friends << contact + user.contacts << contact user.contact_for_person_id(person_one.id).should be_true end it 'returns the correct contact' do contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect]) - user.friends << contact + user.contacts << contact contact2 = Contact.create(:user => user, :person => person_two, :aspects => [aspect]) - user.friends << contact2 + user.contacts << contact2 contact3 = Contact.create(:user => user, :person => person_three, :aspects => [aspect]) - user.friends << contact3 + user.contacts << contact3 user.contact_for_person_id(person_two.id).person.should == person_two end @@ -160,7 +160,7 @@ describe User do it 'returns nil when someone else has contact with the target' do contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect]) - user.friends << contact + user.contacts << contact user2.contact_for_person_id(person_one.id).should be_nil end end diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 6bd70d56c..b02da36b9 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -20,7 +20,7 @@ describe User do connect_users(user, aspect, user2, aspect2) end - it 'should stream only one message to the everyone aspect when a multi-aspected friend posts' do + it 'should stream only one message to the everyone aspect when a multi-aspected contacts posts' do user.add_person_to_aspect(user2.person.id, user.aspects.create(:name => "villains").id) status = user2.post(:status_message, :message => "Users do things", :to => aspect2.id) xml = status.to_diaspora_xml @@ -91,8 +91,8 @@ describe User do aspect.posts.include?(@status_message).should be_true end - it 'should be removed on unfriending' do - user.unfriend(user2.person) + it 'should be removed on disconnecting' do + user.disconnect(user2.person) user.reload user.raw_visible_posts.should_not include @status_message end @@ -101,26 +101,26 @@ describe User do person = user2.person user2.delete - lambda {user.unfriend(person)}.should change(Post, :count).by(-1) + lambda {user.disconnect(person)}.should change(Post, :count).by(-1) end it 'should keep track of user references for one person ' do @status_message.reload @status_message.user_refs.should == 1 - user.unfriend(user2.person) + user.disconnect(user2.person) @status_message.reload @status_message.user_refs.should == 0 end it 'should not override userrefs on receive by another person' do - user3.activate_friend(user2.person, aspect3) + user3.activate_contact(user2.person, aspect3) user3.receive @status_message.to_diaspora_xml, user2.person @status_message.reload @status_message.user_refs.should == 2 - user.unfriend(user2.person) + user.disconnect(user2.person) @status_message.reload @status_message.user_refs.should == 1 end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e444ab64c..2088f76b6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -228,7 +228,7 @@ describe User do end context 'profiles' do - it 'should be able to update their profile and send it to their friends' do + it 'should be able to update their profile and send it to their contacts' do updated_profile = { :first_name => 'bob', :last_name => 'billytown', @@ -245,7 +245,7 @@ describe User do user.aspects.include?(aspect).should == false end - it 'should not delete an aspect with friends' do + it 'should not delete an aspect with contacts' do connect_users(user, aspect, user2, aspect2) aspect.reload proc { user.drop_aspect(aspect) }.should raise_error /Aspect not empty/ @@ -263,8 +263,8 @@ describe User do end describe 'account removal' do - it 'should unfriend everyone' do - user.should_receive(:unfriend_everyone) + it 'should disconnect everyone' do + user.should_receive(:disconnect_everyone) user.destroy end @@ -294,19 +294,19 @@ describe User do end end - describe '#unfriend_everyone' do + describe '#disconnect_everyone' do it 'should send retractions to remote poeple' do user2.delete - user.activate_friend(user2.person, aspect) + user.activate_contact(user2.person, aspect) - user.should_receive(:unfriend).once + user.should_receive(:disconnect).once user.destroy end - it 'should unfriend local people' do + it 'should disconnect local people' do connect_users(user, aspect, user2, aspect2) - lambda {user.destroy}.should change{user2.reload.friends.count}.by(-1) + lambda {user.destroy}.should change{user2.reload.contacts.count}.by(-1) end end end