sort contacts by name, not by a potentially nil field
This commit is contained in:
parent
4ff67b0200
commit
43315e14f9
2 changed files with 5 additions and 2 deletions
|
|
@ -104,7 +104,7 @@ class AspectsController < ApplicationController
|
|||
|
||||
def edit
|
||||
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => {:person => :profile}).first
|
||||
@contacts = current_user.contacts.includes(:person => :profile).all.sort!{|x, y| x.person.profile.first_name <=> y.person.profile.first_name }.reverse!
|
||||
@contacts = current_user.contacts.includes(:person => :profile).all.sort!{|x, y| x.person.name <=> y.person.name}.reverse!
|
||||
unless @aspect
|
||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
|
|
|
|||
|
|
@ -287,6 +287,9 @@ describe AspectsController do
|
|||
before do
|
||||
@bob = bob
|
||||
@eve = eve
|
||||
@eve.profile.first_name = nil
|
||||
@eve.profile.save
|
||||
@eve.save
|
||||
end
|
||||
it 'renders' do
|
||||
get :edit, :id => @alices_aspect_1.id
|
||||
|
|
@ -297,7 +300,7 @@ describe AspectsController do
|
|||
connect_users(@alice, @alices_aspect_1, @eve, @eve.aspects.first)
|
||||
|
||||
get :edit, :id => @alices_aspect_1.id
|
||||
assigns[:contacts].should == [@alice.contact_for(@bob.person), @alice.contact_for(@eve.person)]
|
||||
assigns[:contacts].should == [@alice.contact_for(@eve.person), @alice.contact_for(@bob.person)]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue