<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jrlanois</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jrlanois"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Jrlanois"/>
	<updated>2026-05-22T18:51:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=147096</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=147096"/>
		<updated>2022-12-05T21:37:01Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 4: Remove Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. We aim to follow the DRY principle in our refactoring by removing code that exists in multiple places. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to its own method that can be used in all instances. By moving this code to its own method and replacing with the previous code, it will be following the DRY princple because there's less code being repeated.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png|700px]]&lt;br /&gt;
&lt;br /&gt;
To address this code, we added a new method:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - get team type const method.png]]&lt;br /&gt;
&lt;br /&gt;
This method replaced the repeating code from in the program, ending up with the result seen below. This code is cleaner and properly applies the DRY principle.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg|700px]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand. After analyzing the code, we could see that the team_size method only had one line, and was being used only in one place. So, the method was removed and the call to it (boxed in blue) was replaced with the line of code from the method. The code for team_parent was found to be redundant, and so every call made for team_parent was replaced with what would be the result from it (boxedin red). Also, because the ID of the team parent is the same as the params[:id], all instances of team_parent.id were replaced with params[:id] (boxed in green).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - Removed Methods Changes.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that was changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase. The English file was also updated to reflect new language introduced in our last project, E2254, which is linked above.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller was 79.8% covered. If all of the below tests were added, the controller would reach at 100% coverage. We added some of these tests as part of this project and brought coverage up to 94.9%, which is a 15.1% increase. We also discovered a couple bugs when implementing the tests.&lt;br /&gt;
&lt;br /&gt;
====Create team when team exists====&lt;br /&gt;
&lt;br /&gt;
Parts of an existing test were uncommented and fixed to test this case and show coverage.&lt;br /&gt;
&lt;br /&gt;
====Update team when team exists====&lt;br /&gt;
&lt;br /&gt;
A new test was added to ensure the code properly handles the TeamExistsError which occurs if an existing team name is used.&lt;br /&gt;
&lt;br /&gt;
====Update team when team doesn't exist====&lt;br /&gt;
&lt;br /&gt;
Parts of an existing test were uncommented and fixed to test this case and show coverage.&lt;br /&gt;
&lt;br /&gt;
====Delete all when child nodes exist====&lt;br /&gt;
&lt;br /&gt;
Attempting to write a test for this method revealed that the delete_all method is currently broken in Expertiza. The code before we made any changes&lt;br /&gt;
called Team.destroy_all to delete the teams for an assignment. However, this will delete all teams, not just the teams for a assignment or course.&lt;br /&gt;
This code was commented out and a note was added to document the broken method.&lt;br /&gt;
A skipped test stub was added, but the delete_all method will need to implemented properly before the full test is written.&lt;br /&gt;
&lt;br /&gt;
====Copy to assignment when no course====&lt;br /&gt;
&lt;br /&gt;
An existing test case was fixed to test this code. The test should have been failing, but it passed because of improper checking.&lt;br /&gt;
The test code was updated to check the flash message to ensure an error is shown when an invalid course id is given.&lt;br /&gt;
The code was updated to try to actually find a course with the given id rather than just checking if the id is present.&lt;br /&gt;
&lt;br /&gt;
====Create when team parent is a Course====&lt;br /&gt;
&lt;br /&gt;
This test was not added, but adding it should d cover an additional 2 lines in the team_type method.&lt;br /&gt;
&lt;br /&gt;
==Diagrams==&lt;br /&gt;
===Overview Diagram===&lt;br /&gt;
The following diagram shows an overview of the different routes in the controller and some of their basic functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2274_teams_controller_overview.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
===RSpec Tests=== &lt;br /&gt;
As mentioned for Issue 6, we plan to write several RSpec tests to increase test coverage of the teams_controller file by 10-20%. Specific test cases are list in the issue's section.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
====Randomize Teams Testing====&lt;br /&gt;
&lt;br /&gt;
Given you are logged in as an instructor&lt;br /&gt;
&lt;br /&gt;
* Username: ''instructor6'' Password ''password''&lt;br /&gt;
&lt;br /&gt;
And you are on the Manage Assignments page&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_AssignmentsPage.png|700px]]&lt;br /&gt;
&lt;br /&gt;
When you click on create teams for an assignment with participants&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_CreateTeams.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And you click &amp;quot;Create Team&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_Toolbar.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And enter appropriate information&lt;br /&gt;
&lt;br /&gt;
Then teams should be randomized and created&lt;br /&gt;
&lt;br /&gt;
====Bequeath all Testing====&lt;br /&gt;
&lt;br /&gt;
Given a team has been created for an assignment&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And I am on the create teams page for an assignment&lt;br /&gt;
&lt;br /&gt;
When I click &amp;quot;Bequeath All Teams&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Then I should be able to move the team from an assignment to a course&lt;br /&gt;
&lt;br /&gt;
Course teams before bequeath all:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Course teams after bequeath all:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png|700px]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=147095</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=147095"/>
		<updated>2022-12-05T21:32:43Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 2: Dry Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. We aim to follow the DRY principle in our refactoring by removing code that exists in multiple places. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to its own method that can be used in all instances. By moving this code to its own method and replacing with the previous code, it will be following the DRY princple because there's less code being repeated.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png|700px]]&lt;br /&gt;
