redirect to the 404 page if the content entry does not exist
did
committed Feb 17, 2015
commit 97c1bb40f29cb022ab9ef612b406c86fc846db57
Showing 2
changed files with
15 additions
and 9 deletions
locomotive/steam/middlewares/templatized_page.rb b/lib/locomotive/steam/middlewares/templatized_page.rb
+1
-2
| @@ | @@ -28,8 +28,7 @@ module Locomotive::Steam |
| # log it | |
| log "Found content entry: #{entry._label}" | |
| else | |
| - | # force the rendering of the 404 page |
| - | env['steam.page'] = nil |
| + | redirect_to '/404', 302 |
| end | |
| end | |
spec/integration/server/basic_spec.rb
+14
-7
| @@ | @@ -14,7 +14,13 @@ describe Locomotive::Steam::Server do |
| expect(last_response.body).to match(/Upcoming events/) | |
| end | |
| - | describe 'Page not found' do |
| + | it 'shows an inner page' do |
| + | get '/about-us/jane-doe' |
| + | expect(last_response.body).to include '<link href="/stylesheets/application.css"' |
| + | expect(last_response.body).to include 'Lorem ipsum dolor sit amet' |
| + | end |
| + | |
| + | describe 'page not found' do |
| it 'shows the 404 page' do | |
| get '/void' | |
| @@ | @@ -30,12 +36,6 @@ describe Locomotive::Steam::Server do |
| end | |
| - | it 'shows content' do |
| - | get '/about-us/jane-doe' |
| - | expect(last_response.body).to include '<link href="/stylesheets/application.css"' |
| - | expect(last_response.body).to include 'Lorem ipsum dolor sit amet' |
| - | end |
| - | |
| describe 'snippets' do | |
| it 'includes a basic snippet' do | |
| @@ | @@ -63,6 +63,13 @@ describe Locomotive::Steam::Server do |
| expect(last_response.body).to include 'Leader: Eddie' | |
| end | |
| + | it 'redirects to the 404 if it does not match a content entry' do |
| + | get '/songs/unknown' |
| + | expect(last_response).to be_redirect |
| + | follow_redirect! |
| + | expect(last_response.status).to eq(404) |
| + | end |
| + | |
| end | |
| describe 'translations' do | |