CSC/ECE 517 Fall 2023 - E2386. Reimplement teams users backend: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 51: Line 51:
The TeamsUsers model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of TeamsUsers model and controller we have defined the following test which are implemented to test the reimplemented code of teams_users model and controller.
The TeamsUsers model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of TeamsUsers model and controller we have defined the following test which are implemented to test the reimplemented code of teams_users model and controller.


|| Sr No || Test || Description ||
{| class="wikitable" style="margin-left:40px"
| 1 | `#update_duties` | Updates duties for a participant successfully and redirects to '/student_teams/view?student_id=1'. |
|-
| 2 | `#list` | Renders the list of users under Assignment team teams#users. |
! Test No. !! Description  
| 3 | `#new` | Sets the Team object to an instance variable. |
|-
| 4 | `#create` (User Not Defined) | Throws an error and redirects to 'http://test.host/teams/list?id=1' when a user is not defined. |
| 1 || Tests if `#update_duties` updates duties for a participant successfully and redirects to '/student_teams/view?student_id=1'.
| 5 | `#create` (User Not a Participant) | Throws an error and redirects to 'http://test.host/teams/list?id=1' when the user added is not a participant of the current assignment. |
|-
| 6 | `#create` (Assignment Team Full) | Throws an error 'This team already has the maximum number of members.' and redirects to 'http://test.host/teams/list?id=1'. |
| 2 || Tests if `#list` renders the list of users under Assignment team teams#users.
| 7 | `#create` (User Successfully Added) | New user gets successfully added to the assignment and redirects to 'http://test.host/teams/list?id=1'. |
|-
| 8 | `#delete` | Deletes a user and redirects to 'http://test.host/teams/list?id=1'. |
| 3 || Tests if `#new` sets the Team object to an instance variable.
| 9 | `#delete_selected` | Deletes selected users and redirects to 'http://test.host/teams_users/list'. |
|-
| 4 || Tests if `#create` (User Not Defined) throws an error and redirects to 'http://test.host/teams/list?id=1' when a user is not defined.
|-
| 5 || Tests if `#create` (User Not a Participant) throws an error and redirects to 'http://test.host/teams/list?id=1' when the user added is not a participant of the current assignment.
|-
| 6 || Tests if `#create` (Assignment Team Full) throws an error 'This team already has the maximum number of members.' and redirects to 'http://test.host/teams/list?id=1'.
|-
| 7 || Tests if `#create` (User Successfully Added) new user gets successfully added to the assignment and redirects to 'http://test.host/teams/list?id=1'.
|-
| 8 || Tests if `#delete` deletes a user and redirects to 'http://test.host/teams/list?id=1'.
|-
| 9 || Tests if `#delete_selected` deletes selected users and redirects to 'http://test.host/teams_users/list'.
|}
 





Revision as of 02:26, 16 November 2023

Description of Project

The focal point of the project is the Team_user model, capturing information about mentors, team members, and affiliations with other models such as Users and Teams. This model undertakes various responsibilities, including the formation of teams with enrolled students and the display of team members. Oversight of team management falls under the purview of the Team_user_controller, which orchestrates CRUD operations on the Team_user model. Its duties span the creation, modification, and deletion of teams, along with the administration of team members through additions or removals. Furthermore, the controller provides a list of mentors associated with Team_users.

Problem Statement

The project involves creating a backend system for seamless CRUD operations on a relational database, specifically focusing on interactions between teams and users. This requires defining "Team_Users" model with suitable attributes and relationships, establishing controllers to manage CRUD actions, and setting up corresponding routes. Emphasis is placed on rigorous testing, covering model validations and associations, as well as controller actions to ensure accurate execution of CRUD operations. A key project aspect involves refining code to produce precise JSON responses. Adhering to RESTful conventions, the re-implementation includes appropriate HTTP response codes. RSpec tests are mandatory for both the Team_Users model and TeamUsersController, covering all endpoints and incorporating HTTP response codes. These controller tests are designed to integrate seamlessly with RSwag for generating API documentation and testing REST APIs through the Swagger UI.

