From ee49fb3547b56abb79df30f8b0a3a812ac468b38 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 13 May 2011 16:49:37 -0700 Subject: [PATCH] no more n-query in the view problem --- app/controllers/contacts_controller.rb | 2 +- features/connects_users.feature | 1 - spec/controllers/contacts_controller_spec.rb | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 6dcad56dc..8336f7f70 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -37,7 +37,7 @@ class ContactsController < ApplicationController end def sharing - @contacts = current_user.contacts.sharing + @contacts = current_user.contacts.sharing.includes(:aspects) render :layout => false end end diff --git a/features/connects_users.feature b/features/connects_users.feature index 7d12f75c7..3d0ce375f 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -112,7 +112,6 @@ Feature: sending and receiving requests And I am on "bob@bob.bob"'s page - Then I should not see "Add to aspect" Then I should see "In 2 aspects" Then I should see "Mention" Then I should see "Message" diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index c371a2d51..d8d598cb0 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -67,6 +67,11 @@ describe ContactsController do response.should be_success end + it 'eager loads the aspects' do + get :sharing + assigns[:contacts].first.aspects.loaded?.should be_true + end + it "assigns only the people sharing with you with 'share_with' flag" do get :sharing, :id => 'share_with' assigns[:contacts].to_set.should == alice.contacts.sharing.to_set