diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 5129b8c87..5d6b69373 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -59,7 +59,7 @@ class AspectsController < ApplicationController def show @aspect = current_user.aspect_by_id params[:id] - @contacts = current_user.contacts(:pending => false) + @contacts = current_user.contacts.where(:pending => false) unless @aspect render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @@ -78,7 +78,7 @@ class AspectsController < ApplicationController def manage @aspect = :manage - @contacts = current_user.contacts(:pending => false) + @contacts = current_user.contacts.where(:pending => false) @remote_requests = Request.hashes_for_person(current_user.person) @aspect_hashes = hashes_for_aspects @aspects, @contacts end diff --git a/app/models/user.rb b/app/models/user.rb index ffbbd09de..c751331f9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -299,7 +299,7 @@ class User params[:image_url_small] = params[:photo].url(:thumb_small) end if self.person.profile.update_attributes(params) - push_to_people profile, self.person_objects(contacts(:pending => false)) + push_to_people profile, self.person_objects(contacts.where(:pending => false)) true else false diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 5346d31c7..41c3d43b8 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -72,6 +72,16 @@ describe AspectsController do assigns(:aspect_contacts).first[:person].should == achash[:person] assigns(:posts).should == [] end + it "assigns contacts to only non-pending" do + @user.contacts.count.should == 1 + @user.send_contact_request_to(make_user.person, @aspect) + @user.contacts.count.should == 2 + + get :show, 'id' => @aspect.id.to_s + contacts = assigns(:contacts) + contacts.count.should == 1 + contacts.first.should == @contact + end it "paginates" do 16.times { |i| @user2.post(:status_message, :to => @aspect2.id, :message => "hi #{i}") } @@ -121,6 +131,16 @@ describe AspectsController do get :manage assigns(:remote_requests).should be_empty end + it "assigns contacts to only non-pending" do + @user.contacts.count.should == 1 + @user.send_contact_request_to(make_user.person, @aspect) + @user.contacts.count.should == 2 + + get :manage + contacts = assigns(:contacts) + contacts.count.should == 1 + contacts.first.should == @contact + end context "when the user has pending requests" do before do requestor = make_user diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e33d004e8..8d72c8f9b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -262,6 +262,15 @@ describe User do user.update_profile(params).should be_true user.reload.profile.image_url.should == "http://clown.com" end + it "only pushes to non-pending contacts" do + connect_users(user, aspect, user2, aspect2) + user.contacts.count.should == 1 + user.send_contact_request_to(make_user.person, aspect) + user.contacts.count.should == 2 + + user.should_receive(:push_to_person).once + user.update_profile(@params).should be_true + end context 'passing in a photo' do before do fixture_filename = 'button.png'