diff --git a/Changelog.md b/Changelog.md index ef74f278a..d4226106b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ ## Bug fixes * Don't focus comment form on 'show n more comments' [#4265](https://github.com/diaspora/diaspora/issues/4265) +* Do not render mobile photo view for none-existing photos [#4194](https://github.com/diaspora/diaspora/issues/4194) ## Features * Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index f28b8cc9a..2d7fb936f 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -7,6 +7,10 @@ class PhotosController < ApplicationController respond_to :html, :json + def show + @photo = Photo.find(params[:id]) + end + def index @post_type = :photos @person = Person.find_by_guid(params[:person_id]) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 0ad68cfd1..af7e076dd 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -163,4 +163,15 @@ describe PhotosController do end end + describe "#show" do + it 'should return 404 for nonexistent stuff on mobile devices' do + expect{get :show, :id => 772831, :format => 'mobile'}.to raise_error ActiveRecord::RecordNotFound + end + + it 'should return 200 for existing stuff on mobile devices' do + get :show, :id => @alices_photo.id, :format => 'mobile' + response.should be_success + end + end + end