&lt;br /&gt;
To address this code, we added a new method:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - get team type const method.png]]&lt;br /&gt;
&lt;br /&gt;
This method replaced the repeating code from in the program, ending up with the result seen below. This code is cleaner and properly applies the DRY principle.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg|700px]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that was changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase. The English file was also updated to reflect new language introduced in our last project, E2254, which is linked above.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller was 79.8% covered. If all of the below tests were added, the controller would reach at 100% coverage. We added some of these tests as part of this project and brought coverage up to 94.9%, which is a 15.1% increase. We also discovered a couple bugs when implementing the tests.&lt;br /&gt;
&lt;br /&gt;
====Create team when team exists====&lt;br /&gt;
&lt;br /&gt;
Parts of an existing test were uncommented and fixed to test this case and show coverage.&lt;br /&gt;
&lt;br /&gt;
====Update team when team exists====&lt;br /&gt;
&lt;br /&gt;
A new test was added to ensure the code properly handles the TeamExistsError which occurs if an existing team name is used.&lt;br /&gt;
&lt;br /&gt;
====Update team when team doesn't exist====&lt;br /&gt;
&lt;br /&gt;
Parts of an existing test were uncommented and fixed to test this case and show coverage.&lt;br /&gt;
&lt;br /&gt;
====Delete all when child nodes exist====&lt;br /&gt;
&lt;br /&gt;
Attempting to write a test for this method revealed that the delete_all method is currently broken in Expertiza. The code before we made any changes&lt;br /&gt;
called Team.destroy_all to delete the teams for an assignment. However, this will delete all teams, not just the teams for a assignment or course.&lt;br /&gt;
This code was commented out and a note was added to document the broken method.&lt;br /&gt;
A skipped test stub was added, but the delete_all method will need to implemented properly before the full test is written.&lt;br /&gt;
&lt;br /&gt;
====Copy to assignment when no course====&lt;br /&gt;
&lt;br /&gt;
An existing test case was fixed to test this code. The test should have been failing, but it passed because of improper checking.&lt;br /&gt;
The test code was updated to check the flash message to ensure an error is shown when an invalid course id is given.&lt;br /&gt;
The code was updated to try to actually find a course with the given id rather than just checking if the id is present.&lt;br /&gt;
&lt;br /&gt;
====Create when team parent is a Course====&lt;br /&gt;
&lt;br /&gt;
This test was not added, but adding it should d cover an additional 2 lines in the team_type method.&lt;br /&gt;
&lt;br /&gt;
==Diagrams==&lt;br /&gt;
===Overview Diagram===&lt;br /&gt;
The following diagram shows an overview of the different routes in the controller and some of their basic functionality.&lt;br /&gt;
&lt;br /&gt;
[[File:E2274_teams_controller_overview.png|700px]]&lt;br /&gt;
&lt;br /&gt;
===Use Case Diagram===&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png|700px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
===RSpec Tests=== &lt;br /&gt;
As mentioned for Issue 6, we plan to write several RSpec tests to increase test coverage of the teams_controller file by 10-20%. Specific test cases are list in the issue's section.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
====Randomize Teams Testing====&lt;br /&gt;
&lt;br /&gt;
Given you are logged in as an instructor&lt;br /&gt;
&lt;br /&gt;
* Username: ''instructor6'' Password ''password''&lt;br /&gt;
&lt;br /&gt;
And you are on the Manage Assignments page&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_AssignmentsPage.png|700px]]&lt;br /&gt;
&lt;br /&gt;
When you click on create teams for an assignment with participants&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_CreateTeams.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And you click &amp;quot;Create Team&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_Toolbar.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And enter appropriate information&lt;br /&gt;
&lt;br /&gt;
Then teams should be randomized and created&lt;br /&gt;
&lt;br /&gt;
====Bequeath all Testing====&lt;br /&gt;
&lt;br /&gt;
Given a team has been created for an assignment&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png|700px]]&lt;br /&gt;
&lt;br /&gt;
And I am on the create teams page for an assignment&lt;br /&gt;
&lt;br /&gt;
When I click &amp;quot;Bequeath All Teams&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Then I should be able to move the team from an assignment to a course&lt;br /&gt;
&lt;br /&gt;
Course teams before bequeath all:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png|700px]]&lt;br /&gt;
&lt;br /&gt;
Course teams after bequeath all:&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png|700px]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_get_team_type_const_method.png&amp;diff=147094</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - get team type const method.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_get_team_type_const_method.png&amp;diff=147094"/>
		<updated>2022-12-05T21:29:29Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: New method added for get_team_type_const to address DRY principle for E2274&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;New method added for get_team_type_const to address DRY principle for E2274&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_Removed_Methods_Changes.png&amp;diff=147092</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - Removed Methods Changes.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_Removed_Methods_Changes.png&amp;diff=147092"/>
		<updated>2022-12-05T21:27:01Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Methods removed for E2274&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Methods removed for E2274&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_DRY_fixes.png&amp;diff=147091</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_DRY_fixes.png&amp;diff=147091"/>
		<updated>2022-12-05T21:26:34Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: DRY Fixes for E2274&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;DRY Fixes for E2274&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146752</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146752"/>
		<updated>2022-11-18T23:00:56Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Manual Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to its own method that can be used in all instances. By moving this code to its own method and replacing with the previous code, it will be following the DRY princple because there's less code being repeated.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
