diff options
author | José Valim <jose.valim@gmail.com> | 2010-02-01 11:40:27 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-01 11:40:27 +0100 |
commit | 0dece7929cf5b04f008640936fb3ece24ce80daa (patch) | |
tree | 4e21b6c9c1e89a80a0f91e3ef27334755a6d26e7 | |
parent | a8c5d22c230ae46f410eed68c9b63ed31379ebbf (diff) | |
download | rails-0dece7929cf5b04f008640936fb3ece24ce80daa.tar.gz rails-0dece7929cf5b04f008640936fb3ece24ce80daa.tar.bz2 rails-0dece7929cf5b04f008640936fb3ece24ce80daa.zip |
Deprecate AC configuration values which were moved to Rack.
-rw-r--r-- | actionpack/lib/action_controller/metal/compatibility.rb | 28 | ||||
-rw-r--r-- | railties/builtin/rails_info/rails/info_controller.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 4 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/middleware_test.rb | 2 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 8 |
7 files changed, 41 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 2be0fa097e..1d4a719aa6 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -15,9 +15,6 @@ module ActionController cattr_accessor :session_options self.session_options = {} - cattr_accessor :allow_concurrency - self.allow_concurrency = false - cattr_accessor :relative_url_root self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] @@ -44,9 +41,6 @@ module ActionController self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : "" - cattr_accessor :consider_all_requests_local - self.consider_all_requests_local = true - # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, # and images to a dedicated asset server away from the main web server. Example: # ActionController::Base.asset_host = "http://assets.example.com" @@ -74,6 +68,25 @@ module ActionController module ClassMethods def consider_all_requests_local + ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local is deprecated, " << + "use Rails.application.config.consider_all_requests_local instead" + Rails.application.config.consider_all_requests_local + end + + def consider_all_requests_local=(value) + ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is no longer effective. " << + "Please configure it on your application with config.consider_all_requests_local=" + end + + def allow_concurrency + ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency is deprecated, " << + "use Rails.application.config.allow_concurrency instead" + Rails.application.config.allow_concurrency + end + + def allow_concurrency=(value) + ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is no longer effective. " << + "Please configure it on your application with config.allow_concurrency=" end def rescue_action(env) @@ -86,6 +99,9 @@ module ActionController end end + delegate :consider_all_requests_local, :consider_all_requests_local=, + :allow_concurrency, :allow_concurrency=, :to => :"self.class" + def render_to_body(options) if options.is_a?(Hash) && options.key?(:template) options[:template].sub!(/^\//, '') diff --git a/railties/builtin/rails_info/rails/info_controller.rb b/railties/builtin/rails_info/rails/info_controller.rb index 47e87c5bf5..196eeb4a6c 100644 --- a/railties/builtin/rails_info/rails/info_controller.rb +++ b/railties/builtin/rails_info/rails/info_controller.rb @@ -1,9 +1,15 @@ class Rails::InfoController < ActionController::Base def properties - if consider_all_requests_local || local_request? + if consider_all_requests_local? || local_request? render :inline => Rails::Info.to_html else render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden end end + + protected + + def consider_all_requests_local? + Rails.application.config.consider_all_requests_local + end end diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 31787b5cc9..d6ad045294 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -5,7 +5,7 @@ module Rails class Configuration < ::Rails::Engine::Configuration include ::Rails::Configuration::Deprecated - attr_accessor :cache_classes, :cache_store, :colorize_logging, + attr_accessor :allow_concurrency, :cache_classes, :cache_store, :colorize_logging, :consider_all_requests_local, :dependency_loading, :filter_parameters, :log_level, :logger, :metals, :plugins, :preload_frameworks, :reload_engines, :reload_plugins, @@ -13,11 +13,13 @@ module Rails def initialize(*) super + @allow_concurrency = false @colorize_logging = true @filter_parameters = [] @dependency_loading = true @serve_static_assets = true @time_zone = "UTC" + @consider_all_requests_local = true end def paths @@ -50,7 +52,7 @@ module Rails self.preload_frameworks = true self.cache_classes = true self.dependency_loading = false - self.action_controller.allow_concurrency = true if respond_to?(:action_controller) + self.allow_concurrency = true self end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index a7519397a6..7887a5d25f 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -8,10 +8,10 @@ module Rails def middleware @@default_middleware_stack ||= ActionDispatch::MiddlewareStack.new.tap do |middleware| middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets }) - middleware.use('::Rack::Lock', :if => lambda { !ActionController::Base.allow_concurrency }) + middleware.use('::Rack::Lock', :if => lambda { !Rails.application.config.allow_concurrency }) middleware.use('::Rack::Runtime') middleware.use('::Rails::Rack::Logger') - middleware.use('::ActionDispatch::ShowExceptions', lambda { ActionController::Base.consider_all_requests_local }) + middleware.use('::ActionDispatch::ShowExceptions', lambda { Rails.application.config.consider_all_requests_local }) middleware.use('::ActionDispatch::Callbacks', lambda { !Rails.application.config.cache_classes }) middleware.use('::ActionDispatch::Cookies') middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options }) diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 60d644bd59..56f45582c8 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -93,7 +93,7 @@ module ApplicationTests RUBY require "#{app_path}/config/application" - assert AppTemplate::Application.config.action_controller.allow_concurrency + assert AppTemplate::Application.config.allow_concurrency end test "the application can be marked as threadsafe when there are no frameworks" do diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 0b92cdba54..ce9cd510a3 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -39,7 +39,7 @@ module ApplicationTests end test "removes lock if allow concurrency is set" do - add_to_config "config.action_controller.allow_concurrency = true" + add_to_config "config.allow_concurrency = true" boot! assert !middleware.include?("Rack::Lock") end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index edab27465e..4163fb2c6d 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -17,23 +17,23 @@ class InfoControllerTest < ActionController::TestCase ActionController::Routing::Routes.draw do |map| match ':controller/:action' end - @controller.stubs(:consider_all_requests_local => false, :local_request? => true) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => true) end test "info controller does not allow remote requests" do - @controller.stubs(:consider_all_requests_local => false, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => false) get :properties assert_response :forbidden end test "info controller renders an error message when request was forbidden" do - @controller.stubs(:consider_all_requests_local => false, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => false) get :properties assert_select 'p' end test "info controller allows requests when all requests are considered local" do - @controller.stubs(:consider_all_requests_local => true, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => true, :local_request? => false) get :properties assert_response :success end |