The Refactoring AuthSourceLdap#authenticate still can use some more refactoring. I performed another extract method, this time to create a method to authenticate an DN (Distinguished Name). Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 # app/models/auth_source_ldap.rb class AuthSourceLdap self.base_dn, :filter …
Tag: ruby
Daily Refactor #17: Extract method in AuthSourceLdap
Since I’ve been doing a lot of work on a Redmine plugin to add more LDAP features, I decided to use today to refactor some of Redmine’s LDAP code. The Refactoring I just performed a simple extract method refactoring on the authenticate method in AuthSourceLdap to make it easier to understand what it does with …
Daily Refactor #16: Rename method in RolesController
The Refactoring I’m continuing last Friday’s refactor today, but this time renaming the method in RolesController. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # app/controllers/roles_controller.rb class RolesController :post, :only => [ :destroy, :move ], :redirect_to => { :action => :list } def index list …
Daily Refactor #15: Rename method in IssueStatusesController
It’s time to move on from the ReportsController to code that needs to be refactored more. Using Caliper’s Flay Report, it looks like IssueStatusesController, TrackersController, AuthSourcesController, and RolesController all have the exact same index action. 1 2 3 4 def index list render :action => 'list' unless request.xhr? end def index list render :action => …
Daily Refactor #14: Extract method to before_filter in ReportsController
The Refactoring I started on a larger refactoring of the issue_report_details method today but found a potential security bug so I threw it away. It’s better to be secure than refactored :) So instead, I performed a common Rails refactoring for removing duplicate code: extracting some code to a before filter. Before 1 2 3 …