diff --git a/app/controllers/application.rb b/app/controllers/application.rb index d3a33f1..cfbcabb 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -12,14 +12,11 @@ class ApplicationController < ActionController::Base extend PermissionCheck init_gettext 'noosfero' + include NeedsProfile + before_filter :detect_stuff_by_domain attr_reader :environment - def self.needs_profile - before_filter :load_profile - design :holder => 'profile' - end - def self.acts_as_environment_admin_controller before_filter :load_admin_controller end @@ -32,10 +29,6 @@ class ApplicationController < ActionController::Base protected - def profile - @profile - end - # TODO: move this logic somewhere else (Domain class?) def detect_stuff_by_domain @domain = Domain.find_by_name(request.host) diff --git a/app/controllers/profile_admin/cms_controller.rb b/app/controllers/profile_admin/cms_controller.rb index fe349a2..55d4c0d 100644 --- a/app/controllers/profile_admin/cms_controller.rb +++ b/app/controllers/profile_admin/cms_controller.rb @@ -1,7 +1,7 @@ -class CmsController < ComatoseAdminController +class CmsController < Comatose::AdminController extend PermissionCheck - ApplicationController.needs_profile + needs_profile define_option :page_class, Article diff --git a/config/environment.rb b/config/environment.rb index fba6a60..980a9e5 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -84,6 +84,7 @@ Comatose.configure do |config| # FIXME: also check permissions end config.admin_includes << :authenticated_system + config.admin_includes << :needs_profile config.admin_helpers << :application_helper config.admin_helpers << :document_helper config.admin_helpers << :language_helper diff --git a/lib/needs_profile.rb b/lib/needs_profile.rb new file mode 100644 index 0000000..4b2708c --- /dev/null +++ b/lib/needs_profile.rb @@ -0,0 +1,20 @@ +module NeedsProfile + + module ClassMethods + def needs_profile + before_filter :load_profile + design :holder => 'profile' + end + end + + def self.included(including) + including.send(:extend, NeedsProfile::ClassMethods) + end + + protected + + def profile + @profile + end + +end diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index cd739aa..d74782c 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -11,8 +11,7 @@ class CmsControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new end - # Replace this with your real tests. - def test_truth - assert true + def test_missing + flunk 'need to add some tests for CmsController ' end end -- libgit2 0.21.2