Michiel Rop pushed to branch feature/wpm-CHANNELMGR-1247 at cms-community / 
hippo-addon-channel-manager


Commits:
3a481c0d by Michiel Eggermont at 2017-05-09T14:02:53+02:00
CHANNELMGR-1239 Fix karma test

- - - - -
216e7969 by Michiel Rop at 2017-05-09T14:03:59+02:00
CHANNELMGR-1247 Fix the "getProjects" unit test

- - - - -


5 changed files:

- 
frontend-ng/src/angularjs/channel/actions/settings/property/property.controller.js
- frontend-ng/src/angularjs/channel/actions/settings/property/property.spec.js
- frontend-ng/src/angularjs/channel/actions/settings/settings.spec.js
- frontend-ng/src/angularjs/services/project.service.js
- frontend-ng/src/angularjs/services/project.service.spec.js


Changes:

=====================================
frontend-ng/src/angularjs/channel/actions/settings/property/property.controller.js
=====================================
--- 
a/frontend-ng/src/angularjs/channel/actions/settings/property/property.controller.js
+++ 
b/frontend-ng/src/angularjs/channel/actions/settings/property/property.controller.js
@@ -47,9 +47,7 @@ class ChannelPropertyCtrl {
     this.annotation = this._getFirstFieldAnnotation();
     this.type = this._getType();
     this.qaClass = this._getQaClass();
-    if (!this.data.editable || (this.data.lockedBy && this.data.lockedBy !== 
ConfigService.cmsUser)) {
-      this.readOnly = true;
-    }
+    this.readOnly = !this.data.editable || (this.data.lockedBy && 
this.data.lockedBy !== ConfigService.cmsUser);
     this.required = this.definition && this.definition.isRequired;
 
     if (this._isPickerField()) {


=====================================
frontend-ng/src/angularjs/channel/actions/settings/property/property.spec.js
=====================================
--- 
a/frontend-ng/src/angularjs/channel/actions/settings/property/property.spec.js
+++ 
b/frontend-ng/src/angularjs/channel/actions/settings/property/property.spec.js
@@ -193,7 +193,8 @@ describe('ChannelProperty', () => {
     expect(ChannelPropertyCtrl.getDropDownListValues()).toEqual([]);
   });
 
-  it('enters read-only mode if the channel is locked by someone else', () => {
+  it('enters read-only mode if the channel is locked by someone else even if 
the channel is editable', () => {
+    channelInfoDescription.editable = true;
     ConfigService.cmsUser = 'admin';
     channelInfoDescription.lockedBy = 'tester';
     let ChannelPropertyCtrl = compileDirectiveAndGetController();


=====================================
frontend-ng/src/angularjs/channel/actions/settings/settings.spec.js
=====================================
--- a/frontend-ng/src/angularjs/channel/actions/settings/settings.spec.js
+++ b/frontend-ng/src/angularjs/channel/actions/settings/settings.spec.js
@@ -147,6 +147,7 @@ describe('ChannelSettings', () => {
 
   it('marks required fields as dirty on save', () => {
     channelInfoDescription.propertyDefinitions.dropDown.isRequired = true;
+    channelInfoDescription.editable = true;
     const ChannelSettingsCtrl = compileDirectiveAndGetController();
     expect(ChannelSettingsCtrl.form.dropDown.$dirty).toEqual(false);
 
@@ -166,6 +167,7 @@ describe('ChannelSettings', () => {
   });
 
   it('notifies the event "on-success" when saving is successful', () => {
+    channelInfoDescription.editable = true;
     spyOn(ChannelService, 'saveChannel').and.returnValue($q.when());
     spyOn(ChannelService, 'recordOwnChange');
     spyOn(HippoIframeService, 'reload');
@@ -180,6 +182,7 @@ describe('ChannelSettings', () => {
   });
 
   it('shows feedback message when saving is failed', () => {
+    channelInfoDescription.editable = true;
     spyOn(ChannelService, 'saveChannel').and.returnValue($q.reject());
     compileDirectiveAndGetController();
 
@@ -200,6 +203,7 @@ describe('ChannelSettings', () => {
   it('displays an alert message when the current channel is locked', () => {
     ConfigService.cmsUser = 'admin';
     channelInfoDescription.lockedBy = 'tester';
+    channelInfoDescription.editable = true;
     compileDirectiveAndGetController();
     
expect(FeedbackService.showErrorOnSubpage).toHaveBeenCalledWith('ERROR_CHANNEL_SETTINGS_READONLY',
 { lockedBy: 'tester' });
 


=====================================
frontend-ng/src/angularjs/services/project.service.js
=====================================
--- a/frontend-ng/src/angularjs/services/project.service.js
+++ b/frontend-ng/src/angularjs/services/project.service.js
@@ -42,14 +42,13 @@ class ProjectService {
   }
 
   projects() {
-    const url = 
`${this.ConfigService.getCmsContextPath()}${REST_API_PATH}/${this._mountId}/channel`;
-    return this.$http({ method: 'GET', url, headers: {}, data: {} })
+    return this._getProjects(this._mountId)
       .then((result) => {
         this.currentBranch()
           .then((branchId) => {
             this.withBranch = [this._master];
-            this.withBranch = this.withBranch.concat(result.data.withBranch);
-            this.withoutBranch = result.data.withoutBranch;
+            this.withBranch = this.withBranch.concat(result.withBranch);
+            this.withoutBranch = result.withoutBranch;
             this.selectedProject = this._master;
             if (branchId) {
               this.selectedProject = this.withBranch.find(project => 
this._compareIgnorePreview(project.id, branchId));
@@ -58,6 +57,11 @@ class ProjectService {
       });
   }
 
+  _getProjects(mountId) {
+    const url = 
`${this.ConfigService.getCmsContextPath()}${REST_API_PATH}/${mountId}/channel`;
+    return this.$http({ method: 'GET', url, headers: {}, data: {} 
}).then(result => result.data);
+  }
+
   compareId(p1) {
     return p2 => this._compareIgnorePreview(p1.id, p2.id);
   }


=====================================
frontend-ng/src/angularjs/services/project.service.spec.js
=====================================
--- a/frontend-ng/src/angularjs/services/project.service.spec.js
+++ b/frontend-ng/src/angularjs/services/project.service.spec.js
@@ -72,7 +72,7 @@ describe('ProjectService', () => {
 
     
$httpBackend.expectGET(`/test/ws/projects/${mountId}/channel`).respond(200, 
returnFromRest);
 
-    ProjectService.projects(12).then((returned) => {
+    ProjectService._getProjects(12).then((returned) => {
       actual = returned;
     });
     $httpBackend.flush();



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/994b2223d5cee2760915d3a81e687beda05a0360...216e79694bdaa267880bbf564d94b968b1c9347b
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to