Skip to content

Commit dc4ebbc

Browse files
thegreatyamoriLEON12699
authored andcommitted
refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
1 parent bf89636 commit dc4ebbc

File tree

8 files changed

+134
-20
lines changed

8 files changed

+134
-20
lines changed

src/app/modules/users/services/users.service.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ describe('UsersService', () => {
5252
expect(grantRoleRequest.request.method).toBe('POST');
5353
});
5454

55+
<<<<<<< HEAD
5556
<<<<<<< HEAD
5657
it('add user to group', () => {
5758
=======
5859
it('add group to a User', () => {
5960
>>>>>>> feat: TT-188 add & remove groups to user service
61+
=======
62+
it('add user to group', () => {
63+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
6064
const userId = 'userId';
6165
const group = 'admin';
6266
const addGroupURL = `${service.baseUrl}/${userId}/groups/add`;
@@ -74,15 +78,20 @@ describe('UsersService', () => {
7478
expect(httpMock.expectOne(addGroupURL).request.method).toBe('POST');
7579
});
7680

81+
<<<<<<< HEAD
7782
<<<<<<< HEAD
7883
it('remove user from group', () => {
7984
=======
8085
it('remove group to a User', () => {
8186
>>>>>>> feat: TT-188 add & remove groups to user service
87+
=======
88+
it('remove user from group', () => {
89+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
8290
const userId = 'userId';
8391
const group = 'admin';
8492
const removeGroupURL = `${service.baseUrl}/${userId}/groups/remove`;
8593

94+
<<<<<<< HEAD
8695
<<<<<<< HEAD
8796
<<<<<<< HEAD
8897
service.removeUserFromGroup(userId, group).subscribe();
@@ -92,6 +101,9 @@ describe('UsersService', () => {
92101
=======
93102
service.removeUserToGroup(userId, group).subscribe();
94103
>>>>>>> refactor: TT-188 refactor some names
104+
=======
105+
service.removeUserFromGroup(userId, group).subscribe();
106+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
95107

96108
expect(httpMock.expectOne(removeGroupURL).request.method).toBe('POST');
97109
});

src/app/modules/users/services/users.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class UsersService {
3939
});
4040
}
4141

42+
<<<<<<< HEAD
4243
<<<<<<< HEAD
4344
<<<<<<< HEAD
4445
removeUserFromGroup(userId: string, group: string): Observable<User> {
@@ -48,6 +49,9 @@ export class UsersService {
4849
=======
4950
removeUserToGroup(userId: string, group: string): Observable<User> {
5051
>>>>>>> refactor: TT-188 refactor some names
52+
=======
53+
removeUserFromGroup(userId: string, group: string): Observable<User> {
54+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
5155
return this.http.post<User>(`${this.baseUrl}/${userId}/groups/remove`, {
5256
group_name: group,
5357
});

src/app/modules/users/store/user.actions.spec.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ describe('UserActions', () => {
7777
});
7878

7979
it('RemoveUserFromGroup type is UserActionTypes.REMOVE_USER_FROM_GROUP', () => {
80+
<<<<<<< HEAD
8081
const userId = 'userId';
8182
const groupName = 'groupName';
8283
const action = new actions.RemoveUserFromGroup(userId, groupName);
@@ -121,28 +122,34 @@ describe('UserActions', () => {
121122
});
122123

123124
it('RemoveUserToGroup type is UserActionTypes.REMOVE_USER_TO_GROUP', () => {
125+
=======
126+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
124127
const userId = 'userId';
125128
const groupName = 'groupName';
126-
const action = new actions.RemoveUserToGroup(userId, groupName);
129+
const action = new actions.RemoveUserFromGroup(userId, groupName);
127130

128-
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_TO_GROUP);
131+
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_FROM_GROUP);
129132
});
130133

131-
it('RemoveUserToGroupSuccess type is UserActionTypes.REMOVE_USER_TO_GROUP_SUCCESS', () => {
134+
it('RemoveUserFromGroupSuccess type is UserActionTypes.REMOVE_USER_FROM_GROUP_SUCCESS', () => {
132135
const payload: User = { id: 'id', email: 'email', name: 'name' };
133-
const action = new actions.RemoveUserToGroupSuccess(payload);
136+
const action = new actions.RemoveUserFromGroupSuccess(payload);
134137

135-
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_TO_GROUP_SUCCESS);
138+
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_FROM_GROUP_SUCCESS);
136139
});
137140

138-
it('RemoveUserToGroupFail type is UserActionTypes.REMOVE_USER_TO_GROUP_FAIL', () => {
139-
const action = new actions.RemoveUserToGroupFail('error');
141+
it('RemoveUserFromGroupFail type is UserActionTypes.REMOVE_USER_FROM_GROUP_FAIL', () => {
142+
const action = new actions.RemoveUserFromGroupFail('error');
140143

144+
<<<<<<< HEAD
141145
<<<<<<< HEAD
142146
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_GROUP_TO_USER_FAIL);
143147
>>>>>>> feat: TT-188 add ngrx flow & test
144148
=======
145149
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_TO_GROUP_FAIL);
146150
>>>>>>> refactor: TT-188 refactor some names
151+
=======
152+
expect(action.type).toEqual(actions.UserActionTypes.REMOVE_USER_FROM_GROUP_FAIL);
153+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
147154
});
148155
});

src/app/modules/users/store/user.actions.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ export enum UserActionTypes {
3131
ADD_USER_TO_GROUP = '[User] ADD_USER_TO_GROUP',
3232
ADD_USER_TO_GROUP_SUCCESS = '[User] ADD_USER_TO_GROUP_SUCCESS',
3333
ADD_USER_TO_GROUP_FAIL = '[User] ADD_USER_TO_GROUP_FAIL',
34+
<<<<<<< HEAD
3435
REMOVE_USER_TO_GROUP = '[User] REMOVE_USER_TO_GROUP',
3536
REMOVE_USER_TO_GROUP_SUCCESS = '[User] REMOVE_USER_TO_GROUP_SUCCESS',
3637
REMOVE_USER_TO_GROUP_FAIL = '[User] REMOVE_USER_TO_GROUP_FAIL',
3738
>>>>>>> refactor: TT-188 refactor some names
39+
=======
40+
REMOVE_USER_FROM_GROUP = '[User] REMOVE_USER_FROM_GROUP',
41+
REMOVE_USER_FROM_GROUP_SUCCESS = '[User] REMOVE_USER_FROM_GROUP_SUCCESS',
42+
REMOVE_USER_FROM_GROUP_FAIL = '[User] REMOVE_USER_FROM_GROUP_FAIL',
43+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
3844
DEFAULT_USER = '[USER] DEFAULT_USER',
3945
}
4046

@@ -101,6 +107,7 @@ export class AddUserToGroupFail implements Action {
101107

102108
export class RemoveUserFromGroup implements Action {
103109
public readonly type = UserActionTypes.REMOVE_USER_FROM_GROUP;
110+
<<<<<<< HEAD
104111
constructor(public userId: string, public groupName: string) {}
105112
}
106113

@@ -133,14 +140,17 @@ export class AddUserToGroupFail implements Action {
133140

134141
export class RemoveUserToGroup implements Action {
135142
public readonly type = UserActionTypes.REMOVE_USER_TO_GROUP;
143+
=======
144+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
136145
constructor(public userId: string, public groupName: string) {}
137146
}
138147

139-
export class RemoveUserToGroupSuccess implements Action {
140-
public readonly type = UserActionTypes.REMOVE_USER_TO_GROUP_SUCCESS;
148+
export class RemoveUserFromGroupSuccess implements Action {
149+
public readonly type = UserActionTypes.REMOVE_USER_FROM_GROUP_SUCCESS;
141150
constructor(readonly payload: User) {}
142151
}
143152

153+
<<<<<<< HEAD
144154
<<<<<<< HEAD
145155
export class RemoveGroupToUserFail implements Action {
146156
public readonly type = UserActionTypes.REMOVE_GROUP_TO_USER_FAIL;
@@ -149,6 +159,10 @@ export class RemoveGroupToUserFail implements Action {
149159
export class RemoveUserToGroupFail implements Action {
150160
public readonly type = UserActionTypes.REMOVE_USER_TO_GROUP_FAIL;
151161
>>>>>>> refactor: TT-188 refactor some names
162+
=======
163+
export class RemoveUserFromGroupFail implements Action {
164+
public readonly type = UserActionTypes.REMOVE_USER_FROM_GROUP_FAIL;
165+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
152166
constructor(public error: string) {}
153167
}
154168

@@ -187,7 +201,13 @@ export type UserActions =
187201
| AddUserToGroup
188202
| AddUserToGroupSuccess
189203
| AddUserToGroupFail
204+
<<<<<<< HEAD
190205
| RemoveUserToGroup
191206
| RemoveUserToGroupSuccess
192207
| RemoveUserToGroupFail;
193208
>>>>>>> refactor: TT-188 refactor some names
209+
=======
210+
| RemoveUserFromGroup
211+
| RemoveUserFromGroupSuccess
212+
| RemoveUserFromGroupFail;
213+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references

src/app/modules/users/store/user.effects.spec.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ describe('UserEffects', () => {
185185
});
186186

187187
it('action type is REMOVE_USER_FROM_GROUP_SUCCESS when service is executed succesfully', async () => {
188+
<<<<<<< HEAD
188189
const userId = 'userId';
189190
const groupName = 'groupName';
190191
actions$ = of({
@@ -211,12 +212,19 @@ describe('UserEffects', () => {
211212
=======
212213
type: UserActionTypes.REMOVE_USER_TO_GROUP,
213214
>>>>>>> refactor: TT-188 refactor some names
215+
=======
216+
const userId = 'userId';
217+
const groupName = 'groupName';
218+
actions$ = of({
219+
type: UserActionTypes.REMOVE_USER_FROM_GROUP,
220+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
214221
userId,
215222
groupName,
216223
});
217224

218225
spyOn(toastrService, 'success');
219226
<<<<<<< HEAD
227+
<<<<<<< HEAD
220228
<<<<<<< HEAD
221229
spyOn(service, 'removeUserFromGroup').and.returnValue(of(user));
222230

@@ -236,29 +244,37 @@ describe('UserEffects', () => {
236244
=======
237245
spyOn(service, 'removeUserToGroup').and.returnValue(of(user));
238246
>>>>>>> refactor: TT-188 refactor some names
247+
=======
248+
spyOn(service, 'removeUserFromGroup').and.returnValue(of(user));
249+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
239250

240-
effects.removeUserToGroup$.subscribe((action) => {
241-
expect(toastrService.success).toHaveBeenCalledWith('Remove user to group success');
242-
expect(action.type).toEqual(UserActionTypes.REMOVE_USER_TO_GROUP_SUCCESS);
251+
effects.removeUserFromGroup$.subscribe((action) => {
252+
expect(toastrService.success).toHaveBeenCalledWith('Remove user from group success');
253+
expect(action.type).toEqual(UserActionTypes.REMOVE_USER_FROM_GROUP_SUCCESS);
243254
});
244255
});
245256

246-
it('action type is REMOVE_USER_TO_GROUP_FAIL when service is executed succesfully', async () => {
257+
it('action type is REMOVE_USER_FROM_GROUP_FAIL when service is executed succesfully', async () => {
247258
const userId = 'userId';
248259
const groupName = 'groupName';
249260
actions$ = of({
261+
<<<<<<< HEAD
250262
<<<<<<< HEAD
251263
type: UserActionTypes.REMOVE_GROUP_TO_USER,
252264
>>>>>>> feat: TT-188 add ngrx flow & test
253265
=======
254266
type: UserActionTypes.REMOVE_USER_TO_GROUP,
255267
>>>>>>> refactor: TT-188 refactor some names
268+
=======
269+
type: UserActionTypes.REMOVE_USER_FROM_GROUP,
270+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
256271
userId,
257272
groupName,
258273
});
259274

260275
spyOn(toastrService, 'error');
261276
<<<<<<< HEAD
277+
<<<<<<< HEAD
262278
<<<<<<< HEAD
263279
spyOn(service, 'removeUserFromGroup').and.returnValue(throwError({ error: { message: 'error' } }));
264280

@@ -270,15 +286,22 @@ describe('UserEffects', () => {
270286
=======
271287
spyOn(service, 'removeUserToGroup').and.returnValue(throwError({ error: { message: 'error' } }));
272288
>>>>>>> refactor: TT-188 refactor some names
289+
=======
290+
spyOn(service, 'removeUserFromGroup').and.returnValue(throwError({ error: { message: 'error' } }));
291+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
273292

274-
effects.removeUserToGroup$.subscribe((action) => {
293+
effects.removeUserFromGroup$.subscribe((action) => {
275294
expect(toastrService.error).toHaveBeenCalled();
295+
<<<<<<< HEAD
276296
<<<<<<< HEAD
277297
expect(action.type).toEqual(UserActionTypes.REMOVE_GROUP_TO_USER_FAIL);
278298
>>>>>>> feat: TT-188 add ngrx flow & test
279299
=======
280300
expect(action.type).toEqual(UserActionTypes.REMOVE_USER_TO_GROUP_FAIL);
281301
>>>>>>> refactor: TT-188 refactor some names
302+
=======
303+
expect(action.type).toEqual(UserActionTypes.REMOVE_USER_FROM_GROUP_FAIL);
304+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
282305
});
283306
});
284307
});

src/app/modules/users/store/user.effects.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class UserEffects {
109109

110110
@Effect()
111111
<<<<<<< HEAD
112+
<<<<<<< HEAD
112113
<<<<<<< HEAD
113114
removeUserFromGroup$: Observable<Action> = this.actions$.pipe(
114115
ofType(actions.UserActionTypes.REMOVE_USER_FROM_GROUP),
@@ -131,20 +132,29 @@ export class UserEffects {
131132
ofType(actions.UserActionTypes.REMOVE_USER_TO_GROUP),
132133
map((action: actions.RemoveUserToGroup) => action),
133134
>>>>>>> refactor: TT-188 refactor some names
135+
=======
136+
removeUserFromGroup$: Observable<Action> = this.actions$.pipe(
137+
ofType(actions.UserActionTypes.REMOVE_USER_FROM_GROUP),
138+
map((action: actions.RemoveUserFromGroup) => action),
139+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
134140
mergeMap((action) =>
135-
this.userService.removeUserToGroup(action.userId, action.groupName).pipe(
141+
this.userService.removeUserFromGroup(action.userId, action.groupName).pipe(
136142
map((response) => {
137-
this.toastrService.success('Remove user to group success');
138-
return new actions.RemoveUserToGroupSuccess(response);
143+
this.toastrService.success('Remove user from group success');
144+
return new actions.RemoveUserFromGroupSuccess(response);
139145
}),
140146
catchError((error) => {
141147
this.toastrService.error(error.error.message);
148+
<<<<<<< HEAD
142149
<<<<<<< HEAD
143150
return of(new actions.RemoveGroupToUserFail(error));
144151
>>>>>>> feat: TT-188 add ngrx flow & test
145152
=======
146153
return of(new actions.RemoveUserToGroupFail(error));
147154
>>>>>>> refactor: TT-188 refactor some names
155+
=======
156+
return of(new actions.RemoveUserFromGroupFail(error));
157+
>>>>>>> refactor: TT-188 refactor 'removeTo' to 'removeFrom' references
148158
})
149159
)
150160
)

0 commit comments

Comments
 (0)