From 175908e079cd4b57a6c67b3ee9fa39e33ea6e262 Mon Sep 17 00:00:00 2001 From: Tamas Laszlo Fabian Date: Mon, 24 Jun 2013 15:23:57 +0200 Subject: [PATCH 1/2] Return 404 for nonexistent photo on mobiles --- app/controllers/photos_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) 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]) From d59648504d1f97cce604c2e2f2325b0294e6f5ce Mon Sep 17 00:00:00 2001 From: Tamas Laszlo Fabian Date: Mon, 24 Jun 2013 15:37:17 +0200 Subject: [PATCH 2/2] Added test to avoid regression --- spec/controllers/photos_controller_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) 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