Allow non-logged-in users to see public photos
This commit is contained in:
parent
9ef0fbfe60
commit
f9a9654c86
2 changed files with 33 additions and 9 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class PhotosController < ApplicationController
|
class PhotosController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!, :except => :show
|
||||||
|
|
||||||
helper_method :parent, :photo, :additional_photos, :next_photo, :previous_photo, :ownership
|
helper_method :parent, :photo, :additional_photos, :next_photo, :previous_photo, :ownership
|
||||||
|
|
||||||
|
|
@ -140,8 +140,14 @@ class PhotosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if photo
|
if user_signed_in?
|
||||||
respond_with photo
|
@photo = current_user.find_visible_shareable_by_id(Photo, params[:id])
|
||||||
|
else
|
||||||
|
@photo = Photo.where(id => params[:id], :public => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if @photo
|
||||||
|
respond_with @photo
|
||||||
else
|
else
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ describe PhotosController do
|
||||||
before do
|
before do
|
||||||
user3 = Factory(:user_with_aspect)
|
user3 = Factory(:user_with_aspect)
|
||||||
@photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id, :public => true)
|
@photo = user3.post(:photo, :user_file => uploaded_photo, :to => user3.aspects.first.id, :public => true)
|
||||||
|
end
|
||||||
|
context "user logged in" do
|
||||||
|
before do
|
||||||
get :show, :id => @photo.to_param
|
get :show, :id => @photo.to_param
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -121,6 +124,21 @@ describe PhotosController do
|
||||||
@controller.ownership.should be_false
|
@controller.ownership.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
context "not logged in" do
|
||||||
|
before do
|
||||||
|
sign_out :user
|
||||||
|
get :show, :id => @photo.to_param
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds" do
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it "assigns the photo" do
|
||||||
|
assigns[:photo].should == @photo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#edit' do
|
describe '#edit' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue