From 7ee5843c3cedfe36a680d5b28aa31eef45296c50 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 16 Dec 2009 11:56:51 -0600 Subject: Fully expand relative rails framework paths and make sure we aren't adding any to the load path more than once. --- actionpack/lib/abstract_controller.rb | 8 ++++++-- actionpack/lib/action_controller.rb | 4 +++- actionpack/lib/action_dispatch.rb | 8 ++++---- actionpack/lib/action_view.rb | 13 ++++++------- actionpack/test/abstract_unit.rb | 15 +++++++-------- 5 files changed, 26 insertions(+), 22 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/abstract_controller.rb b/actionpack/lib/abstract_controller.rb index 92d2971ec3..109a3a3385 100644 --- a/actionpack/lib/abstract_controller.rb +++ b/actionpack/lib/abstract_controller.rb @@ -1,5 +1,9 @@ -require "active_support/core_ext/module/attr_internal" -require "active_support/core_ext/module/delegation" +activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) +$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) + +require 'active_support' +require 'active_support/core_ext/module/attr_internal' +require 'active_support/core_ext/module/delegation' module AbstractController extend ActiveSupport::Autoload diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 2113d791f5..37ff10e852 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -1,4 +1,6 @@ -require "active_support" +activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) +$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) +require 'active_support' module ActionController extend ActiveSupport::Autoload diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index d1c191d652..feed6a8e25 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -21,6 +21,10 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ +activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) +$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) +require 'active_support' + require 'rack' module Rack @@ -74,7 +78,3 @@ module ActionDispatch end autoload :Mime, 'action_dispatch/http/mime_type' - -activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" -$:.unshift activesupport_path if File.directory?(activesupport_path) -require 'active_support' diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb index 06238ca747..c3e42ac0d5 100644 --- a/actionpack/lib/action_view.rb +++ b/actionpack/lib/action_view.rb @@ -21,7 +21,12 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -require File.join(File.dirname(__FILE__), "action_pack") +activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__) +$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path) +require 'active_support' +require 'active_support/core_ext/class/attribute_accessors' + +require 'action_pack' module ActionView extend ActiveSupport::Autoload @@ -51,10 +56,4 @@ end require 'action_view/erb/util' - I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml" - -activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" -$:.unshift activesupport_path if File.directory?(activesupport_path) -require 'active_support' -require 'active_support/core_ext/class/attribute_accessors' diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 4dae1ab873..a9341b60df 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -1,12 +1,9 @@ -root = File.expand_path('../../..', __FILE__) begin - require "#{root}/vendor/gems/environment" + require File.expand_path('../../../vendor/gems/environment', __FILE__) rescue LoadError - $:.unshift "#{root}/activesupport/lib" - $:.unshift "#{root}/activemodel/lib" end -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +lib = File.expand_path('../../lib', __FILE__) $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) $:.unshift(File.dirname(__FILE__) + '/lib') @@ -16,18 +13,20 @@ $:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers') ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp') require 'test/unit' -require 'active_support' -require 'active_support/test_case' require 'abstract_controller' require 'action_controller' require 'action_view' require 'action_view/base' require 'action_dispatch' -require 'active_model' require 'fixture_template' +require 'active_support/test_case' require 'action_view/test_case' require 'active_support/dependencies' +activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__) +$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path) +require 'active_model' + begin require 'ruby-debug' Debugger.settings[:autoeval] = true -- cgit v1.2.3