===RSpec Tests=== &lt;br /&gt;
As mentioned for Issue 6, we plan to write several RSpec tests to increase test coverage of the teams_controller file by 10-20%. Specific test cases are list in the issue's section.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing===&lt;br /&gt;
====Randomize Teams Testing====&lt;br /&gt;
&lt;br /&gt;
Given you are logged in as an instructor&lt;br /&gt;
&lt;br /&gt;
* Username: ''instructor6'' Password ''password''&lt;br /&gt;
&lt;br /&gt;
And you are on the Manage Assignments page&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_AssignmentsPage.png]]&lt;br /&gt;
&lt;br /&gt;
When you click on create teams for an assignment with participants&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_CreateTeams.png]]&lt;br /&gt;
&lt;br /&gt;
And you click &amp;quot;Create Team&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_Toolbar.png]]&lt;br /&gt;
&lt;br /&gt;
And enter appropriate information&lt;br /&gt;
&lt;br /&gt;
Then teams should be randomized and created&lt;br /&gt;
&lt;br /&gt;
====Bequeath all Testing====&lt;br /&gt;
&lt;br /&gt;
Given a team has been created for an assignment&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png]]&lt;br /&gt;
&lt;br /&gt;
And I am on the create teams page for an assignment&lt;br /&gt;
&lt;br /&gt;
When I click &amp;quot;Bequeath All Teams&amp;quot;&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png]]&lt;br /&gt;
&lt;br /&gt;
Then I should be able to move the team from an assignment to a course&lt;br /&gt;
&lt;br /&gt;
Course teams before bequeath all:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png]]&lt;br /&gt;
&lt;br /&gt;
Course teams after bequeath all:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146750</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146750"/>
		<updated>2022-11-18T22:50:17Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 2: Dry Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to its own method that can be used in all instances. By moving this code to its own method and replacing with the previous code, it will be following the DRY princple because there's less code being repeated.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146427</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146427"/>
		<updated>2022-11-14T21:31:20Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 2: Dry Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to it's own method that can be used in all instances.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146426</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146426"/>
		<updated>2022-11-14T21:31:08Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 3: Refactor Update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to it's own method that can be used in all instances.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146424</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146424"/>
		<updated>2022-11-14T21:27:54Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Added use case diagram.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===Background===&lt;br /&gt;
In Expertiza, teams are used to allow students to work together in group projects. The teams controller is responsible for assigning students to teams, as well as performing CRUD operations. In this project we will refactor teams_controller.rb and add tests to increase test coverage. This project is a continuation of our previous work as described below, and we will build our existing code changes.&lt;br /&gt;
&lt;br /&gt;
===Previous Work===&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
==Project Overview==&lt;br /&gt;
There are several issues we plan to address as part of this project.&lt;br /&gt;
&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1: Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2: Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to it's own method that can be used in all instances.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3: Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
The code to rescue a TeamExistsError can also be removed since there will no longer be a check that could potentially throw such an error.&lt;br /&gt;
&lt;br /&gt;
===Issue 4: Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5: Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6: Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;br /&gt;
&lt;br /&gt;
==Use Case Diagram==&lt;br /&gt;
The teams controller is mainly responsible for dealing with the Team model. It can perform CRUD operations with teams and manage them on assignments and courses. It also has methods that can move the teams between them.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_use_case_diagram.png&amp;diff=146423</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - use case diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_use_case_diagram.png&amp;diff=146423"/>
		<updated>2022-11-14T21:24:32Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Use case diagram for Teams_controller.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Use case diagram for Teams_controller.rb&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146418</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146418"/>
		<updated>2022-11-14T20:57:43Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 2 Dry Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and added tests associated with its functionality. Before we worked on it, teams_controller.rb had some minor parts of a few methods that could be improved. More comments can be added to improve the readability of methods in the file as well as code more understandable for what custom methods do. Furthermore, test coverage could be improved.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
