CSC/ECE 517 Fall 2021 - E2126.Testing- Team Related Files
Relevant links
About Expertiza
Expertiza is an open source project based on Ruby on Rails framework. It is a web based program that allows instructors to create and update/edit assignments/tasks, and then assigns them to students. Students then can submit, edit, and update their assignments, as well as peer review other student's assignments.
Problem statement and background
There are many files related to teams that don’t have enough tests: teams_controller, teams_users_controller, student_teams_controller, join_team_requests_controller, and advertise_for_partner_controller. They all need essentially the same kind of fixtures or mocks to enable testing: A team that is created, a couple of students that can be added to the team, an invitation that can be sent from one student to another student to join a particular team
Approach Chosen & Why?
In this project we have first identified all the set of scenarios related to team controllers. Each of the scenarios are identified as mentioned above and has been subdivided into a number of ways in which it can be realized. This will ensure that code is robust to any kind of unexpected changes and that the functionality will not be broken when deployed in production. We have chosen to bring about this robustness of test by writing unit test and functional tests using RSpec and Capybara respectively. Unit Tests will ensure that the particular functionality is being tested in a isolated setup which would even include the edge cases whereas the functional tests will ensure that this teams feature is in resonance with the other features and works coherently.
Implementation
teams_controller.rb
teams_users_controller.rb
Scenario 1: Add new user to the selected team.
- Given user is not defined.
When given user is defined, link is provided to create the user.
- Selected team to which user is being added belongs to an assignment:
When user is not a participant of the assignment, link is provided to add the user to the assignment.
When the assignment team already has maximum number of users, "Maximum users reached" notification is flashed.
- Selected team to which user is being added belongs to a course:
When user is not a participant of the course, link is provided to add the user to the course.
When the course team already has maximum number of users, "Maximum users reached" notification is flashed.
Scenario 2: Delete user from the selected team.
- User under assignment or course team is deleted.
user association to the respective team is deleted and hence user is no longer part of the team.
student_teams_controller.rb
join_team_requests_controller.rb
P = Pending status
D = Denied status
A = Accepted status
Scenario 1: Creating a team request
- If the team id is verified along with user id and assignment id, create a new request and change @join_team_request = 'P' .
- If error occurs, flash error message.
Scenario 2: Decline a team request.
- After verifying team_user_id, change @join_team_request.status = 'D' .
- Redirect to view_student_teams_path
Scenario 3: Check team status.
- If team if full. Print error message "This team is full." .
- If team is not empty, print message "You are already a member of this team." .
Scenario 4: CRUD for join team request [Flow]
advertise_partner_controller.rb
Scenario 1: Creating new advertisement for partners.
- We set the advertise_for_partner : True , comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.
[Flow diagram here]
Scenario 2: Updating the advertisement.
- We set the comments_for_advertisement[param] when the user wants to set a new advertisement for partners in AssignmentTeam model.
- Update Unsuccessful : If there is an error during update then the following error message is thrown "An error occurred and your advertisement was not updated." and edit page is rendered.
- Update Successful : If the advertisement is successfully updated in the database then the "Your advertisement was successfully updated!" message is prompted and the user is redirected to the view_student_teams_path .
[Flow diagram here]
Scenario 3: Remove the advertisement.
- We set the advertise_for_partner : False , comments_for_advertisement : nil when the user wants to set a new advertisement for partners in AssignmentTeam model.
- Remove Unsuccessful : If there is an error during removing the advertisement then the following error message is thrown "An error occurred and your advertisement was not removed." and the previous page is rendered.
- Remove Successful : If the advertisement is successfully removed in the database then the "Your advertisement was successfully removed!" message is prompted and the user is redirected to the view_student_teams_path .
[Flow diagram here]