From 726cf8a3d5461a97886e91ae1d933ec9cfb5752f Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Thu, 13 Jul 2017 17:37:09 +0100 Subject: [PATCH] PCHR-2395: PR Feedback --- .../shared/controllers/request-ctrl.js | 8 +++--- .../leave-request-ctrls.spec.js | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/controllers/request-ctrl.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/controllers/request-ctrl.js index 2faf2e435c7..468ad70e4ef 100644 --- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/controllers/request-ctrl.js +++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/src/leave-absences/shared/controllers/request-ctrl.js @@ -1029,12 +1029,10 @@ define([ // When in Admin Dashboard return Contact.all() .then(function (contacts) { - var self = this; - this.managedContacts = _.remove(contacts.list, function (contact) { - // Removes the manager/admin from the list of managees - return contact.id !== self.directiveOptions.contactId; - }); + // Removes the admin from the list of managees + return contact.id !== this.directiveOptions.contactId; + }.bind(this)); }.bind(this)); } else { // Everywhere else diff --git a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/controllers/sub-controllers/leave-request-ctrls.spec.js b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/controllers/sub-controllers/leave-request-ctrls.spec.js index c3cbaac9c1e..543deafd144 100644 --- a/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/controllers/sub-controllers/leave-request-ctrls.spec.js +++ b/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/controllers/sub-controllers/leave-request-ctrls.spec.js @@ -1205,6 +1205,33 @@ }); describe('admin opens leave request popup in create mode', function () { + var adminId = 206; + + beforeEach(function () { + $ctrl.request.contact_id = adminId.toString(); + + role = 'admin'; + initTestController({ + contactId: adminId + }); + }); + + describe('on initialization', function () { + it('is in create mode', function () { + expect($ctrl.isMode('create')).toBeTruthy(); + }); + + it('has admin role', function () { + expect($ctrl.isRole('admin')).toBeTruthy(); + }); + + it('does not contain admin in the list of managees', function () { + expect(_.find($ctrl.managedContacts, { 'id': adminId })).toBeUndefined(); + }); + }); + }); + + describe('admin opens leave request popup in create mode for a pre-selected contact', function () { var selectedContactId = 208; var adminId = 206;