fix 500 when viewing a nonexsitaint status message
This commit is contained in:
parent
d202200a88
commit
2784f641ba
3 changed files with 18 additions and 8 deletions
|
|
@ -73,15 +73,19 @@ class StatusMessagesController < ApplicationController
|
|||
|
||||
def show
|
||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||
@object_aspect_ids = @status_message.aspects.map{|a| a.id}
|
||||
if @status_message
|
||||
@object_aspect_ids = @status_message.aspects.map{|a| a.id}
|
||||
|
||||
# mark corresponding notification as read
|
||||
if notification = Notification.where(:recipient_id => current_user.id, :target_id => @status_message.id).first
|
||||
notification.unread = false
|
||||
notification.save
|
||||
# mark corresponding notification as read
|
||||
if notification = Notification.where(:recipient_id => current_user.id, :target_id => @status_message.id).first
|
||||
notification.unread = false
|
||||
notification.save
|
||||
end
|
||||
|
||||
respond_with @status_message
|
||||
else
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
respond_with @status_message
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
= render 'photos/index', :photos => @posts
|
||||
- else
|
||||
#main_stream.stream
|
||||
= render 'shared/stream', :posts => @fakes
|
||||
= render 'shared/stream', :posts => @fakes, :commenting_disabled => @commenting_disabled
|
||||
%a.paginate
|
||||
= t("more")
|
||||
= will_paginate @posts
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ describe StatusMessagesController do
|
|||
note.reload
|
||||
}.should change(note, :unread).from(true).to(false)
|
||||
end
|
||||
|
||||
|
||||
it 'redirects to back if there is no status message' do
|
||||
get :show, :id => 2345
|
||||
response.status.should == 302
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue