fix 500 when viewing a nonexsitaint status message

This commit is contained in:
maxwell 2011-02-11 18:13:01 -08:00
parent d202200a88
commit 2784f641ba
3 changed files with 18 additions and 8 deletions

View file

@ -73,6 +73,7 @@ class StatusMessagesController < ApplicationController
def show def show
@status_message = current_user.find_visible_post_by_id params[:id] @status_message = current_user.find_visible_post_by_id params[:id]
if @status_message
@object_aspect_ids = @status_message.aspects.map{|a| a.id} @object_aspect_ids = @status_message.aspects.map{|a| a.id}
# mark corresponding notification as read # mark corresponding notification as read
@ -82,6 +83,9 @@ class StatusMessagesController < ApplicationController
end end
respond_with @status_message respond_with @status_message
else
redirect_to :back
end
end end
end end

View file

@ -58,7 +58,7 @@
= render 'photos/index', :photos => @posts = render 'photos/index', :photos => @posts
- else - else
#main_stream.stream #main_stream.stream
= render 'shared/stream', :posts => @fakes = render 'shared/stream', :posts => @fakes, :commenting_disabled => @commenting_disabled
%a.paginate %a.paginate
= t("more") = t("more")
= will_paginate @posts = will_paginate @posts

View file

@ -43,6 +43,12 @@ describe StatusMessagesController do
note.reload note.reload
}.should change(note, :unread).from(true).to(false) }.should change(note, :unread).from(true).to(false)
end end
it 'redirects to back if there is no status message' do
get :show, :id => 2345
response.status.should == 302
end
end end
describe '#create' do describe '#create' do