CSC/ECE 517 Fall 2020 - E2069. refactor suggestions controller
Background
The suggestions_controller.rb of Expertiza is involved in creating/editing suggestions topic suggestions for a project and involved approvals. Students can submit suggestions and work on them if approved.
Motivation
We intend to improve the readability and code quality of the suggestions_controller.rb. Since this controller has methods that must actually be done by other classes (owing to Single Responsibility feature of the SOLID principles), we have realized the need to move these methods to their respective classes.
Issues to Fix
1. Move the method create_new_team (on line 94) to a more appropriate class. (Ex: Team.rb or AssignmentTeam.rb) 2. Move the method approve to SignupTopic.rb, since it is modifying fields belonging to SignupTopic directly. 3. There are two methods named similarly: approve and approve_suggestion. Their functionality is not clear at first glance. Rename them so that they more accurately reflect their purpose. Add appropriate comments. 4. Move the send_email method to the Mailer class in app/mailers/mailer.rb. 5. In views/suggestion/show.html.erb and views/suggestion/student_view.html.erb, there seems to be a DRY violation which needs to be fixed. Merge both files into a single view file in order to fix the DRY problem.
Code Review
Issue: Move the method create_new_team to a more appropriate class. This method was moved to teams_controller.rb since it is appropriate. We pass the required variables inside the scope of this function as method parameters.
<IMAGE>
Issue: Move the send_email method to the Mailer class. This method was moved to the Mailer.rb file which seems to have many built-in functionalities for mail services. So we transferred the send_email method here and passed parameters from suggestion_controller.
<IMAGE>
<ADD ISSUE>
<ADD ISSUE>
<ADD ISSUE>
Test Cases
Below test cases were added/updated to ensure the correctness of our work.
<ADD TEST CASE LOGIC>