A team in spring 2022 attempted to refactor the controller as shown [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This revision modified a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, we began a new refactor which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved renaming methods, improving how teams were removed from the waitlist, and drying code. Some code was also moved to the Team model (team.rb).&lt;br /&gt;
&lt;br /&gt;
This project is a continuation of our previous work and we will build upon our existing code changes.&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1 Add Comments===&lt;br /&gt;
We plan to add comments describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2 Dry Code===&lt;br /&gt;
Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb. To fix this, we can extract the &amp;lt;code&amp;gt;Object.const_get(session[:team_type] + ... )&amp;lt;/code&amp;gt; to it's own method that can be used in all instances.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 3 Refactor Update===&lt;br /&gt;
We will analyze the update function in teams_controller.rb to see how we could refactor it to improve functionality. For example, the update method current checks to see if there is an existing team with the same id as highlighted below, but this check is not needed when updating as the team should in fact already exist.&lt;br /&gt;
[[File:Issue 3 redline.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Issue 4 Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5 Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6 Test Coverage===&lt;br /&gt;
Before starting this project, the teams controller is 79.8% covered. If all of the below tests are added, the controller reach at 100% coverage. We plan to at least add some of the tests as part of this project.&lt;br /&gt;
&lt;br /&gt;
* Create team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team exists&lt;br /&gt;
&lt;br /&gt;
* Update team when team doesn't exist&lt;br /&gt;
&lt;br /&gt;
* Delete all when child nodes exist&lt;br /&gt;
&lt;br /&gt;
* Copy to assignment when no course&lt;br /&gt;
&lt;br /&gt;
* List when team parent is a Course&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_DRY_fixes_todo_for_list_create_delete_all.png&amp;diff=146416</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - DRY fixes todo for list create delete all.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_DRY_fixes_todo_for_list_create_delete_all.png&amp;diff=146416"/>
		<updated>2022-11-14T20:55:24Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here's one fix that needs to be done that can be used to enfore the DRY principle in these the list, create, and delete_all methods in teams_controller.rb.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146409</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146409"/>
		<updated>2022-11-14T20:24:36Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issue 5 Update Translations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and added tests associated with its functionality. Before we worked on it, teams_controller.rb had some minor parts of a few methods that could be improved. More comments can be added to improve the readability of methods in the file as well as code more understandable for what custom methods do. Furthermore, test coverage could be improved.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
Prior work can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This work was done in spring 2022, and it mainly consisted of refactoring a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, work was done by us from first part of the OSS project, which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved refactoring the methods like create_teams method, which involved renaming it to randomize_teams. The delete method was refactored to improve how teams were removed from the waitlist. The inherit method was also refactored to be renamed to copy_to_assignment and part of the code was moved to the custom method copy_teams_to_collection in Team model (team.rb). Furthermore, bequeath_all was also refactored to remove nested if statements and other returns so the method is easier to follow from looking at it.&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;br /&gt;
&lt;br /&gt;
===Issue 1 Add Comments===&lt;br /&gt;
We plan to add a comment describing the functionality of the following methods.&lt;br /&gt;
&lt;br /&gt;
* list&lt;br /&gt;
&lt;br /&gt;
* new&lt;br /&gt;
&lt;br /&gt;
* update&lt;br /&gt;
&lt;br /&gt;
* edit&lt;br /&gt;
&lt;br /&gt;
* delete_all&lt;br /&gt;
&lt;br /&gt;
* delete&lt;br /&gt;
&lt;br /&gt;
===Issue 2 Dry Code===&lt;br /&gt;
&lt;br /&gt;
===Issue 3 Refactor Update===&lt;br /&gt;
&lt;br /&gt;
===Issue 4 Remove Methods===&lt;br /&gt;
We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.&lt;br /&gt;
&lt;br /&gt;
===Issue 5 Update Translations===&lt;br /&gt;
The code that may need to changed is highlighted below. The translation needs to be ensured that it is proper and the frontend needs to make sure that it's mapped to the correct phrase.&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png]]&lt;br /&gt;
&lt;br /&gt;
===Issue 6 Test Coverage===&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_hi_IN.yml_things_to_change.png&amp;diff=146407</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2274 Refactor teams controller.rb - hi IN.yml things to change.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2274_Refactor_teams_controller.rb_-_hi_IN.yml_things_to_change.png&amp;diff=146407"/>
		<updated>2022-11-14T20:22:43Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: The highlighted code may need to be changed in on these lines in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The highlighted code may need to be changed in on these lines in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146399</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146399"/>
		<updated>2022-11-14T15:36:36Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Updated current text&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and added tests associated with its functionality. Before we worked on it, teams_controller.rb had some minor parts of a few methods that could be improved. More comments can be added to improve the readability of methods in the file as well as code more understandable for what custom methods do. Furthermore, test coverage could be improved.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
Prior work can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller here]. This work was done in spring 2022, and it mainly consisted of refactoring a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.&lt;br /&gt;
&lt;br /&gt;
More recently, work was done by us from first part of the OSS project, which can be found [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb here]. This revision involved refactoring the methods like create_teams method, which involved renaming it to randomize_teams. The delete method was refactored to improve how teams were removed from the waitlist. The inherit method was also refactored to be renamed to copy_to_assignment and part of the code was moved to the custom method copy_teams_to_collection in Team model (team.rb). Furthermore, bequeath_all was also refactored to remove nested if statements and other returns so the method is easier to follow from looking at it.&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;br /&gt;
* More comments need to be added to the controller to briefly explain functionality of custom methods. &lt;br /&gt;
* Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.&lt;br /&gt;
* Try to refactor the update method to make it cleaner.&lt;br /&gt;
* There are few methods such as team_size, team_parent which will be removed.&lt;br /&gt;
* Fix the code and Hindi text in &amp;lt;code&amp;gt;config/locales/hi_IN.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Add tests to increase test coverage by 10-20% if able.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146397</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146397"/>
		<updated>2022-11-14T14:50:53Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and added tests associated with its functionality. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller&lt;br /&gt;
&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;br /&gt;
* Add more comments to the controller, briefly explain the functionality of custom methods &lt;br /&gt;
* Find out areas in the code where DRY principle can be applied (For eg. look at create and update methods to find similarity)&lt;br /&gt;
* Try to look at the waitlist functionality and simplify it.&lt;br /&gt;
* Try to look and modify the update function&lt;br /&gt;
* There are few methods team_size, team_parent which look unnecessary &lt;br /&gt;
* Try to update the config/locales/hi_IN.yml  hindi text.&lt;br /&gt;
* Try to increase the test coverage.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146394</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146394"/>
		<updated>2022-11-13T22:41:26Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Issues Being Worked on */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller&lt;br /&gt;
&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;br /&gt;
* Add more comments to the controller, briefly explain the functionality of custom methods &lt;br /&gt;
* Find out areas in the code where DRY principle can be applied (For eg. look at create and update methods to find similarity)&lt;br /&gt;
* Try to look at the waitlist functionality and simplify it.&lt;br /&gt;
* Try to look and modify the update function&lt;br /&gt;
* There are few methods team_size, team_parent which look unnecessary &lt;br /&gt;
* Try to update the config/locales/hi_IN.yml  hindi text.&lt;br /&gt;
* Try to increase the test coverage.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146393</id>
		<title>CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2274:_Refactor_teams_controller.rb&amp;diff=146393"/>
		<updated>2022-11-13T22:40:56Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Added initial things&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2022_-_E2214:_Refactor_teams_controller&lt;br /&gt;
&lt;br /&gt;
https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
==Issues Being Worked on==&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146188</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146188"/>
		<updated>2022-10-31T23:26:43Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function. This also needed to be updated in the rspec test &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  describe 'create teams method' do&lt;br /&gt;
    context 'when correct parameters are passed' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(ExpertizaLogger).to receive(:info).and_return(nil)&lt;br /&gt;
        ...&lt;br /&gt;
        user_session = { user: instructor, team_type: 'Assignment' }&lt;br /&gt;
        result = get :randomize_teams, params: request_params, session: user_session&lt;br /&gt;
        # status code 302: Redirect url&lt;br /&gt;
        ...&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Gets the model representing the parent of the team&lt;br /&gt;
  def team_type&lt;br /&gt;
    if session[:team_type] == 'Assignment'&lt;br /&gt;
      Assignment&lt;br /&gt;
    elsif session[:team_type] == 'Course'&lt;br /&gt;
      Course&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Finds the object containing the students&lt;br /&gt;
  # which the team will be generated from&lt;br /&gt;
  def team_parent&lt;br /&gt;
    @team_parent ||= team_type.find(params[:id])&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change to being able to delete from the waitlist needed to be accounted for in the &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt; rspec test, which can be seen here:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
       ...&lt;br /&gt;
      end&lt;br /&gt;
    end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
===Test Coverage===&lt;br /&gt;
Rspec test coverage of &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; fromt the main branch of expertiza:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage before refactoring.png]]&lt;br /&gt;
Rspec test coverage of &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; after our refactoring:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage after refactoring.png]]&lt;br /&gt;
&lt;br /&gt;
===Randomize Teams===&lt;br /&gt;
&lt;br /&gt;
Given you are logged in as an instructor&lt;br /&gt;
&lt;br /&gt;
* Username: ''instructor6'' Password ''password''&lt;br /&gt;
&lt;br /&gt;
And you are on the Manage Assignments page&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_AssignmentsPage.png]]&lt;br /&gt;
&lt;br /&gt;
When you click on create teams for an assignment with participants&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_CreateTeams.png]]&lt;br /&gt;
&lt;br /&gt;
And you click &amp;quot;Create Team&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_Toolbar.png]]&lt;br /&gt;
&lt;br /&gt;
And enter appropriate information&lt;br /&gt;
&lt;br /&gt;
Then teams should be randomized and created&lt;br /&gt;
&lt;br /&gt;
===Bequeath all===&lt;br /&gt;
&lt;br /&gt;
Given a team has been created for an assignment&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png]]&lt;br /&gt;
&lt;br /&gt;
And I am on the create teams page for an assignment&lt;br /&gt;
&lt;br /&gt;
When I click &amp;quot;Bequeath All Teams&amp;quot;&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png]]&lt;br /&gt;
&lt;br /&gt;
Then I should be able to move the team from an assignment to a course&lt;br /&gt;
&lt;br /&gt;
Course teams before bequeath all:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png]]&lt;br /&gt;
&lt;br /&gt;
Course teams after bequeath all:&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146187</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146187"/>
		<updated>2022-10-31T22:43:20Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function. This also needed to be updated in the rspec test &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  describe 'create teams method' do&lt;br /&gt;
    context 'when correct parameters are passed' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(ExpertizaLogger).to receive(:info).and_return(nil)&lt;br /&gt;
        ...&lt;br /&gt;
        user_session = { user: instructor, team_type: 'Assignment' }&lt;br /&gt;
        result = get :randomize_teams, params: request_params, session: user_session&lt;br /&gt;
        # status code 302: Redirect url&lt;br /&gt;
        ...&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Gets the model representing the parent of the team&lt;br /&gt;
  def team_type&lt;br /&gt;
    if session[:team_type] == 'Assignment'&lt;br /&gt;
      Assignment&lt;br /&gt;
    elsif session[:team_type] == 'Course'&lt;br /&gt;
      Course&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Finds the object containing the students&lt;br /&gt;
  # which the team will be generated from&lt;br /&gt;
  def team_parent&lt;br /&gt;
    @team_parent ||= team_type.find(params[:id])&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change to being able to delete from the waitlist needed to be accounted for in the &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt; rspec test, which can be seen here:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
       ...&lt;br /&gt;
      end&lt;br /&gt;
    end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
