diff --git a/src/app/modules/time-clock/store/entry.effects.ts b/src/app/modules/time-clock/store/entry.effects.ts index d81756e85..aae5ae452 100644 --- a/src/app/modules/time-clock/store/entry.effects.ts +++ b/src/app/modules/time-clock/store/entry.effects.ts @@ -1,11 +1,11 @@ -import {INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY} from './../../shared/messages'; -import {Injectable} from '@angular/core'; -import {ofType, Actions, Effect} from '@ngrx/effects'; -import {Action} from '@ngrx/store'; -import {of, Observable} from 'rxjs'; -import {ToastrService} from 'ngx-toastr'; -import {catchError, map, mergeMap} from 'rxjs/operators'; -import {EntryService} from '../services/entry.service'; +import { INFO_DELETE_SUCCESSFULLY, INFO_SAVED_SUCCESSFULLY } from './../../shared/messages'; +import { Injectable } from '@angular/core'; +import { Actions, Effect, ofType } from '@ngrx/effects'; +import { Action } from '@ngrx/store'; +import { Observable, of } from 'rxjs'; +import { ToastrService } from 'ngx-toastr'; +import { catchError, map, mergeMap } from 'rxjs/operators'; +import { EntryService } from '../services/entry.service'; import * as actions from './entry.actions'; @Injectable() diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index 3513e46cd..62c09e3d8 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -249,4 +249,17 @@ describe('TimeEntriesComponent', () => { expect(component.doSave).toHaveBeenCalledWith(entryToSave); })); + + it('when saving time entries, the time entries should be queried', () => { + const currentMonth = new Date().getMonth() + 1; + const entryToSave = { + project_id: 'project-id' + }; + component.activeTimeEntry = null; + spyOn(store, 'dispatch'); + + component.saveEntry(entryToSave); + + expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntries(currentMonth)); + }); }); diff --git a/src/app/modules/time-entries/pages/time-entries.component.ts b/src/app/modules/time-entries/pages/time-entries.component.ts index 84012aa36..2628d24e8 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.ts @@ -65,6 +65,7 @@ export class TimeEntriesComponent implements OnInit { } else { this.store.dispatch(new entryActions.CreateEntry(entry)); } + this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1)); } removeEntry(entryId: string) {