mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
parent
62009832fe
commit
44ce2f5359
@ -44,7 +44,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
_defaultAccept: IMAGE_MIME_TYPES,
|
_defaultAccept: IMAGE_MIME_TYPES,
|
||||||
_defaultExtensions: IMAGE_EXTENSIONS,
|
_defaultExtensions: IMAGE_EXTENSIONS,
|
||||||
_defaultUploadUrl: '/uploads/',
|
_defaultUploadUrl: '/images/',
|
||||||
_showUnsplash: false,
|
_showUnsplash: false,
|
||||||
|
|
||||||
// Allowed actions
|
// Allowed actions
|
||||||
|
@ -61,7 +61,7 @@ export default Component.extend({
|
|||||||
uploadUrls: null, // [{filename: 'x', url: 'y'}],
|
uploadUrls: null, // [{filename: 'x', url: 'y'}],
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
_defaultUploadUrl: '/uploads/',
|
_defaultUploadUrl: '/images/',
|
||||||
_files: null,
|
_files: null,
|
||||||
_uploadTrackers: null,
|
_uploadTrackers: null,
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
<div class="gh-setting" data-test-setting="icon">
|
<div class="gh-setting" data-test-setting="icon">
|
||||||
{{#gh-uploader
|
{{#gh-uploader
|
||||||
extensions=iconExtensions
|
extensions=iconExtensions
|
||||||
uploadUrl="/uploads/icon/"
|
uploadUrl="/images/icon/"
|
||||||
onComplete=(action "imageUploaded" "icon")
|
onComplete=(action "imageUploaded" "icon")
|
||||||
as |uploader|
|
as |uploader|
|
||||||
}}
|
}}
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
<button type="button" {{action "toggleUploadImageModal"}} class="edit-user-image">Edit Picture</button>
|
<button type="button" {{action "toggleUploadImageModal"}} class="edit-user-image">Edit Picture</button>
|
||||||
{{#if showUploadImageModal}}
|
{{#if showUploadImageModal}}
|
||||||
{{gh-fullscreen-modal "upload-image"
|
{{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")
|
close=(action "toggleUploadImageModal")
|
||||||
modifier="action wide"}}
|
modifier="action wide"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -12,6 +12,6 @@ const fileUploadResponse = function (db, {requestBody}) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function mockUploads(server) {
|
export default function mockUploads(server) {
|
||||||
server.post('/uploads/', fileUploadResponse, 200, {timing: 100});
|
server.post('/images/', fileUploadResponse, 200, {timing: 100});
|
||||||
server.post('/uploads/icon/', fileUploadResponse, 200, {timing: 100});
|
server.post('/images/icon/', fileUploadResponse, 200, {timing: 100});
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ describe('Acceptance: Settings - General', function () {
|
|||||||
).to.not.exist;
|
).to.not.exist;
|
||||||
|
|
||||||
// failed upload shows error
|
// failed upload shows error
|
||||||
this.server.post('/uploads/icon/', function () {
|
this.server.post('/images/icon/', function () {
|
||||||
return {
|
return {
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: 'ValidationError',
|
errorType: 'ValidationError',
|
||||||
@ -199,7 +199,7 @@ describe('Acceptance: Settings - General', function () {
|
|||||||
).to.not.exist;
|
).to.not.exist;
|
||||||
|
|
||||||
// failed upload shows error
|
// failed upload shows error
|
||||||
this.server.post('/uploads/', function () {
|
this.server.post('/images/', function () {
|
||||||
return {
|
return {
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: 'ValidationError',
|
errorType: 'ValidationError',
|
||||||
@ -268,7 +268,7 @@ describe('Acceptance: Settings - General', function () {
|
|||||||
).to.not.exist;
|
).to.not.exist;
|
||||||
|
|
||||||
// failed upload shows error
|
// failed upload shows error
|
||||||
this.server.post('/uploads/', function () {
|
this.server.post('/images/', function () {
|
||||||
return {
|
return {
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: 'ValidationError',
|
errorType: 'ValidationError',
|
||||||
|
@ -18,13 +18,13 @@ const notificationsStub = Service.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const stubSuccessfulUpload = function (server, delay = 0) {
|
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"'];
|
return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"'];
|
||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const stubFailedUpload = function (server, code, error, delay = 0) {
|
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({
|
return [code, {'Content-Type': 'application/json'}, JSON.stringify({
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: error,
|
errorType: error,
|
||||||
@ -41,7 +41,7 @@ describe('Integration: Component: gh-file-uploader', function () {
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
server = new Pretender();
|
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);
|
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'});
|
await fileUpload('input[type="file"]', ['test'], {name: 'test.csv'});
|
||||||
|
|
||||||
expect(server.handledRequests.length).to.equal(1);
|
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 () {
|
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 () {
|
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, {}, ''];
|
return [413, {}, ''];
|
||||||
});
|
});
|
||||||
await render(hbs`{{gh-file-uploader url=uploadUrl}}`);
|
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 () {
|
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'}, ''];
|
return [500, {'Content-Type': 'application/json'}, ''];
|
||||||
});
|
});
|
||||||
await render(hbs`{{gh-file-uploader url=uploadUrl}}`);
|
await render(hbs`{{gh-file-uploader url=uploadUrl}}`);
|
||||||
|
@ -29,13 +29,13 @@ const sessionStub = Service.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const stubSuccessfulUpload = function (server, delay = 0) {
|
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"'];
|
return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"'];
|
||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const stubFailedUpload = function (server, code, error, delay = 0) {
|
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({
|
return [code, {'Content-Type': 'application/json'}, JSON.stringify({
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: error,
|
errorType: error,
|
||||||
@ -84,7 +84,7 @@ describe('Integration: Component: gh-image-uploader', function () {
|
|||||||
await fileUpload('input[type="file"]', ['test'], {name: 'test.png'});
|
await fileUpload('input[type="file"]', ['test'], {name: 'test.png'});
|
||||||
|
|
||||||
expect(server.handledRequests.length).to.equal(1);
|
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;
|
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 () {
|
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, {}, ''];
|
return [413, {}, ''];
|
||||||
});
|
});
|
||||||
await render(hbs`{{gh-image-uploader image=image update=(action update)}}`);
|
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 () {
|
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'}, ''];
|
return [500, {'Content-Type': 'application/json'}, ''];
|
||||||
});
|
});
|
||||||
await render(hbs`{{gh-image-uploader image=image update=(action update)}}`);
|
await render(hbs`{{gh-image-uploader image=image update=(action update)}}`);
|
||||||
|
@ -9,13 +9,13 @@ import {run} from '@ember/runloop';
|
|||||||
import {setupRenderingTest} from 'ember-mocha';
|
import {setupRenderingTest} from 'ember-mocha';
|
||||||
|
|
||||||
const stubSuccessfulUpload = function (server, delay = 0) {
|
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"'];
|
return [200, {'Content-Type': 'application/json'}, '"/content/images/test.png"'];
|
||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const stubFailedUpload = function (server, code, error, delay = 0) {
|
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({
|
return [code, {'Content-Type': 'application/json'}, JSON.stringify({
|
||||||
errors: [{
|
errors: [{
|
||||||
errorType: error,
|
errorType: error,
|
||||||
@ -51,7 +51,7 @@ describe('Integration: Component: gh-uploader', function () {
|
|||||||
|
|
||||||
let [lastRequest] = server.handledRequests;
|
let [lastRequest] = server.handledRequests;
|
||||||
expect(server.handledRequests.length).to.equal(1);
|
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
|
// requestBody is a FormData object
|
||||||
// this will fail in anything other than Chrome and Firefox
|
// this will fail in anything other than Chrome and Firefox
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/FormData#Browser_compatibility
|
// 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 () {
|
it('onComplete returns results in same order as selected', async function () {
|
||||||
// first request has a delay to simulate larger file
|
// 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
|
// second request has no delay to simulate small file
|
||||||
stubSuccessfulUpload(server, 0);
|
stubSuccessfulUpload(server, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user