Mathijs den Burger pushed to branch feature/cmng-psp1 at cms-community / hippo-addon-channel-manager
Commits: b1698a08 by Canh Ngo at 2016-05-27T10:49:51+02:00 CHANNELMGR-691 only get prototype info when having 'write' permission The backend of /newpagemodel requires 'write' permission, so the front-end should only call it when having enough permission - - - - - eac6ae4c by Mathijs den Burger at 2016-05-30T12:07:43+02:00 CHANNELMGR-691 Merge changes into mainline - - - - - 2 changed files: - frontend-ng/src/angularjs/channel/channel.service.js - frontend-ng/src/angularjs/channel/channel.service.spec.js Changes: ===================================== frontend-ng/src/angularjs/channel/channel.service.js ===================================== --- a/frontend-ng/src/angularjs/channel/channel.service.js +++ b/frontend-ng/src/angularjs/channel/channel.service.js @@ -97,7 +97,10 @@ export class ChannelService { this.CatalogService.load(this.getMountId()); this.SiteMapService.load(channel.siteMapId); - this._augmentChannelWithPrototypeInfo(); + + if (this.SessionService.hasWriteAccess()) { + this._augmentChannelWithPrototypeInfo(); + } } getChannel() { ===================================== frontend-ng/src/angularjs/channel/channel.service.spec.js ===================================== --- a/frontend-ng/src/angularjs/channel/channel.service.spec.js +++ b/frontend-ng/src/angularjs/channel/channel.service.spec.js @@ -42,9 +42,12 @@ describe('ChannelService', () => { workspaceExists: true, }; - SessionServiceMock = { - initialize: (channel) => $q.resolve(channel), - }; + SessionServiceMock = jasmine.createSpyObj('SessionService', [ + 'initialize', + 'hasWriteAccess', + ]); + SessionServiceMock.initialize.and.callFake((channel) => $q.when(channel)); + SessionServiceMock.hasWriteAccess.and.returnValue(true); CatalogServiceMock = jasmine.createSpyObj('CatalogService', [ 'load', @@ -143,12 +146,19 @@ describe('ChannelService', () => { }); it('should not save a reference to the channel when load fails', () => { - spyOn(SessionServiceMock, 'initialize').and.returnValue($q.reject()); + SessionServiceMock.initialize.and.returnValue($q.reject()); ChannelService._load(channelMock); $rootScope.$digest(); expect(ChannelService.getChannel()).not.toEqual(channelMock); }); + it('should not fetch pagemodel when session does not have write permission', () => { + SessionServiceMock.hasWriteAccess.and.returnValue(false); + ChannelService._load(channelMock); + $rootScope.$digest(); + expect(HstService.doGetWithParams).not.toHaveBeenCalledWith(channelMock.mountId, undefined, 'newpagemodel'); + }); + it('should save a reference to the channel when load succeeds', () => { HstService.doGetWithParams.and.returnValue($q.when({ data: { prototypes: ['test'] } })); ChannelService._load(channelMock); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/81be50853aa267d30a6b928ddc3537cceb408909...eac6ae4cd5eadb3e95c8e3bae8cf8cda6d3f8e59
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn