diff --git a/src/app/modules/time-clock/services/entry.service.spec.ts b/src/app/modules/time-clock/services/entry.service.spec.ts index ed4191c0b..3bfe37681 100644 --- a/src/app/modules/time-clock/services/entry.service.spec.ts +++ b/src/app/modules/time-clock/services/entry.service.spec.ts @@ -40,21 +40,12 @@ describe('EntryService', () => { }); it('loads an activeEntry with /running', () => { - service.urlInProduction = true; service.loadActiveEntry().subscribe(); const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running`); expect(loadEntryRequest.request.method).toBe('GET'); }); - it('loads an activeEntry with /active/{userId}', () => { - service.urlInProduction = false; - service.loadActiveEntry().subscribe(); - - const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/active/2`); - expect(loadEntryRequest.request.method).toBe('GET'); - }); - it('loads summary with get /summary?time_offset=', () => { service.summary().subscribe(); const timeOffset = new Date().getTimezoneOffset(); @@ -93,12 +84,21 @@ describe('EntryService', () => { }); it('stops an entry using POST', () => { + service.urlInProduction = true; service.stopEntryRunning('id').subscribe(); const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`); expect(updateEntryRequest.request.method).toBe('POST'); }); + it('stops an entry using PUT', () => { + service.urlInProduction = false; + service.stopEntryRunning('id').subscribe(); + + const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`); + expect(updateEntryRequest.request.method).toBe('PUT'); + }); + it('when getting time entries for report, time range should be sent', () => { const yesterday = moment(new Date()).subtract(1, 'day'); const today = moment(new Date()); diff --git a/src/app/modules/time-clock/services/entry.service.ts b/src/app/modules/time-clock/services/entry.service.ts index 12915e192..fa3e5bd24 100644 --- a/src/app/modules/time-clock/services/entry.service.ts +++ b/src/app/modules/time-clock/services/entry.service.ts @@ -22,14 +22,7 @@ export class EntryService { urlInProduction = environment.production; loadActiveEntry(): Observable { - let path = ''; - - if (this.urlInProduction){ - path = `${this.baseUrl}/running`; - }else{ - path = `${this.baseUrl}/active/2`; - } - return this.http.get(path); + return this.http.get(`${this.baseUrl}/running`); } loadEntries(date): Observable { @@ -52,8 +45,7 @@ export class EntryService { } stopEntryRunning(idEntry: string): Observable { - const url = `${this.baseUrl}/${idEntry}/stop`; - return this.http.post(url, null); + return (this.urlInProduction ? this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); } restartEntry(idEntry: string): Observable {