mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-11 08:43:59 +03:00
Added serializer for redirects.upload
refs: https://github.com/TryGhost/Toolbox/issues/245 - There was only a serializer in place for redirects.download. - Upload was falling through, which means nothing happens by default atm - We want to change this default, so I'm making sure all our routes have serializers declared and tests - Updated the tests and checked the behaviour was the same before and after: - We can't use our new framework here yet because it doesn't support uploads or downloads - Instead, just add simple matching for the body of the responses
This commit is contained in:
parent
28a30835a1
commit
7433378e6a
@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
download(response, apiConfig, frame) {
|
||||
all(response, apiConfig, frame) {
|
||||
frame.response = response;
|
||||
}
|
||||
};
|
||||
|
@ -20,7 +20,29 @@ describe('Redirects API', function () {
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /application\/json/)
|
||||
.expect('Content-Disposition', 'Attachment; filename="redirects.json"')
|
||||
.expect(200);
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
res.body.should.eql([
|
||||
{from: '^/post/[0-9]+/([a-z0-9\\-]+)', to: '/$1'},
|
||||
{permanent: true, from: '/my-old-blog-post/', to: '/revamped-url/'},
|
||||
{permanent: true, from: '/test-params', to: '/result?q=abc'},
|
||||
{from: '^\\/what(\\/?)$', to: '/what-does-god-say'},
|
||||
{from: '^\\/search\\/label\\/([^\\%20]+)$', to: '/tag/$1'},
|
||||
{from: '^\\/topic\\/', to: '/'},
|
||||
{from: '^/resources\\/download(\\/?)$', to: '/shubal-stearns'},
|
||||
{from: '^/(?:capture1|capture2)/([A-Za-z0-9\\-]+)', to: '/$1'},
|
||||
{
|
||||
from: '^\\/[0-9]{4}\\/[0-9]{2}\\/([a-z0-9\\-]+)(\\.html)?(\\/)?$',
|
||||
to: '/$1'
|
||||
},
|
||||
{from: '^/prefix/([a-z0-9\\-]+)?', to: '/blog/$1'},
|
||||
{from: '/^\\/case-insensitive/i', to: '/redirected-insensitive'},
|
||||
{from: '^\\/Case-Sensitive', to: '/redirected-sensitive'},
|
||||
{from: '^\\/Default-Sensitive', to: '/redirected-default'},
|
||||
{from: '/external-url', to: 'https://ghost.org'},
|
||||
{from: '/external-url/(.*)', to: 'https://ghost.org/$1'}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it('upload', function () {
|
||||
@ -35,6 +57,9 @@ describe('Redirects API', function () {
|
||||
.set('Origin', config.get('url'))
|
||||
.attach('redirects', path.join(config.get('paths:contentPath'), 'redirects-init.json'))
|
||||
.expect('Content-Type', /application\/json/)
|
||||
.expect(200);
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
res.body.should.be.empty();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user