From 51e129b5c638df061b4b58687033426ac5f24572 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 9 Feb 2011 16:05:02 -0800 Subject: [PATCH] Don't call hashes_for_people if it is a json request in search --- app/controllers/people_controller.rb | 3 ++- spec/controllers/people_controller_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index b93b353ab..677f3bc25 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -14,7 +14,8 @@ class PeopleController < ApplicationController limit = params[:limit] || 15 @people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => limit - @hashes = hashes_for_people(@people, @aspects) + @hashes = hashes_for_people(@people, @aspects) unless request.format == :json + #only do it if it is an email address if params[:q].try(:match, Devise.email_regexp) webfinger(params[:q]) diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 5eba63cf4..dd305f184 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -36,6 +36,14 @@ describe PeopleController do get :index, :q => "Korth", :format => 'json' response.body.should == [@korth].to_json end + it 'does not set @hashes in a json request' do + get :index, :q => "Korth", :format => 'json' + assigns[:hashes].should be_nil + end + it 'sets @hashes in an html request' do + get :index, :q => "Korth" + assigns[:hashes].should_not be_nil + end it "assigns people" do eugene2 = Factory.create(:person, :profile => Factory.build(:profile, :first_name => "Eugene",