Skip to content

Commit

Permalink
RecordNotFound errors now trigger 404s
Browse files Browse the repository at this point in the history
Exceptions that raise during view rendering do not trigger ActionDispatch's exception handler.
  • Loading branch information
jasoncodes committed Jun 11, 2011
1 parent 0e4ad8e commit a716679
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/posts_controller.rb
@@ -1,4 +1,8 @@
class PostsController < ApplicationController
def show
resource
end

def feed
max_age = 4.hours
response.headers['Cache-Control'] = 'public, max-age=' + max_age.to_i.to_s
Expand Down
7 changes: 7 additions & 0 deletions spec/acceptance/posts_spec.rb
Expand Up @@ -136,4 +136,11 @@
end
end

context 'Posts#show with invalid slug' do
it 'should raise an not found exception' do
lambda do
visit post_path('2011/05/01/invalid')
end.should raise_error(ActiveRecord::RecordNotFound)
end
end
end

0 comments on commit a716679

Please sign in to comment.