From 73f224e690cce0a362f388b7d93d5f356d51cbf7 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 24 Feb 2012 21:48:37 -0800 Subject: [PATCH] don't render page-viewer twice; last_post should actually get the last post posted, not the first one --- app/controllers/people_controller.rb | 2 +- public/javascripts/app/router.js | 5 ++--- spec/controllers/people_controller_spec.rb | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 8b9c6348e..4abf12a75 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -110,7 +110,7 @@ class PeopleController < ApplicationController def last_post @person = Person.find_from_guid_or_username(params) - last_post = Post.visible_from_author(@person, current_user).last + last_post = Post.visible_from_author(@person, current_user).order('posts.created_at DESC').first redirect_to post_path(last_post) end diff --git a/public/javascripts/app/router.js b/public/javascripts/app/router.js index 157c0fc81..30d12cc7d 100644 --- a/public/javascripts/app/router.js +++ b/public/javascripts/app/router.js @@ -36,11 +36,10 @@ app.Router = Backbone.Router.extend({ app.page = new app.views.Photos({model : app.photos}).render(); $("#main_stream").html(app.page.el); - }, + }, singlePost : function(id) { - - var page = new app.pages.PostViewer({ id: id }).render(); + var page = new app.pages.PostViewer({ id: id }); $("#container").html(page.el); } }); diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 059c25c72..ea1f832e3 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -84,7 +84,7 @@ describe PeopleController do get :index, :q => "Eug" assigns[:people].map { |x| x.id }.should =~ [@eugene.id, eugene2.id] end - + it "succeeds if there is exactly one match" do get :index, :q => "Korth" assigns[:people].length.should == 1