diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index adcfc5bf7..d5a81e0d7 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -70,7 +70,7 @@ class ConversationsController < ApplicationController def new all_contacts_and_ids = Contact.connection.select_rows( - current_user.contacts.joins(:person => :profile). + current_user.contacts.where(:sharing => true).joins(:person => :profile). select("contacts.id, profiles.first_name, profiles.last_name, people.diaspora_handle").to_sql ).map{|r| {:value => r[0], :name => Person.name_from_attrs(r[1], r[2], r[3]).gsub(/(")/, "'")} } diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index b791c1cfb..b2d68859c 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -18,8 +18,10 @@ describe ConversationsController do response.should be_success end - it "assigns a json list of contacts" do - assigns(:contacts_json).should include(alice.contacts.first.person.name) + it "assigns a json list of contacts that are sharing with the person" do + assigns(:contacts_json).should include(alice.contacts.where(:sharing => true).first.person.name) + alice.contacts << Contact.new(:person_id => eve.person.id, :user_id => alice.id, :sharing => false, :receiving => true) + assigns(:contacts_json).should_not include(alice.contacts.where(:sharing => false).first.person.name) end it "assigns a contact if passed a contact id" do