From 1b6c33aff5d86e395914ce17ce807c14e86019ed Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Sat, 28 Apr 2012 17:41:22 -0700 Subject: [PATCH] show a user's full profile info if she's on her own page. duh. --- app/assets/javascripts/app/pages/profile.js | 2 -- app/controllers/profiles_controller.rb | 2 +- spec/controllers/profiles_controller_spec.rb | 9 ++++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index 40bf8c2aa..3d4f11b7f 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -24,8 +24,6 @@ app.pages.Profile = app.views.Base.extend({ presenter : function(){ var bio = this.model.get("bio") || '' - console.log(this.defaultPresenter().current_user) - return _.extend(this.defaultPresenter(), {text : this.model && app.helpers.textFormatter(bio, this.model), isOwnProfile : this.isOwnProfile(), diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 8b8f59091..390a99a4a 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -18,7 +18,7 @@ class ProfilesController < ApplicationController public_json = @person.as_api_response(:backbone) extra_json = {} - if(current_user && current_user.contacts.receiving.where(:person_id => @person.id).first) + if(current_user && (current_user.person == @person || current_user.contacts.receiving.where(:person_id => @person.id).first)) extra_json = { :location => @person.profile.location, :birthday => @person.profile.formatted_birthday, diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index b7a457642..42dc6a70b 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -24,9 +24,6 @@ describe ProfilesController do it "returns the user's public information if a user is logged in and the visiting user is not receiving" do sign_in :user, alice - - puts alice.contacts.first.person.inspect - get :show, :id => @user.person.guid, :format => :json response.body.should_not match(/.location./) end @@ -36,6 +33,12 @@ describe ProfilesController do get :show, :id => @user.person.guid, :format => :json response.body.should match(/.location./) end + + it "returns the user's private information if a user is logged in as herself" do + sign_in :user, eve + get :show, :id => @user.person.guid, :format => :json + response.body.should match(/.location./) + end end describe '#edit' do