mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Added subdirectory coverage to DynamiRedirectsManager suites
refs https://github.com/TryGhost/Toolbox/issues/139
- These unit tests come directly from equivalent regression tests in Ghost repository - fedbfb3c67/test/regression/site/redirects.test.js
- This changeset covers subdirectory use in incoming request
This commit is contained in:
parent
0daed36366
commit
c0b1ddfd3e
1 changed files with 30 additions and 0 deletions
|
@ -314,4 +314,34 @@ describe('DynamicRedirectManager', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('with subdirectory configuration', function () {
|
||||
let manager;
|
||||
|
||||
beforeEach(function () {
|
||||
manager = new DynamicRedirectManager({
|
||||
permanentMaxAge: 100,
|
||||
getSubdirectoryURL: (pathname) => {
|
||||
return urlJoin('', pathname);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should include the subdirectory', function () {
|
||||
const from = '/my-old-blog-post/';
|
||||
const to = '/revamped-url/';
|
||||
|
||||
manager.addRedirect(from , to, {permanent: true});
|
||||
|
||||
req.url = '/blog/my-old-blog-post/';
|
||||
|
||||
manager.handleRequest(req, res, function next() {
|
||||
should.fail(true, 'next should NOT have been called');
|
||||
});
|
||||
|
||||
should.equal(headers['Cache-Control'], 'public, max-age=100');
|
||||
should.equal(status, 301);
|
||||
should.equal(location, '/blog/revamped-url/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue