only display contacts you are sharing with in aspect edit panes
This commit is contained in:
parent
0db8541f6e
commit
7e838fc778
3 changed files with 17 additions and 2 deletions
|
|
@ -108,9 +108,9 @@ class AspectsController < ApplicationController
|
|||
@contacts_in_aspect = @aspect.contacts.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name }
|
||||
c = Contact.arel_table
|
||||
if @contacts_in_aspect.empty?
|
||||
@contacts_not_in_aspect = current_user.contacts.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name }
|
||||
@contacts_not_in_aspect = current_user.contacts.receiving.includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name }
|
||||
else
|
||||
@contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name }
|
||||
@contacts_not_in_aspect = current_user.contacts.receiving.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:person => :profile).all.sort! { |x, y| x.person.name <=> y.person.name }
|
||||
end
|
||||
|
||||
@contacts = @contacts_in_aspect + @contacts_not_in_aspect
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ class Contact < ActiveRecord::Base
|
|||
where(:sharing => true)
|
||||
}
|
||||
|
||||
scope :receiving, lambda {
|
||||
where(:receiving => true)
|
||||
}
|
||||
|
||||
def dispatch_request
|
||||
request = self.generate_request
|
||||
Postzord::Dispatch.new(self.user, request).post
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ describe Contact do
|
|||
}.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'receiving' do
|
||||
it 'returns contacts with sharing true' do
|
||||
lambda {
|
||||
alice.contacts.create!(:receiving => true, :person => Factory(:person))
|
||||
alice.contacts.create!(:receiving => false, :person => Factory(:person))
|
||||
}.should change{
|
||||
Contact.receiving.count
|
||||
}.by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#contacts' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue