diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index 7551be257..6b9eee025 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -54,7 +54,7 @@ {{::saleClaimed.sale.price | currency: 'EUR':2}} - {{saleClaimed.sale.discount}} % diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js index f66a296c8..8fa7e2f2d 100644 --- a/modules/claim/front/detail/index.js +++ b/modules/claim/front/detail/index.js @@ -29,8 +29,10 @@ class Controller { set salesClaimed(value) { this._salesClaimed = value; - if (value) + if (value) { this.calculateTotals(); + this.isClaimEditable(); + } } get salesClaimed() { @@ -134,6 +136,12 @@ class Controller { }); } + isClaimEditable() { + this.$http.get(`Tickets/${this.claim.ticketFk}/isEditable`).then(res => { + this.isEditable = res.data; + }); + } + updateDiscount() { const claimedSale = this.saleClaimed.sale; if (this.newDiscount != claimedSale.discount) { diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js index 24491075d..8d102ae96 100644 --- a/modules/claim/front/detail/index.spec.js +++ b/modules/claim/front/detail/index.spec.js @@ -17,13 +17,14 @@ describe('claim', () => { show: () => {} }; $httpBackend = _$httpBackend_; - $httpBackend.when('GET', 'Claims/ClaimBeginnings').respond({}); + $httpBackend.whenGET('Claims/ClaimBeginnings').respond({}); + $httpBackend.whenGET(`Tickets/1/isEditable`).respond(true); $state = _$state_; aclService = {hasAny: () => true}; controller = $componentController('vnClaimDetail', {$state, aclService, $scope}); + controller.claim = {ticketFk: 1}; controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; controller.salesClaimed = [{id: 1, sale: {}}]; - controller.claim = {ticketFk: 1}; controller.$.model = crudModel; controller.$.addSales = { hide: () => {}, @@ -36,7 +37,6 @@ describe('claim', () => { describe('openAddSalesDialog()', () => { it('should call getClaimableFromTicket and $.addSales.show', () => { - controller.$ = {addSales: {show: () => {}}}; spyOn(controller, 'getClaimableFromTicket'); spyOn(controller.$.addSales, 'show'); controller.openAddSalesDialog(); @@ -146,5 +146,14 @@ describe('claim', () => { expect(controller.$.descriptor.show).toHaveBeenCalledWith(); }); }); + + describe('isClaimEditable()', () => { + it('should check if the claim is editable', () => { + controller.isClaimEditable(); + $httpBackend.flush(); + + expect(controller.isEditable).toBeTruthy(); + }); + }); }); }); diff --git a/modules/client/front/web-access/index.spec.js b/modules/client/front/web-access/index.spec.js index f8eb7b2ef..671e95095 100644 --- a/modules/client/front/web-access/index.spec.js +++ b/modules/client/front/web-access/index.spec.js @@ -29,13 +29,24 @@ describe('Component VnClientWebAccess', () => { }); describe('isCustomer()', () => { - it(`should perform a query if client is defined with an ID`, () => { + it('should return a true if the password can be modified', () => { controller.client = {id: '1234'}; - controller.isCustomer(); - $httpBackend.when('GET', `Clients/${controller.client.id}/hasCustomerRole`).respond('ok'); - $httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`); + $httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond({isCustomer: true}); + controller.isCustomer(); $httpBackend.flush(); + + expect(controller.canChangePassword).toBeTruthy(); + }); + + it(`should return a false if the password can't be modified`, () => { + controller.client = {id: '1234'}; + + $httpBackend.expectGET(`Clients/${controller.client.id}/hasCustomerRole`).respond({isCustomer: false}); + controller.isCustomer(); + $httpBackend.flush(); + + expect(controller.canChangePassword).toBeFalsy(); }); });