redirect to sign in page from photo#show on a private photo when user isn't signed in
This commit is contained in:
parent
5d08bddb5b
commit
b3142ac208
2 changed files with 9 additions and 1 deletions
|
|
@ -149,8 +149,10 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
if @photo
|
if @photo
|
||||||
respond_with @photo
|
respond_with @photo
|
||||||
else
|
elsif user_signed_in?
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
|
else
|
||||||
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,12 @@ describe PhotosController do
|
||||||
get :show, :id => @photo.to_param
|
get :show, :id => @photo.to_param
|
||||||
response.should redirect_to(aspects_path)
|
response.should redirect_to(aspects_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'redirects to the sign in page if not logged in' do
|
||||||
|
controller.stub(:user_signed_in?).and_return(false) #sign_out :user doesn't work
|
||||||
|
get :show, :id => @photo.to_param
|
||||||
|
response.should redirect_to new_user_session_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "public photo" do
|
context "public photo" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue