[Git][noosfero/noosfero][master] concerns: Organize existing concerns in application controller

Bráulio Bhavamitra gitlab at mg.gitlab.com
Sat Jul 16 12:01:58 BRT 2016


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
f678092a by Braulio Bhavamitra at 2016-07-16T12:01:33-03:00
concerns: Organize existing concerns in application controller

- - - - -


6 changed files:

- app/controllers/application_controller.rb
- app/concerns/authenticated_system.rb → app/controllers/concerns/authenticated_system.rb
- app/helpers/design_helper.rb → app/controllers/concerns/custom_design.rb
- lib/needs_profile.rb → app/controllers/concerns/needs_profile.rb
- config/initializers/00_dependencies.rb
- test/unit/design_helper_test.rb → test/unit/custom_design_test.rb


Changes:

=====================================
app/controllers/application_controller.rb
=====================================
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,6 +14,20 @@ class ApplicationController < ActionController::Base
   before_filter :redirect_to_current_user
 
   before_filter :set_session_theme
+
+  # FIXME: only include necessary methods
+  include ApplicationHelper
+
+  # concerns
+  include PermissionCheck
+  include CustomDesign
+  include NeedsProfile
+
+  # implementations
+  include FindByContents
+  include Noosfero::Plugin::HotSpot
+  include SearchTermHelper
+
   def set_session_theme
     if params[:theme]
       session[:theme] = environment.theme_ids.include?(params[:theme]) ? params[:theme] : nil
@@ -48,7 +62,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  include ApplicationHelper
   layout :get_layout
   def get_layout
     return false if request.format == :js or request.xhr?
@@ -74,9 +87,6 @@ class ApplicationController < ActionController::Base
   helper :document
   helper :language
 
-  include DesignHelper
-  include PermissionCheck
-
   before_filter :set_locale
   def set_locale
     FastGettext.available_locales = environment.available_locales
@@ -89,8 +99,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  include NeedsProfile
-
   attr_reader :environment
 
   # declares that the given <tt>actions</tt> cannot be accessed by other HTTP
@@ -151,8 +159,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  include Noosfero::Plugin::HotSpot
-
   # FIXME this filter just loads @plugins to children controllers and helpers
   def init_noosfero_plugins
     plugins
@@ -184,9 +190,6 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  include SearchTermHelper
-  include FindByContents
-
   def find_suggestions(query, context, asset, options={})
     plugins.dispatch_first(:find_suggestions, query, context, asset, options)
   end


=====================================
app/concerns/authenticated_system.rb → app/controllers/concerns/authenticated_system.rb
=====================================
--- a/app/concerns/authenticated_system.rb
+++ b/app/controllers/concerns/authenticated_system.rb


=====================================
app/helpers/design_helper.rb → app/controllers/concerns/custom_design.rb
=====================================
--- a/app/helpers/design_helper.rb
+++ b/app/controllers/concerns/custom_design.rb
@@ -1,4 +1,4 @@
-module DesignHelper
+module CustomDesign
 
   extend ActiveSupport::Concern
 


=====================================
lib/needs_profile.rb → app/controllers/concerns/needs_profile.rb
=====================================
--- a/lib/needs_profile.rb
+++ b/app/controllers/concerns/needs_profile.rb


=====================================
config/initializers/00_dependencies.rb
=====================================
--- a/config/initializers/00_dependencies.rb
+++ b/config/initializers/00_dependencies.rb
@@ -25,6 +25,5 @@ require 'acts_as_customizable'
 require 'route_if'
 require 'maybe_add_http'
 require 'set_profile_region_from_city_state'
-require 'needs_profile'
 require 'white_list_filter'
 


=====================================
test/unit/design_helper_test.rb → test/unit/custom_design_test.rb
=====================================
--- a/test/unit/design_helper_test.rb
+++ b/test/unit/custom_design_test.rb
@@ -1,9 +1,8 @@
 require_relative "../test_helper"
-require 'boxes_helper'
 
-class DesignHelperTest < ActionView::TestCase
+class CustomDesignTest < ActionView::TestCase
 
-  include DesignHelper
+  include CustomDesign
   include ActionView::Helpers::TagHelper
 
   def setup



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/f678092a250e2d5fe937dff638e67b155a5ae687
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160716/4bce2a59/attachment-0001.html>


More information about the Noosfero-dev mailing list