Commit 71631540 authored by Stephan Schulz's avatar Stephan Schulz

Limit allowed contacts for sending messages to, to the ones that are sharing with you.

parent 47dbced6
......@@ -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(", 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(/(")/, "'")} }
......@@ -18,8 +18,10 @@ describe ConversationsController do
response.should be_success
it "assigns a json list of contacts" do
assigns(:contacts_json).should include(
it "assigns a json list of contacts that are sharing with the person" do
assigns(:contacts_json).should include(alice.contacts.where(:sharing => true)
alice.contacts << =>, :user_id =>, :sharing => false, :receiving => true)
assigns(:contacts_json).should_not include(alice.contacts.where(:sharing => false)
it "assigns a contact if passed a contact id" do
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment