The Refactoring Today I cleaned up one of the duplications from yesterday’s refactoring, using pull up method. Before 1 2 3 4 5 6 7 8 9 # app/controllers/issues_controller.rb class IssuesController < ApplicationController def query_statement_invalid(exception) logger.error "Query::StatementInvalid: #{exception.message}" if logger session.delete(:query) sort_clear render_error "An error occurred while executing the query and has been logged. Please …
Daily Refactor #65: Extract Gantt to a new controller
The Refactoring Today I finally tackled a larger refactoring that I’ve been wanting to do for awhile now. Redmine’s IssuesController has accumulated a lot of extra actions over the years, one of which is an action that renders a Gantt chart. This has never made sense to me, since the Gantt chart collects a bunch …
Daily Refactor #64: Move Method to QueriesHelper
The Refactoring To continue refactoring Redmine’s IssuesController, I used move method to move a utility method to the QueriesHelper. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 …
Daily Refactor #63: Extract Method to before_filter in IssuesController
The Refactoring Mark Thomas pointed out some odd code in Redmine’s IssuesController#build_new_issue_from_params, specifically that it’s doing some error checking in the middle of a method body. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 # …
Daily Refactor #62: Extract Method in IssuesController
The Refactoring Today’s refactoring follows up on yesterday’s. Now that I have the #new and #create actions for REST, I can start to remove the duplication I introduced. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 …