Arthur Bogaart pushed to branch feature/cmng-psp1 at cms / 
hippo-addon-channel-manager


Commits:
256d19be by Arthur Bogaart at 2016-02-12T16:16:18+01:00
CHANNELMGR-339 Fix SessionService tests

The rootResource param was moved into the ConfigService but the 
mockConfigService was not updated to reflect this refactoring, thus breaking 
the tests.
 I also moved the assignment of rootResource in ConfigService to occur before 
values from CmsService.getConfig() are merged to allow the CMS to override the 
rootResource if needed.

- - - - -


2 changed files:

- frontend-ng/src/angularjs/api/config.service.js
- frontend-ng/src/angularjs/api/session.service.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/api/config.service.js
=====================================
--- a/frontend-ng/src/angularjs/api/config.service.js
+++ b/frontend-ng/src/angularjs/api/config.service.js
@@ -19,10 +19,9 @@ export class ConfigService {
   constructor(CmsService) {
     'ngInject';
 
-    // default configuration
     this.locale = 'en';
+    this.rootResource = '/cafebabe-cafe-babe-cafe-babecafebabe.';
 
     Object.assign(this, CmsService.getConfig());
-    this.rootResource = '/cafebabe-cafe-babe-cafe-babecafebabe.';
   }
 }


=====================================
frontend-ng/src/angularjs/api/session.service.spec.js
=====================================
--- a/frontend-ng/src/angularjs/api/session.service.spec.js
+++ b/frontend-ng/src/angularjs/api/session.service.spec.js
@@ -22,21 +22,25 @@ describe('SessionService', function () {
   var ConfigServiceMock;
   var channelMock;
 
-  // built-in path to RootResource 'REST' endpoint
-  var composerModePath = 
'/cafebabe-cafe-babe-cafe-babecafebabe./composermode/';
-  var handshakeUrl = '/testContextPath/testApiUrlPrefix' + composerModePath + 
'test.host.name/';
+  var rootResource = '/cafebabe.';
+  var apiUrlPrefix = '/testApiUrlPrefix';
+  var composerMode = '/composermode';
+  var contextPath = '/testContextPath';
+  var hostname = 'test.host.name';
+  var handshakeUrl = contextPath + apiUrlPrefix + rootResource + composerMode 
+ '/' + hostname + '/';
 
   beforeEach(function () {
     module('hippo-cm-api');
 
     channelMock = {
-      contextPath: '/testContextPath',
-      hostname: 'test.host.name',
+      contextPath: contextPath,
+      hostname: hostname,
     };
 
     ConfigServiceMock = {
-      apiUrlPrefix: '/testApiUrlPrefix',
+      apiUrlPrefix: apiUrlPrefix,
       cmsUser: 'testUser',
+      rootResource: rootResource,
     };
 
     module(function ($provide) {
@@ -59,7 +63,7 @@ describe('SessionService', function () {
   });
 
   it('should have a handshakePath', function () {
-    
expect(SessionService.handshakePath).toEqual(ConfigServiceMock.apiUrlPrefix + 
composerModePath);
+    expect(SessionService.handshakePath).toEqual(apiUrlPrefix + rootResource + 
composerMode + '/');
   });
 
   it('should have a cms user', function () {



View it on GitLab: 
https://code.onehippo.org/cms/hippo-addon-channel-manager/commit/256d19bec2ff1b14d231143183832eecbc5a7a0b
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to