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

Commit

Permalink
Merge pull request #10 from ckeditor/t/9
Browse files Browse the repository at this point in the history
Fix: Prevented UploadGateway from being created when cloudServices#tokenUrl is not provided. Closes #9.
  • Loading branch information
Piotr Jasiun authored Nov 2, 2017
2 parents 6f573b2 + 744d6e4 commit cdc6662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cloudservicesuploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export default class CloudServicesUploadAdapter extends Plugin {
const token = cloudServices.token;
const uploadUrl = cloudServices.uploadUrl || 'https://files.cke-cs.com/upload/';

if ( !token ) {
return;
}

this._uploadGateway = new CloudServicesUploadAdapter._UploadGateway( token, uploadUrl );

editor.plugins.get( FileRepository ).createAdapter = loader => {
Expand Down
14 changes: 14 additions & 0 deletions tests/cloudservicesuploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ describe( 'CloudServicesUploadAdapter', () => {
} );
} );

it( 'should not set loader if there is no token', () => {
UploadGatewayMock.lastToken = undefined;

return ClassicTestEditor
.create( div, {
plugins: [ CloudServicesUploadAdapter ]
} )
.then( editor => {
expect( UploadGatewayMock.lastToken ).to.be.undefined;

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

it( 'should set the default uploadUrl', () => {
const expectedDefaultUrl = 'https://files.cke-cs.com/upload/';

Expand Down

0 comments on commit cdc6662

Please sign in to comment.