===Randomize Teams===&lt;br /&gt;
&lt;br /&gt;
Given you are logged in as an instructor&lt;br /&gt;
&lt;br /&gt;
* Username: ''instructor6'' Password ''password''&lt;br /&gt;
&lt;br /&gt;
And you are on the Manage Assignments page&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_AssignmentsPage.png]]&lt;br /&gt;
&lt;br /&gt;
When you click on create teams for an assignment with participants&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_CreateTeams.png]]&lt;br /&gt;
&lt;br /&gt;
And you click &amp;quot;Create Team&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:E2254_Toolbar.png]]&lt;br /&gt;
&lt;br /&gt;
And enter appropriate information&lt;br /&gt;
&lt;br /&gt;
Then teams should be randomized and created&lt;br /&gt;
&lt;br /&gt;
===Bequeath all===&lt;br /&gt;
&lt;br /&gt;
Given a team has been created for an assignment&lt;br /&gt;
&lt;br /&gt;
And I am on the create teams page for an assignment&lt;br /&gt;
&lt;br /&gt;
When I click &amp;quot;Bequeath All Teams&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then I should be able to move the team from an assignment to a course&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage before refactoring.png]]&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage after refactoring.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png]]&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png]]&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png]]&lt;br /&gt;
[[File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png]]&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_teams_for_test_assignment.png&amp;diff=146186</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - teams for test assignment.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_teams_for_test_assignment.png&amp;diff=146186"/>
		<updated>2022-10-31T22:41:40Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_coverage_before_refactoring.png&amp;diff=146185</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage before refactoring.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_coverage_before_refactoring.png&amp;diff=146185"/>
		<updated>2022-10-31T22:40:40Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_coverage_after_refactoring.png&amp;diff=146184</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - coverage after refactoring.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_coverage_after_refactoring.png&amp;diff=146184"/>
		<updated>2022-10-31T22:40:23Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_course_teams_before_bequeathing_all.png&amp;diff=146183</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams before bequeathing all.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_course_teams_before_bequeathing_all.png&amp;diff=146183"/>
		<updated>2022-10-31T22:39:59Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_course_teams_after_bequeathing_all.png&amp;diff=146182</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - course teams after bequeathing all.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_course_teams_after_bequeathing_all.png&amp;diff=146182"/>
		<updated>2022-10-31T22:36:17Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_bequeath_all_success_message.png&amp;diff=146181</id>
		<title>File:CSC-ECE 517 Fall 2022 - E2254 Refactor teams controller.rb - bequeath all success message.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CSC-ECE_517_Fall_2022_-_E2254_Refactor_teams_controller.rb_-_bequeath_all_success_message.png&amp;diff=146181"/>
		<updated>2022-10-31T22:34:31Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146003</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146003"/>
		<updated>2022-10-26T20:01:53Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Fix #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function. This also needed to be updated in the rspec test &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  describe 'create teams method' do&lt;br /&gt;
    context 'when correct parameters are passed' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        allow(ExpertizaLogger).to receive(:info).and_return(nil)&lt;br /&gt;
        ...&lt;br /&gt;
        user_session = { user: instructor, team_type: 'Assignment' }&lt;br /&gt;
        result = get :randomize_teams, params: request_params, session: user_session&lt;br /&gt;
        # status code 302: Redirect url&lt;br /&gt;
        ...&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Gets the model representing the parent of the team&lt;br /&gt;
  def team_type&lt;br /&gt;
    if session[:team_type] == 'Assignment'&lt;br /&gt;
      Assignment&lt;br /&gt;
    elsif session[:team_type] == 'Course'&lt;br /&gt;
      Course&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Finds the object containing the students&lt;br /&gt;
  # which the team will be generated from&lt;br /&gt;
  def team_parent&lt;br /&gt;
    @team_parent ||= team_type.find(params[:id])&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change to being able to delete from the waitlist needed to be accounted for in the &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt; rspec test, which can be seen here:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
       ...&lt;br /&gt;
      end&lt;br /&gt;
    end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146002</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146002"/>
		<updated>2022-10-26T20:01:28Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Fixes #4 and #6 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function. This also needed to be updated in the rspec test &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  describe 'create teams method' do&lt;br /&gt;
    context 'when correct parameters are passed' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        ...&lt;br /&gt;
        user_session = { user: instructor, team_type: 'Assignment' }&lt;br /&gt;
        result = get :randomize_teams, params: request_params, session: user_session&lt;br /&gt;
        # status code 302: Redirect url&lt;br /&gt;
        ...&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Gets the model representing the parent of the team&lt;br /&gt;
  def team_type&lt;br /&gt;
    if session[:team_type] == 'Assignment'&lt;br /&gt;
      Assignment&lt;br /&gt;
    elsif session[:team_type] == 'Course'&lt;br /&gt;
      Course&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Finds the object containing the students&lt;br /&gt;
  # which the team will be generated from&lt;br /&gt;
  def team_parent&lt;br /&gt;
    @team_parent ||= team_type.find(params[:id])&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change to being able to delete from the waitlist needed to be accounted for in the &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt; rspec test, which can be seen here:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;context 'when called and team is not nil and it does not hold a topic' do&lt;br /&gt;
      it 'deletes the team' do&lt;br /&gt;
        allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
       ...&lt;br /&gt;
      end&lt;br /&gt;
    end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146001</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=146001"/>
		<updated>2022-10-26T19:58:35Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Fix #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function. This also needed to be updated in the rspec test &amp;lt;code&amp;gt;teams_controller_spec.rb&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  describe 'create teams method' do&lt;br /&gt;
    context 'when correct parameters are passed' do&lt;br /&gt;
      it 'creates teams with random names' do&lt;br /&gt;
        ...&lt;br /&gt;
        user_session = { user: instructor, team_type: 'Assignment' }&lt;br /&gt;
        result = get :randomize_teams, params: request_params, session: user_session&lt;br /&gt;
        # status code 302: Redirect url&lt;br /&gt;
        ...&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;/code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Gets the model representing the parent of the team&lt;br /&gt;
  def team_type&lt;br /&gt;
    if session[:team_type] == 'Assignment'&lt;br /&gt;
      Assignment&lt;br /&gt;
    elsif session[:team_type] == 'Course'&lt;br /&gt;
      Course&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Finds the object containing the students&lt;br /&gt;
  # which the team will be generated from&lt;br /&gt;
  def team_parent&lt;br /&gt;
    @team_parent ||= team_type.find(params[:id])&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145999</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145999"/>
		<updated>2022-10-26T19:53:47Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
