Skip to content

Commit

Permalink
Display 404 page if tag does not exist.
Browse files Browse the repository at this point in the history
closes #2667
- if tag result is '' 404 instead of rendering an empty page
- added test for /tag/asdf should 404
  • Loading branch information
shindakun committed May 12, 2014
1 parent 10759ed commit eb2fdc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/server/controllers/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ frontendControllers = {
tag: page.meta.filters.tags ? page.meta.filters.tags[0] : ''
});

// If the resulting tag is '' then 404.
if (!result.tag) {
return next();
}
res.render(view, result);
});
});
Expand Down
9 changes: 8 additions & 1 deletion core/test/functional/frontend/error_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ CasperTest.begin('Check frontend route not found (404)', 2, function suite(test)
test.assertEqual(response.status, 404, 'Response status should be 404.');
test.assertSelectorHasText('.error-code', '404');
});
}, true);
}, true);

CasperTest.begin('Check frontend tag route not found (404)', 2, function suite(test) {
casper.thenOpen(url + 'tag/asdf/', function (response) {
test.assertEqual(response.status, 404, 'Response status should be 404.');
test.assertSelectorHasText('.error-code', '404');
});
}, true);

0 comments on commit eb2fdc4

Please sign in to comment.