mirror of
https://github.com/diaspora/diaspora.git
synced 2026-01-10 07:38:10 -05:00
Select distinct people in contacts index
This commit is contained in:
@@ -25,6 +25,7 @@ class ContactsController < ApplicationController
|
||||
format.mobile { @contacts = sort_and_paginate_profiles(@contacts) }
|
||||
format.json {
|
||||
@people = Person.joins(:contacts => :aspect_memberships).
|
||||
select('DISTINCT people.*').
|
||||
where(:contacts => { :user_id => current_user.id },
|
||||
:aspect_memberships => { :aspect_id => params[:aspect_ids] })
|
||||
|
||||
|
||||
@@ -67,6 +67,14 @@ describe ContactsController do
|
||||
get :index
|
||||
save_fixture(html_for("body"), "aspects_manage")
|
||||
end
|
||||
|
||||
it 'does not select duplicate contacts' do
|
||||
aspect = bob.aspects.create(:name => 'hilarious people')
|
||||
aspect.contacts << bob.contact_for(eve.person)
|
||||
get :index, :format => 'json', :aspect_ids => bob.aspect_ids
|
||||
assigns[:people].map{|p| p.id}.uniq.should == assigns[:people].map{|p| p.id}
|
||||
assigns[:people].should == bob.contacts.map(&:person)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#featured' do
|
||||
|
||||
Reference in New Issue
Block a user