Renamed /uploads* endpoints to /images*

refs #10438
This commit is contained in:
Nazar Gargol 2019-02-22 11:22:50 +07:00
parent 62009832fe
commit 44ce2f5359
9 changed files with 24 additions and 24 deletions

View File

@ -44,7 +44,7 @@ export default Component.extend({
_defaultAccept: IMAGE_MIME_TYPES,
_defaultExtensions: IMAGE_EXTENSIONS,
_defaultUploadUrl: '/uploads/',
_defaultUploadUrl: '/images/',
_showUnsplash: false,
// Allowed actions

View File

@ -61,7 +61,7 @@ export default Component.extend({
uploadUrls: null, // [{filename: 'x', url: 'y'}],
// Private
_defaultUploadUrl: '/uploads/',
_defaultUploadUrl: '/images/',
_files: null,
_uploadTrackers: null,

View File

@ -95,7 +95,7 @@
<div class="gh-setting" data-test-setting="icon">
{{#gh-uploader
extensions=iconExtensions
uploadUrl="/uploads/icon/"
uploadUrl="/images/icon/"
onComplete=(action "imageUploaded" "icon")
as |uploader|
}}

View File

@ -111,7 +111,7 @@
<button type="button" {{action "toggleUploadImageModal"}} class="edit-user-image">Edit Picture</button>
{{#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}}

View File

@ -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});
}

View File

@ -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',

View File

@ -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}}`);

View File

@ -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)}}`);

View File

@ -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);