diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 4551dd9f74..da27edd68c 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -324,8 +324,6 @@ module ActionController #:nodoc: unless @controller_path components = self.name.to_s.split('::') components[-1] = $1 if /^(.*)Controller$/ =~ components.last - # Accomodate the root Controllers module. - components.shift if components.first == 'Controllers' @controller_path = components.map { |name| name.underscore }.join('/') end diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 19675605d4..e2d97b8fa0 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -109,7 +109,7 @@ module ActionController #:nodoc: private def default_helper_module! - module_name = name.sub(/^Controllers::/, '').sub(/Controller$|$/, 'Helper') + module_name = name.sub(/Controller$|$/, 'Helper') module_path = module_name.split('::').map { |m| m.underscore }.join('/') require_dependency module_path helper module_name.constantize @@ -128,7 +128,7 @@ module ActionController #:nodoc: rescue MissingSourceFile => e raise unless e.is_missing?("helpers/#{child.controller_path}_helper") end - end + end end end end diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 9687aa2748..10a3e0ce35 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -2,68 +2,57 @@ require File.dirname(__FILE__) + '/../abstract_unit' require 'test/unit' require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late -# This file currently contains a few controller UTs -# I couldn't find where the current base tests are, so I created this file. -# If there aren't any base-specific UTs, then this file should grow as they -# are written. If there are, or there is a better place for these, then I will -# move them to the correct location. -# -# Nicholas Seckar aka. Ulysses - -# Provide a static version of the Controllers module instead of the auto-loading version. -# We don't want these tests to fail when dependencies are to blame. -module Controllers - module Submodule - class ContainedEmptyController < ActionController::Base - end - class ContainedNonEmptyController < ActionController::Base - def public_action - end - - hide_action :hidden_action - def hidden_action - end - - def another_hidden_action - end - hide_action :another_hidden_action - end - class SubclassedController < ContainedNonEmptyController - hide_action :public_action # Hiding it here should not affect the superclass. - end +# Provide some controller to run the tests on. +module Submodule + class ContainedEmptyController < ActionController::Base end - class EmptyController < ActionController::Base - include ActionController::Caching - end - class NonEmptyController < ActionController::Base + class ContainedNonEmptyController < ActionController::Base def public_action end hide_action :hidden_action def hidden_action end + + def another_hidden_action + end + hide_action :another_hidden_action + end + class SubclassedController < ContainedNonEmptyController + hide_action :public_action # Hiding it here should not affect the superclass. + end +end +class EmptyController < ActionController::Base + include ActionController::Caching +end +class NonEmptyController < ActionController::Base + def public_action + end + + hide_action :hidden_action + def hidden_action end end class ControllerClassTests < Test::Unit::TestCase def test_controller_path - assert_equal 'empty', Controllers::EmptyController.controller_path - assert_equal 'submodule/contained_empty', Controllers::Submodule::ContainedEmptyController.controller_path + assert_equal 'empty', EmptyController.controller_path + assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path end def test_controller_name - assert_equal 'empty', Controllers::EmptyController.controller_name - assert_equal 'contained_empty', Controllers::Submodule::ContainedEmptyController.controller_name + assert_equal 'empty', EmptyController.controller_name + assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name end end class ControllerInstanceTests < Test::Unit::TestCase def setup - @empty = Controllers::EmptyController.new - @contained = Controllers::Submodule::ContainedEmptyController.new - @empty_controllers = [@empty, @contained, Controllers::Submodule::SubclassedController.new] + @empty = EmptyController.new + @contained = Submodule::ContainedEmptyController.new + @empty_controllers = [@empty, @contained, Submodule::SubclassedController.new] - @non_empty_controllers = [Controllers::NonEmptyController.new, - Controllers::Submodule::ContainedNonEmptyController.new] + @non_empty_controllers = [NonEmptyController.new, + Submodule::ContainedNonEmptyController.new] end def test_action_methods diff --git a/actionpack/test/controller/benchmark_test.rb b/actionpack/test/controller/benchmark_test.rb index 7e19376101..f346e575e3 100644 --- a/actionpack/test/controller/benchmark_test.rb +++ b/actionpack/test/controller/benchmark_test.rb @@ -1,17 +1,14 @@ require File.dirname(__FILE__) + '/../abstract_unit' require 'test/unit' -# Provide a static version of the Controllers module instead of the auto-loading version. -# We don't want these tests to fail when dependencies are to blame. -module Controllers - class BenchmarkedController < ActionController::Base - def public_action - render :nothing => true - end +# Provide some static controllers. +class BenchmarkedController < ActionController::Base + def public_action + render :nothing => true + end - def rescue_action(e) - raise e - end + def rescue_action(e) + raise e end end @@ -22,7 +19,7 @@ class BenchmarkTest < Test::Unit::TestCase end def setup - @controller = Controllers::BenchmarkedController.new + @controller = BenchmarkedController.new # benchmark doesn't do anything unless a logger is set @controller.logger = MockLogger.new @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new diff --git a/activesupport/lib/active_support/core_ext/class/removal.rb b/activesupport/lib/active_support/core_ext/class/removal.rb index 628781669d..b217c1957c 100644 --- a/activesupport/lib/active_support/core_ext/class/removal.rb +++ b/activesupport/lib/active_support/core_ext/class/removal.rb @@ -8,17 +8,17 @@ class Class #:nodoc: end def remove_class(*klasses) - klasses.each do |klass| + klasses.flatten.each do |klass| # Skip this class if there is nothing bound to this name next unless defined?(klass.name) - + basename = klass.to_s.split("::").last parent = klass.parent - + # Skip this class if it does not match the current one bound to this name next unless parent.const_defined?(basename) && klass = parent.const_get(basename) - + parent.send :remove_const, basename unless parent == klass end end -end \ No newline at end of file +end diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 6d5adb6605..b82c7e56f3 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -98,10 +98,6 @@ class Module #:nodoc: # Use const_missing to autoload associations so we don't have to # require_association when using single-table inheritance. def const_missing(class_id) - if Object.const_defined?(:Controllers) && Object::Controllers.const_available?(class_id) - return Object::Controllers.const_get(class_id) - end - file_name = class_id.to_s.demodulize.underscore file_path = as_load_path.empty? ? file_name : "#{as_load_path}/#{file_name}" begin diff --git a/railties/builtin/controllers/rails_info_controller.rb b/railties/builtin/controllers/rails_info_controller.rb index ca2801e075..fe3c2d7c5d 100644 --- a/railties/builtin/controllers/rails_info_controller.rb +++ b/railties/builtin/controllers/rails_info_controller.rb @@ -1,11 +1,9 @@ -module Controllers #:nodoc: - class RailsInfoController < ApplicationController - def properties - if local_request? - render :inline => Rails::Info.to_html - else - render :text => '
For security purposes, this information is only available to local requests.
', :status => 500 - end +class RailsInfoController < ApplicationController + def properties + if local_request? + render :inline => Rails::Info.to_html + else + render :text => 'For security purposes, this information is only available to local requests.
', :status => 500 end end -end \ No newline at end of file +end diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb index 4c226c2700..2bd9a1de14 100644 --- a/railties/lib/commands/servers/lighttpd.rb +++ b/railties/lib/commands/servers/lighttpd.rb @@ -30,7 +30,9 @@ unless File.exist?(config_file) source = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "configs", "lighttpd.conf")) puts "=> #{config_file} not found, copying from #{source}" - FileUtils.cp source, config_file + config = File.read source + config = config.gsub "CWD", File.expand_path(RAILS_ROOT).inspect + File.open(config_file, 'w') { |f| f.write config } end config = IO.read(config_file) diff --git a/railties/test/dispatcher_test.rb b/railties/test/dispatcher_test.rb index bf5d235dfe..41d08e224e 100644 --- a/railties/test/dispatcher_test.rb +++ b/railties/test/dispatcher_test.rb @@ -24,12 +24,10 @@ class DispatcherTest < Test::Unit::TestCase def setup @output = StringIO.new ENV['REQUEST_METHOD'] = "GET" - setup_minimal_environment end def teardown ENV['REQUEST_METHOD'] = nil - teardown_minimal_environment end def test_ac_subclasses_cleared_on_reset @@ -91,13 +89,4 @@ class DispatcherTest < Test::Unit::TestCase def dispatch Dispatcher.dispatch(nil, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output) end - - def setup_minimal_environment - value = Dependencies::LoadingModule.root - Object.const_set("Controllers", value) - end - - def teardown_minimal_environment - Object.send(:remove_const, "Controllers") - end end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index 1488387f3c..6e539f8051 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -8,8 +8,6 @@ require 'action_controller' require 'action_controller/test_process' require 'rails_info' -module Controllers; def self.const_available?(constant); false end end - class ApplicationController < ActionController::Base @local_request = false class << self @@ -29,24 +27,24 @@ end require 'rails_info_controller' # Re-raise errors caught by the controller. -class Controllers::RailsInfoController; def rescue_action(e) raise e end; end +class RailsInfoController; def rescue_action(e) raise e end; end class RailsInfoControllerTest < Test::Unit::TestCase def setup - @controller = Controllers::RailsInfoController.new + @controller = RailsInfoController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_rails_info_properties_table_rendered_for_local_request - Controllers::RailsInfoController.local_request = true + RailsInfoController.local_request = true get :properties assert_tag :tag => 'table' assert_response :success end def test_rails_info_properties_error_rendered_for_non_local_request - Controllers::RailsInfoController.local_request = false + RailsInfoController.local_request = false get :properties assert_tag :tag => 'p' assert_response 500