File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/app/modules/time-clock/services Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,21 @@ describe('EntryService', () => {
40
40
} ) ;
41
41
42
42
it ( 'loads an activeEntry with /running' , ( ) => {
43
+ service . urlInProduction = true ;
43
44
service . loadActiveEntry ( ) . subscribe ( ) ;
44
45
45
46
const loadEntryRequest = httpMock . expectOne ( `${ service . baseUrl } /running` ) ;
46
47
expect ( loadEntryRequest . request . method ) . toBe ( 'GET' ) ;
47
48
} ) ;
48
49
50
+ it ( 'loads an activeEntry with /active/{userId}' , ( ) => {
51
+ service . urlInProduction = false ;
52
+ service . loadActiveEntry ( ) . subscribe ( ) ;
53
+
54
+ const loadEntryRequest = httpMock . expectOne ( `${ service . baseUrl } /active/2` ) ;
55
+ expect ( loadEntryRequest . request . method ) . toBe ( 'GET' ) ;
56
+ } ) ;
57
+
49
58
it ( 'loads summary with get /summary?time_offset=<time-offset>' , ( ) => {
50
59
service . summary ( ) . subscribe ( ) ;
51
60
const timeOffset = new Date ( ) . getTimezoneOffset ( ) ;
Original file line number Diff line number Diff line change @@ -19,9 +19,17 @@ export class EntryService {
19
19
20
20
static TIME_ENTRIES_DATE_TIME_FORMAT = 'yyyy-MM-ddTHH:mm:ssZZZZZ' ;
21
21
baseUrl = `${ environment . timeTrackerApiUrl } /time-entries` ;
22
+ urlInProduction = environment . production ;
22
23
23
24
loadActiveEntry ( ) : Observable < any > {
24
- return this . http . get ( `${ this . baseUrl } /running` ) ;
25
+ let path = '' ;
26
+
27
+ if ( this . urlInProduction ) {
28
+ path = `${ this . baseUrl } /running` ;
29
+ } else {
30
+ path = `${ this . baseUrl } /active/2` ;
31
+ }
32
+ return this . http . get ( path ) ;
25
33
}
26
34
27
35
loadEntries ( date ) : Observable < any > {
You can’t perform that action at this time.
0 commit comments