The Refactoring
After a two hour Developer Meeting for Redmine this morning, I’m too drained to tackle the entire refactoring for #find_optional_project
. I did use pull up method to remove the duplication in the GanttsController
and IssuesController
though.
Before
1
2
3
4
5
6
7
|
# app/controllers/issues_controller.rb
class IssuesController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end |
# app/controllers/issues_controller.rb
class IssuesController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end
1
2
3
4
5
6
7
|
# app/controllers/gantts_controller.rb
class GanttsController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end |
# app/controllers/gantts_controller.rb
class GanttsController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end
1
2
3
4
|
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# ...
end |
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# ...
end
After
1
2
3
4
|
# app/controllers/issues_controller.rb
class IssuesController < ApplicationController
# ...
end |
# app/controllers/issues_controller.rb
class IssuesController < ApplicationController
# ...
end
1
2
3
4
|
# app/controllers/gantts_controller.rb
class GanttsController < ApplicationController
# ...
end |
# app/controllers/gantts_controller.rb
class GanttsController < ApplicationController
# ...
end
1
2
3
4
5
6
7
|
# app/controllers/application_controller.rb
class ApplicationController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end |
# app/controllers/application_controller.rb
class ApplicationController params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end
Review
This finishes up my refactoring of the GanttsController
. I’m leaving the refactoring of the other duplicated #find_optional_project
methods for another time.
Reference commit