Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #713 from Northeastern-Electric-Racing/#650-can-re…
Browse files Browse the repository at this point in the history
…view-own-cr

#650 - added check so you can't review your own cr
  • Loading branch information
jamescd18 authored Jun 15, 2022
2 parents db23a2a + 92d3b52 commit 3082c92
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../../test-support/test-data/change-requests.stub';
import {
exampleAdminUser,
exampleAdminUser2,
exampleGuestUser,
exampleMemberUser
} from '../../../test-support/test-data/users.stub';
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('change request details container', () => {

it('enables review if the user is an admin', () => {
mockSingleCRHook(false, false, exampleActivationChangeRequest);
mockAuthHook(exampleAdminUser);
mockAuthHook(exampleAdminUser2);
renderComponent();

expect(screen.getByText('Review')).not.toBeDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const ChangeRequestDetails: React.FC = () => {

return (
<ChangeRequestDetailsView
isUserAllowedToReview={auth.user?.role !== 'GUEST' && auth.user?.role !== 'MEMBER'}
isUserAllowedToReview={
auth.user?.role !== 'GUEST' &&
auth.user?.role !== 'MEMBER' &&
auth.user?.userId !== data?.submitter.userId
}
isUserAllowedToImplement={auth.user?.role !== 'GUEST'}
changeRequest={data!}
/>
Expand Down
10 changes: 10 additions & 0 deletions src/test-support/test-data/users.stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export const exampleAdminUser: User = {
role: Role.ADMIN
};

export const exampleAdminUser2: User = {
userId: 3,
firstName: 'Joe',
lastName: 'Shmoe',
googleAuthId: '2',
email: '[email protected]',
emailId: 'shmoe.j',
role: Role.ADMIN
};

export const exampleLeadershipUser: User = {
userId: 3,
firstName: 'Joe',
Expand Down

0 comments on commit 3082c92

Please sign in to comment.