==Issues Fixed==&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
==Files Changed==&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
===Fix #2===&lt;br /&gt;
The &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; method's name poorly reflected it's actual function. The function takes a group of students from an assignment or course and creates randomized teams. To reflect this, the method was renamed to &amp;lt;code&amp;gt;randomize_teams&amp;lt;/code&amp;gt; and a comment was added briefly describing the function.&lt;br /&gt;
&lt;br /&gt;
===Fix #3===&lt;br /&gt;
Several places used a complicated line to find the parent of a team. The parent is either a &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or an &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt;. The type of parent is stored in the &amp;lt;code&amp;gt;session&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; of the parent in the &amp;lt;code&amp;gt;params&amp;lt;code&amp;gt;. We created two new private methods, &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; to DRY out the code. The &amp;lt;code&amp;gt;team_type&amp;lt;/code&amp;gt; method returns either &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Assignment&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;team_parent&amp;lt;/code&amp;gt; method returns the the actual parent rather than the model.&lt;br /&gt;
&lt;br /&gt;
===Fixes #4 and #6===&lt;br /&gt;
Removed the following if statement editing a waitlist in a controller and replaced it with &amp;lt;code&amp;gt;Waitlist.remove_from_waitlists(@team.id)&amp;lt;/code&amp;gt;.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
  #   # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
  #   topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
  #   next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
  #   # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
  #   SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
