Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented add_user in courses controller #44

Merged

Conversation

cynthia-lixinyi
Copy link

General Info

Changes

Explain your changes here (in such a way that you would understand why you made them a year from now).
Implemented add_user method in class CoursesController. This method accepts course_id and user_id in the request body and adds an entry to the user_to_courses table and UserToCourse model.

Testing

Explain how you tested your changes. If testing is not necessary, explain why.
Tests cover these cases:
(1) If either the provided course_id does not exist in the courses table or the provided user_id does not exists in the users tables, the add_user method should return not_found status and an error message in the JSON response.
(2) If the user is already added to the course, in the JSON response return an error message saying "The user is already added to the course".
(3) Happy path: course_id and user_id exist in their corresponding tables, and an entry with the course_id, user_id, and role is successfully added to the user_to_courses table and UserToCourse model.

Documentation

Does this PR require documentation. If so, explain where it can be found.

Checklist

  • Name of branch corresponds to story

@Zzz212zzZ Zzz212zzZ self-requested a review April 24, 2024 04:36
Zzz212zzZ
Zzz212zzZ previously approved these changes Apr 24, 2024
Copy link

@Zzz212zzZ Zzz212zzZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

@Sep26 Sep26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go.

@cynthia-lixinyi cynthia-lixinyi merged commit e9162bb into main Apr 24, 2024
6 checks passed
@cynthia-lixinyi cynthia-lixinyi deleted the 187487461-implement-add-user-by-course-controller branch April 24, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants