From 84bd1fb1fc3ab42af895863bae824ae0e9972a5d Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Mon, 23 Apr 2012 23:31:39 -0700 Subject: [PATCH] return the person json response for profiles to get a correctly formatted name and expected avatar response; fix a jasmine spec around redirection --- app/assets/templates/profile-info.jst.hbs | 4 ++-- app/controllers/profiles_controller.rb | 6 ++++-- spec/controllers/profiles_controller_spec.rb | 2 +- spec/javascripts/app/views/small_frame_view_spec.js | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/templates/profile-info.jst.hbs b/app/assets/templates/profile-info.jst.hbs index 3e6a3fae7..1b9049cfe 100644 --- a/app/assets/templates/profile-info.jst.hbs +++ b/app/assets/templates/profile-info.jst.hbs @@ -1,7 +1,7 @@
-
+

- {{full_name}} + {{name}}

diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index e9b8e303d..b515db975 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -8,11 +8,13 @@ class ProfilesController < ApplicationController respond_to :html, :except => [:show] respond_to :js, :only => :update + # this is terrible because we're actually serving up the associated person here; + # however, this is the effect that we want for now def show - @profile = Person.find_by_guid!(params[:id]).profile + @person = Person.find_by_guid!(params[:id]) respond_to do |format| - format.json { render :json => @profile } + format.json { render :json => @person.as_api_response(:backbone) } end end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index f53726267..10165d6fb 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -13,7 +13,7 @@ describe ProfilesController do describe '#show' do it "returns the user as json" do get :show, :id => @user.person.guid, :format => :json - response.body.should == @user.person.profile.to_json + JSON.parse(response.body).should == JSON.parse(@user.person.as_api_response(:backbone).to_json) end end diff --git a/spec/javascripts/app/views/small_frame_view_spec.js b/spec/javascripts/app/views/small_frame_view_spec.js index 8760bf8ab..167668be0 100644 --- a/spec/javascripts/app/views/small_frame_view_spec.js +++ b/spec/javascripts/app/views/small_frame_view_spec.js @@ -21,6 +21,7 @@ describe("app.views.SmallFrame", function(){ describe("redirecting to a post", function(){ beforeEach(function(){ + app.page = {editMode : false} app.router = new app.Router() spyOn(app.router, "navigate") })