# end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
In the process of making this change, the unused &amp;lt;code&amp;gt;@signUps&amp;lt;/code&amp;gt; variable is removed, taking care of Fix #6 as well.&lt;br /&gt;
The change in how things were deleted from waitlists and how things were deleted from signed up teams led to issues with rspec testing in &amp;lt;code&amp;gt;airbrake_exception_errors_controller_tests_spec.rb&amp;lt;/code&amp;gt;. To fix this, we allowed functionality to account for what was changed:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;    it 'will delete the team if current team did not involve in any other reviews' do&lt;br /&gt;
      ...&lt;br /&gt;
      controller.session[:team_type] = 'Assignment'&lt;br /&gt;
&lt;br /&gt;
      allow(SignedUpTeam).to receive(:destroy).and_return(nil)&lt;br /&gt;
      allow(Waitlist).to receive(:remove_from_waitlists).and_return(nil)&lt;br /&gt;
      allow(Team).to receive(:find).with(any_args).and_return(team)&lt;br /&gt;
      allow(Team).to receive(:find_by).with(any_args).and_return(team)&lt;br /&gt;
      ...&lt;br /&gt;
      end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fixes #7 and #8===&lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fix #9===&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145993</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145993"/>
		<updated>2022-10-26T19:14:30Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: added info for fixes 8 and 9&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
=Issues Fixed=&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;random_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated.&lt;br /&gt;
#* Changed the delete method to use the existing Waitlist.remove_from_waitlists method to handle removing the deleted team from all waitlists&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
#* Actually ended up removing this variable in the process of doing fix 4 above&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
=Files Changed=&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Changes=&lt;br /&gt;
* Fixes #7 and #8: &lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
# used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
# teams from assignments to courses and vice versa.&lt;br /&gt;
def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
  teams.each do |team|&lt;br /&gt;
    team.copy(recipient_collection_id)&lt;br /&gt;
  end&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def copy_to_assignment&lt;br /&gt;
  ...&lt;br /&gt;
  if teams.empty?&lt;br /&gt;
    flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
  else&lt;br /&gt;
    Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
  end&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;def bequeath_all&lt;br /&gt;
  ...&lt;br /&gt;
  teams = assignment.teams&lt;br /&gt;
  Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
  flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
  ...&lt;br /&gt;
end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fix #9:&lt;br /&gt;
Refactored bequeath_all to get rid of all the nested if statements&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Copies existing teams from an assignment to a&lt;br /&gt;
  # course if the course doesn't already have teams&lt;br /&gt;
  def bequeath_all&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    course = Course.find(assignment.course_id) if assignment.course_id&lt;br /&gt;
&lt;br /&gt;
    if !assignment.course_id&lt;br /&gt;
      flash[:error] = 'No course was found for this assignment.'&lt;br /&gt;
    elsif course.course_teams.any?&lt;br /&gt;
      flash[:error] = 'The course already has associated teams'&lt;br /&gt;
    else&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Also, the multiple returns have been removed from the method. The redirect and return for the check to ensure &lt;br /&gt;
a course team was being used was moved to it's own method:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;  # Redirects if the team is not a CourseTeam&lt;br /&gt;
  def ensure_course_team&lt;br /&gt;
    if session[:team_type] == 'Course'&lt;br /&gt;
      flash[:error] = 'Invalid team type for bequeathal'&lt;br /&gt;
      redirect_to controller: 'teams', action: 'list', id: params[:id]&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and specified to run at before the &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; method at the start of the file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;before_action :ensure_course_team, only: %i[bequeath_all]&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145733</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145733"/>
		<updated>2022-10-25T19:57:28Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Started adding in changed code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
