diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 659eecf68..fad80aad5 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index db17280af..cfb8506da 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -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 diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index 86c92d5ac..af73677a8 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -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