From 2d3eeb9c46e9b2b5c70bb891bdbdb5b5772d48d6 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 15 Jun 2011 20:30:08 -0700 Subject: [PATCH] Get another couple specs green on pg --- app/controllers/conversations_controller.rb | 9 +++++++-- lib/diaspora/user/connecting.rb | 4 ++++ spec/models/contact_spec.rb | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index 24c1fca3a..e6a4e09f9 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -58,12 +58,17 @@ class ConversationsController < ApplicationController def new all_contacts_and_ids = Contact.connection.execute(current_user.contacts.joins(:person => :profile ).select("contacts.id, profiles.first_name, profiles.last_name, people.diaspora_handle").to_sql).map do |r| - {:value => r[0], - :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} + person_json_from_row r end @contacts_json = all_contacts_and_ids.to_json.gsub!(/(")/, '\\"') @contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id] render :layout => false end + def person_json_from_row r + r = [r["id"], r["first_name"], r["last_name"], r["diaspora_handle"]] if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) + {:value => r[0], + :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} + end + end diff --git a/lib/diaspora/user/connecting.rb b/lib/diaspora/user/connecting.rb index 3c083f821..668ab2709 100644 --- a/lib/diaspora/user/connecting.rb +++ b/lib/diaspora/user/connecting.rb @@ -5,6 +5,10 @@ module Diaspora module UserModules module Connecting + # This will create a contact on the side of the sharer and the sharee. + # @param [Person] person The person to start sharing with. + # @param [Aspect] aspect The aspect to add them to. + # @return [Contact] The newly made contact for the passed in person. def share_with(person, aspect) contact = self.contacts.find_or_initialize_by_person_id(person.id) unless contact.receiving? diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 5f89c84c3..a63afb92d 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -98,7 +98,7 @@ describe Contact do end it "returns the target local user's contacts that are in the same aspect" do - @contact.contacts.map{|p| p.id}.should == [@eve.person].concat(@people1).map{|p| p.id} + @contact.contacts.map{|p| p.id}.should =~ [@eve.person].concat(@people1).map{|p| p.id} end it 'returns nothing if contacts_visible is false in that aspect' do