=Issues Fixed=&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;random_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated. ----- John if you could describe briefly what you did here that'd be great -----&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
=Files Changed=&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
* spec/controllers/teams_controller.rb&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Changes=&lt;br /&gt;
* Fix #7: &lt;br /&gt;
One of the main changes made to implement this was in &amp;lt;code&amp;gt;Team.rb&amp;lt;/code&amp;gt; where the class method &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt; was added.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;# E2254 : This method copies a list of teams to another collection. It is mainly&lt;br /&gt;
  # used in the Team model for copy_to_assignment and bequeath_all for the purpose of copying&lt;br /&gt;
  # teams from assignments to courses and vice versa.&lt;br /&gt;
  def self.copy_teams_to_collection(teams, recipient_collection_id)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      team.copy(recipient_collection_id)&lt;br /&gt;
    end&lt;br /&gt;
  end&amp;lt;/code&amp;gt;&lt;br /&gt;
This method was called in &amp;lt;code&amp;gt;teams_controller.rb&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; (method used to be named &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt;) and &amp;lt;code&amp;gt;bequeath_all&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&amp;lt;code&amp;gt;def copy_to_assignment&lt;br /&gt;
   ...&lt;br /&gt;
      if teams.empty?&lt;br /&gt;
        flash[:note] = 'No teams were found when trying to copy to assignment.'&lt;br /&gt;
      else&lt;br /&gt;
        Team.copy_teams_to_collection(teams, assignment.id)&lt;br /&gt;
      end&lt;br /&gt;
   ...&lt;br /&gt;
end&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;def bequeath_all&lt;br /&gt;
   ...&lt;br /&gt;
      teams = assignment.teams&lt;br /&gt;
      Team.copy_teams_to_collection(teams, course.id)&lt;br /&gt;
      flash[:note] = teams.length.to_s + ' teams were successfully copied to &amp;quot;' + course.name + '&amp;quot;'&lt;br /&gt;
   ...&lt;br /&gt;
end&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145729</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145729"/>
		<updated>2022-10-25T18:27:07Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: Added files changed bullets&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
=Issues Fixed=&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;random_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated. ----- John if you could describe briefly what you did here that'd be great -----&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;br /&gt;
&lt;br /&gt;
=Files Changed=&lt;br /&gt;
* app/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
&lt;br /&gt;
* app/views/teams/new.html.erb&lt;br /&gt;
&lt;br /&gt;
* config/locales/en_US.yml&lt;br /&gt;
&lt;br /&gt;
* config/locales/en_IN.yml&lt;br /&gt;
&lt;br /&gt;
* config/routes.rb&lt;br /&gt;
&lt;br /&gt;
* spec/controllers/teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
* spec/controllers/airbrake_exception_errors_controller_tests_spec.rb&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145728</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145728"/>
		<updated>2022-10-25T18:18:34Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;br /&gt;
&lt;br /&gt;
=Issues Fixed=&lt;br /&gt;
# Added more comments and briefly explained the functionality of custom methods like &amp;lt;code&amp;gt;action_allowed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
# Changed method name of &amp;lt;code&amp;gt;create_teams&amp;lt;/code&amp;gt; to a better name: &amp;lt;code&amp;gt;random_teams&amp;lt;/code&amp;gt;&lt;br /&gt;
# Found areas in the code where the DRY principle can be applied and did so&lt;br /&gt;
# The delete method manipulates a waitlist! This needs to be done in a model class, e.g., SignedUpTeam. And also check if this code is already present in the model or not. Explore the code base to find where else waitlist is manipulated. ----- John if you could describe briefly what you did here that'd be great -----&lt;br /&gt;
# Removed all extra added gems&lt;br /&gt;
# Renamed variable signUps to signups because it's a noun&lt;br /&gt;
# Moved list copying code from the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to be a class method of the Team model: &amp;lt;code&amp;gt;copy_teams_to_collection&amp;lt;/code&amp;gt;. Also replaced identical code in bequeath_all to also use this class method.&lt;br /&gt;
# Changed the name of the &amp;lt;code&amp;gt;inherit&amp;lt;/code&amp;gt; method to &amp;lt;code&amp;gt;copy_to_assignment&amp;lt;/code&amp;gt; so the name is more descriptive of it's purpose&lt;br /&gt;
# Removed nested if statments and removed other return points from bequeath_all&lt;br /&gt;
# Removed unnecessary comments for methods like &amp;lt;code&amp;gt;update&amp;lt;/code&amp;gt; and added meaningful comments to other methods&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145726</id>
		<title>CSC/ECE 517 Fall 2022 - E2254: Refactor teams controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2022_-_E2254:_Refactor_teams_controller.rb&amp;diff=145726"/>
		<updated>2022-10-25T17:36:36Z</updated>

		<summary type="html">&lt;p&gt;Jrlanois: In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Introduction===&lt;br /&gt;
In this project we refactored teams_controller.rb and some tests associated with it. Before we worked on it, teams_controller.rb had some problems that violated some essential Rails design principles. Some methods have been moved to the teams.rb model class. Some duplicate code was removed. We added some comments for readability. And, we fixed tests to be more consistent with the program and execution.&lt;/div&gt;</summary>
		<author><name>Jrlanois</name></author>
	</entry>
</feed>