Don't let googlebot 500 us on the public post page

This commit is contained in:
Raphael Sofaer 2011-08-09 12:26:10 -07:00
parent 23ea0ed462
commit 7f5f696642
3 changed files with 11 additions and 4 deletions

View file

@ -75,8 +75,8 @@ class PublicsController < ApplicationController
@post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first @post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first
end end
#hax to upgrade logged in users who can comment
if @post if @post
#hax to upgrade logged in users who can comment
if user_signed_in? && current_user.find_visible_post_by_id(@post.id) if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
redirect_to post_path(@post) redirect_to post_path(@post)
else else
@ -86,8 +86,8 @@ class PublicsController < ApplicationController
I18n.locale = @person.owner.language I18n.locale = @person.owner.language
respond_to do |format| respond_to do |format|
format.all{ render "#{@post.class.to_s.underscore}", :layout => 'application'}
format.xml{ render :xml => @post.to_diaspora_xml } format.xml{ render :xml => @post.to_diaspora_xml }
format.any{ render "#{@post.class.to_s.underscore}", :layout => 'application'}
end end
else else
flash[:error] = I18n.t('posts.show.not_found') flash[:error] = I18n.t('posts.show.not_found')

View file

@ -66,7 +66,14 @@ describe PublicsController do
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all') status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
get :post, :guid => status.id get :post, :guid => status.id
response.status= 200 response.status.should == 200
end
it 'shows a public photo' do
status = Factory(:status_message_with_photo, :public => true, :author => alice.person)
photo = status.photos.first
get :post, :guid => photo.id
response.status.should == 200
end end
it 'does not show a private post' do it 'does not show a private post' do

View file

@ -78,7 +78,7 @@ end
Factory.define(:status_message_with_photo, :parent => :status_message) do |m| Factory.define(:status_message_with_photo, :parent => :status_message) do |m|
m.sequence(:text) { |n| "There are #{n} ninjas in this photo." } m.sequence(:text) { |n| "There are #{n} ninjas in this photo." }
m.after_build do |m| m.after_build do |m|
p = Factory(:photo, :author => m.author, :status_message => m, :pending => false) p = Factory(:photo, :author => m.author, :status_message => m, :pending => false, :public => m.public)
end end
end end