CSC/ECE 517 Fall 2022 - E2256: Refactor late policies controller.rb

From Expertiza_Wiki
Revision as of 02:14, 25 October 2022 by Kkotak (talk | contribs) (→‎E2256. Refactor late_policies_controller.rb)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Background

The SCRUM from late policies is managed by the later policies controller. The file primarily determines whether newly added or updated late policies are valid policies by ensuring that they do not share the same name as an already existing policy. The file also ensures that the late penalty per unit of time is less than the maximum late penalty, and restricts late penalty to have a maximum value of 100.

Teams Members

Kalgee Anand Kotak (kkotak)
Ashrita Ramaswamy (aramasw)
Nitish Kumar Murali (nmurali2)

Description about project

This wiki describes the work done to refactor late policies controller.rb. The main goals of the effort were to eliminate redundant code and to make the create and update methods' code easier to read. This also includes adding code comments for understandability.

Files Modified

  • app/controllers/late_policies_controller.rb
  • app/views/late_policies/new.html.erb
  • app/views/late_policies/_form.html.erb
  • app/views/late_policies/show.html.erb
  • app/views/late_policies/edit.html.erb
  • app/views/late_policies/index.html.erb
  • spec/controllers/late_policies_controller_spec.rb

Issues Fixed

We worked on the following Issues (I#)
I1 : Rename all usages of @penalty_policy to @late_policy within the controller as well as the views
I2 : Refactor the method “duplicate_name_check” such that it doesn’t violate the Single Responsibility Principle. Use a better name than “duplicate_name_check”
I3 : Make the validate_input method as “stateless” as possible.
I4 : Update the code so that initially you assume that the penalty is NOT VALID, and then you need to verify that it is valid during validation.
I5 : Use local variables instead of instance variables in the create and update method.
I6 : Add RSpec tests