Get another couple specs green on pg

This commit is contained in:
Raphael Sofaer 2011-06-15 20:30:08 -07:00
parent f0cb2159c7
commit 2d3eeb9c46
3 changed files with 12 additions and 3 deletions

View file

@ -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

View file

@ -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?

View file

@ -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