Objectives

  • Craft RESTful endpoints for creating, displaying, and deleting invitations, along with approving new invitations. Additionally, provide functionality for listing pending invitations, creating new invitations, and notifying students about newly formed team invitations.
  • Develop and integrate methods within the Team_usersController to facilitate invitation-related operations, including creating, accepting, declining, and canceling invitations. Ensure thorough checks of user and team statuses before initiating or accepting invitations.
  • Establish a user-invitation system that empowers invited users to accept, decline, or cancel invitations, triggering corresponding updates to the associated Team_user records. This should seamlessly manage the addition or removal of users from teams.
  • Implement an email notification system within the user-invitation framework, sending email notifications to invited users upon the issuance of new invitations.
  • Enforce the use of proper status codes and robust validation mechanisms for all RESTful endpoints.
  • Construct models and controllers for the Team_user model, incorporating contemporary approaches to writing Ruby code. This involves leveraging language features and adhering to best practices for object-oriented design.
  • Compose comprehensive RSpec tests covering all APIs, models, and controllers to ensure the robustness and reliability of the entire system.

Development Strategy

Our development strategy adheres to the principles of Test-Driven Development (TDD) for the implementation of both the Invitation model and the Invitation Controller. The process begins with the creation of a failing test case, followed by the addition of code to address the identified issues and ensure the successful passage of the test.

Furthermore, we align with the Rails philosophy of "Fat models," aiming to migrate substantial business logic from the controller to the model. This approach is intended to maintain a clean and organized controller codebase while promoting code reusability throughout the application.

Project Design and Implementation

Considering the existing functionality of the Team_user model and controller, we have outlined a set of RESTful endpoints along with their corresponding request types for implementation. In the controller, we plan to adopt the Strategy Pattern, leveraging its ability to encapsulate controller actions and facilitate easy extensibility and usability. This pattern will enable a structured approach to defining and managing the various operations the controller can perform.

Functionality

In this project, we aim to add functions for the following:

1. Retrieve and display team members.

2. Add a new team member with checks for user existence and team limits.

3. Delete a specific team member.

4. Delete multiple selected team members based on item IDs.

5. Autocomplete functionality for user names within a team.

6. Updating duties of a team member.

Testing Plan

The TeamsUsers model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of TeamsUsers model and controller we have defined the following test which are implemented to test the reimplemented code of teams_users model and controller.

Test No. Description
1 Tests if `#update_duties` updates duties for a participant successfully and redirects to '/student_teams/view?student_id=1'.
2 Tests if `#list` renders the list of users under Assignment team teams#users.
3 Tests if `#new` sets the Team object to an instance variable.
4 Tests if `#create` (User Not Defined) throws an error and redirects to 'http://test.host/teams/list?id=1' when a user is not defined.
5 Tests if `#create` (User Not a Participant) throws an error and redirects to 'http://test.host/teams/list?id=1' when the user added is not a participant of the current assignment.
6 Tests if `#create` (Assignment Team Full) throws an error 'This team already has the maximum number of members.' and redirects to 'http://test.host/teams/list?id=1'.
7 Tests if `#create` (User Successfully Added) new user gets successfully added to the assignment and redirects to 'http://test.host/teams/list?id=1'.
8 Tests if `#delete` deletes a user and redirects to 'http://test.host/teams/list?id=1'.
9 Tests if `#delete_selected` deletes selected users and redirects to 'http://test.host/teams_users/list'.


Relevant Links

Github Repository: https://github.com/Kashika08/reimplementation-back-end

Team Members

  • Jay Shah (github: jayjshah2000)
  • Kashika Malick (github: kashika08)
  • Riya Gori (github: riyagori1203)

Mentor

Kartiki Bhandakkar