Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Other: The plugin will not log a warning when `config.ckfinder.upload…
Browse files Browse the repository at this point in the history
…Url` is not specified (because `FileRepository` will do it itself). Closes #5.
  • Loading branch information
Reinmar committed Sep 28, 2017
1 parent 97515eb commit 1a15688
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
],
"dependencies": {
"@ckeditor/ckeditor5-core": "^0.9.0",
"@ckeditor/ckeditor5-upload": "^0.2.0",
"@ckeditor/ckeditor5-utils": "^0.10.0"
"@ckeditor/ckeditor5-upload": "^0.2.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^0.9.0",
Expand Down
8 changes: 1 addition & 7 deletions src/uploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository';
import { getCsrfToken } from './utils';
import log from '@ckeditor/ckeditor5-utils/src/log';

/**
* A plugin that enables CKFinder uploads in CKEditor 5.
Expand Down Expand Up @@ -49,12 +48,7 @@ export default class CKFinderUploadAdapter extends Plugin {
const url = this.editor.config.get( 'ckfinder.uploadUrl' );

if ( !url ) {
/**
* Please provide `ckfinder.uploadUrl` config option.
*
* @error ckfinder-upload-adapter-no-config
*/
log.warn( 'ckfinder-upload-adapter-no-config: Please provide "ckfinder.uploadUrl" config option.' );
return;
}

// Register CKFinderAdapter
Expand Down
18 changes: 9 additions & 9 deletions tests/uploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import CKFinderUploadAdapter from '../src/uploadadapter';
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository';
import { createNativeFileMock } from '@ckeditor/ckeditor5-upload/tests/_utils/mocks';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
import log from '@ckeditor/ckeditor5-utils/src/log';

describe( 'CKFinderUploadAdapter', () => {
let editor, sinonXHR;
Expand Down Expand Up @@ -60,21 +59,22 @@ describe( 'CKFinderUploadAdapter', () => {
expect( adapter.abort ).to.be.a( 'function' );
} );

it( 'should log warning when there is no configuration', () => {
it( 'should not set the FileRepository.createAdapter factory if not configured', () => {
const editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );
const warnSub = testUtils.sinon.stub( log, 'warn' );

return ClassicTestEditor
.create( editorElement, {
plugins: [ Image, ImageUpload, CKFinderUploadAdapter ],
} )
.then( () => {
sinon.assert.calledOnce( warnSub );
sinon.assert.calledWithExactly(
warnSub,
'ckfinder-upload-adapter-no-config: Please provide "ckfinder.uploadUrl" config option.'
);
.then( editor => {
const fileRepository = editor.plugins.get( FileRepository );

expect( fileRepository ).to.not.have.property( 'createAdapter' );

editorElement.remove();

return editor.destroy();
} );
} );

Expand Down

0 comments on commit 1a15688

Please sign in to comment.