From 44ce2f5359f3c02f08e7fe0953db6fd54ef1e998 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 22 Feb 2019 11:22:50 +0700 Subject: [PATCH] Renamed /uploads* endpoints to /images* refs #10438 --- ghost/admin/app/components/gh-image-uploader.js | 2 +- ghost/admin/app/components/gh-uploader.js | 2 +- ghost/admin/app/templates/settings/general.hbs | 2 +- ghost/admin/app/templates/staff/user.hbs | 2 +- ghost/admin/mirage/config/uploads.js | 4 ++-- .../admin/tests/acceptance/settings/general-test.js | 6 +++--- .../integration/components/gh-file-uploader-test.js | 12 ++++++------ .../integration/components/gh-image-uploader-test.js | 10 +++++----- .../tests/integration/components/gh-uploader-test.js | 8 ++++---- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ghost/admin/app/components/gh-image-uploader.js b/ghost/admin/app/components/gh-image-uploader.js index d5ec51113a..eefb7dd265 100644 --- a/ghost/admin/app/components/gh-image-uploader.js +++ b/ghost/admin/app/components/gh-image-uploader.js @@ -44,7 +44,7 @@ export default Component.extend({ _defaultAccept: IMAGE_MIME_TYPES, _defaultExtensions: IMAGE_EXTENSIONS, - _defaultUploadUrl: '/uploads/', + _defaultUploadUrl: '/images/', _showUnsplash: false, // Allowed actions diff --git a/ghost/admin/app/components/gh-uploader.js b/ghost/admin/app/components/gh-uploader.js index e4cdcdbab4..912434a073 100644 --- a/ghost/admin/app/components/gh-uploader.js +++ b/ghost/admin/app/components/gh-uploader.js @@ -61,7 +61,7 @@ export default Component.extend({ uploadUrls: null, // [{filename: 'x', url: 'y'}], // Private - _defaultUploadUrl: '/uploads/', + _defaultUploadUrl: '/images/', _files: null, _uploadTrackers: null, diff --git a/ghost/admin/app/templates/settings/general.hbs b/ghost/admin/app/templates/settings/general.hbs index bed60ae243..68767657ce 100644 --- a/ghost/admin/app/templates/settings/general.hbs +++ b/ghost/admin/app/templates/settings/general.hbs @@ -95,7 +95,7 @@
{{#gh-uploader extensions=iconExtensions - uploadUrl="/uploads/icon/" + uploadUrl="/images/icon/" onComplete=(action "imageUploaded" "icon") as |uploader| }} diff --git a/ghost/admin/app/templates/staff/user.hbs b/ghost/admin/app/templates/staff/user.hbs index 09b4af1b78..0828399467 100644 --- a/ghost/admin/app/templates/staff/user.hbs +++ b/ghost/admin/app/templates/staff/user.hbs @@ -111,7 +111,7 @@ {{#if showUploadImageModal}} {{gh-fullscreen-modal "upload-image" - model=(hash model=user imageProperty="profileImage" uploadUrl="/uploads/profile-image") + model=(hash model=user imageProperty="profileImage" uploadUrl="/images/profile-image") close=(action "toggleUploadImageModal") modifier="action wide"}} {{/if}} diff --git a/ghost/admin/mirage/config/uploads.js b/ghost/admin/mirage/config/uploads.js index 911123ebf6..6d1bb213fd 100644 --- a/ghost/admin/mirage/config/uploads.js +++ b/ghost/admin/mirage/config/uploads.js @@ -12,6 +12,6 @@ const fileUploadResponse = function (db, {requestBody}) { }; export default function mockUploads(server) { - server.post('/uploads/', fileUploadResponse, 200, {timing: 100}); - server.post('/uploads/icon/', fileUploadResponse, 200, {timing: 100}); + server.post('/images/', fileUploadResponse, 200, {timing: 100}); + server.post('/images/icon/', fileUploadResponse, 200, {timing: 100}); } diff --git a/ghost/admin/tests/acceptance/settings/general-test.js b/ghost/admin/tests/acceptance/settings/general-test.js index 89f8247015..07140247aa 100644 --- a/ghost/admin/tests/acceptance/settings/general-test.js +++ b/ghost/admin/tests/acceptance/settings/general-test.js @@ -130,7 +130,7 @@ describe('Acceptance: Settings - General', function () { ).to.not.exist; // failed upload shows error - this.server.post('/uploads/icon/', function () { + this.server.post('/images/icon/', function () { return { errors: [{ errorType: 'ValidationError', @@ -199,7 +199,7 @@ describe('Acceptance: Settings - General', function () { ).to.not.exist; // failed upload shows error - this.server.post('/uploads/', function () { + this.server.post('/images/', function () { return { errors: [{ errorType: 'ValidationError', @@ -268,7 +268,7 @@ describe('Acceptance: Settings - General', function () { ).to.not.exist; // failed upload shows error - this.server.post('/uploads/', function () { + this.server.post('/images/', function () { return { errors: [{ errorType: 'ValidationError', diff --git a/ghost/admin/tests/integration/components/gh-file-uploader-test.js b/ghost/admin/tests/integration/components/gh-file-uploader-test.js index dff3cb87a8..92bc17ad35 100644 --- a/ghost/admin/tests/integration/components/gh-file-uploader-test.js +++ b/ghost/admin/tests/integration/components/gh-file-uploader-test.js @@ -18,13 +18,13 @@ const notificationsStub = Service.extend({ }); const stubSuccessfulUpload = function (server, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"']; }, delay); }; const stubFailedUpload = function (server, code, error, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [code, {'Content-Type': 'application/json'}, JSON.stringify({ errors: [{ errorType: error, @@ -41,7 +41,7 @@ describe('Integration: Component: gh-file-uploader', function () { beforeEach(function () { server = new Pretender(); - this.set('uploadUrl', '/ghost/api/v2/admin/uploads/'); + this.set('uploadUrl', '/ghost/api/v2/admin/images/'); this.owner.register('service:notifications', notificationsStub); }); @@ -86,7 +86,7 @@ describe('Integration: Component: gh-file-uploader', function () { await fileUpload('input[type="file"]', ['test'], {name: 'test.csv'}); expect(server.handledRequests.length).to.equal(1); - expect(server.handledRequests[0].url).to.equal('/ghost/api/v2/admin/uploads/'); + expect(server.handledRequests[0].url).to.equal('/ghost/api/v2/admin/images/'); }); it('fires uploadSuccess action on successful upload', async function () { @@ -185,7 +185,7 @@ describe('Integration: Component: gh-file-uploader', function () { }); it('handles file too large error directly from the web server', async function () { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [413, {}, '']; }); await render(hbs`{{gh-file-uploader url=uploadUrl}}`); @@ -205,7 +205,7 @@ describe('Integration: Component: gh-file-uploader', function () { }); it('handles unknown failure', async function () { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [500, {'Content-Type': 'application/json'}, '']; }); await render(hbs`{{gh-file-uploader url=uploadUrl}}`); diff --git a/ghost/admin/tests/integration/components/gh-image-uploader-test.js b/ghost/admin/tests/integration/components/gh-image-uploader-test.js index 344fe13728..2524689fe8 100644 --- a/ghost/admin/tests/integration/components/gh-image-uploader-test.js +++ b/ghost/admin/tests/integration/components/gh-image-uploader-test.js @@ -29,13 +29,13 @@ const sessionStub = Service.extend({ }); const stubSuccessfulUpload = function (server, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"']; }, delay); }; const stubFailedUpload = function (server, code, error, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [code, {'Content-Type': 'application/json'}, JSON.stringify({ errors: [{ errorType: error, @@ -84,7 +84,7 @@ describe('Integration: Component: gh-image-uploader', function () { await fileUpload('input[type="file"]', ['test'], {name: 'test.png'}); expect(server.handledRequests.length).to.equal(1); - expect(server.handledRequests[0].url).to.equal('/ghost/api/v2/admin/uploads/'); + expect(server.handledRequests[0].url).to.equal('/ghost/api/v2/admin/images/'); expect(server.handledRequests[0].requestHeaders.Authorization).to.be.undefined; }); @@ -183,7 +183,7 @@ describe('Integration: Component: gh-image-uploader', function () { }); it('handles file too large error directly from the web server', async function () { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [413, {}, '']; }); await render(hbs`{{gh-image-uploader image=image update=(action update)}}`); @@ -203,7 +203,7 @@ describe('Integration: Component: gh-image-uploader', function () { }); it('handles unknown failure', async function () { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [500, {'Content-Type': 'application/json'}, '']; }); await render(hbs`{{gh-image-uploader image=image update=(action update)}}`); diff --git a/ghost/admin/tests/integration/components/gh-uploader-test.js b/ghost/admin/tests/integration/components/gh-uploader-test.js index e6df6ca819..057ba7e3b8 100644 --- a/ghost/admin/tests/integration/components/gh-uploader-test.js +++ b/ghost/admin/tests/integration/components/gh-uploader-test.js @@ -9,13 +9,13 @@ import {run} from '@ember/runloop'; import {setupRenderingTest} from 'ember-mocha'; const stubSuccessfulUpload = function (server, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"']; }, delay); }; const stubFailedUpload = function (server, code, error, delay = 0) { - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { return [code, {'Content-Type': 'application/json'}, JSON.stringify({ errors: [{ errorType: error, @@ -51,7 +51,7 @@ describe('Integration: Component: gh-uploader', function () { let [lastRequest] = server.handledRequests; expect(server.handledRequests.length).to.equal(1); - expect(lastRequest.url).to.equal('/ghost/api/v2/admin/uploads/'); + expect(lastRequest.url).to.equal('/ghost/api/v2/admin/images/'); // requestBody is a FormData object // this will fail in anything other than Chrome and Firefox // https://developer.mozilla.org/en-US/docs/Web/API/FormData#Browser_compatibility @@ -136,7 +136,7 @@ describe('Integration: Component: gh-uploader', function () { it('onComplete returns results in same order as selected', async function () { // first request has a delay to simulate larger file - server.post('/ghost/api/v2/admin/uploads/', function () { + server.post('/ghost/api/v2/admin/images/', function () { // second request has no delay to simulate small file stubSuccessfulUpload(server, 0);