aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-07-07 12:03:01 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-07-07 12:03:08 -0700
commit81f398b804a68c8090c0fbea20f50c0ae253b708 (patch)
treee7fee0d699f8065ed7f217c93c2e035af305ceca /actionpack
parent64c75d6618b6bc21576e95ceb31467d1984ecb33 (diff)
downloadrails-81f398b804a68c8090c0fbea20f50c0ae253b708.tar.gz
rails-81f398b804a68c8090c0fbea20f50c0ae253b708.tar.bz2
rails-81f398b804a68c8090c0fbea20f50c0ae253b708.zip
Fix setting helpers_path to a string or pathname
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb5
-rw-r--r--actionpack/test/abstract/helper_test.rb2
-rw-r--r--actionpack/test/controller/helper_test.rb6
3 files changed, 7 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index 89201fb5ee..e0bc47318a 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/class/attribute'
module ActionController
@@ -64,7 +65,7 @@ module ActionController
def helpers_dir=(value)
ActiveSupport::Deprecation.warn "helpers_dir= is deprecated, use helpers_path= instead", caller
- self.helpers_path = Array(value)
+ self.helpers_path = Array.wrap(value)
end
# Declares helper accessors for controller attributes. For example, the
@@ -103,7 +104,7 @@ module ActionController
# Extract helper names from files in app/helpers/**/*_helper.rb
def all_application_helpers
helpers = []
- helpers_path.each do |path|
+ Array.wrap(helpers_path).each do |path|
extract = /^#{Regexp.quote(path.to_s)}\/?(.*)_helper.rb$/
helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
end
diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index 0cdf5c2298..15c27501f2 100644
--- a/actionpack/test/abstract/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-ActionController::Base.helpers_path = [File.dirname(__FILE__) + '/../fixtures/helpers']
+ActionController::Base.helpers_path = File.expand_path('../../fixtures/helpers', __FILE__)
module AbstractController
module Testing
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index c9a6e5dd45..9b9657929f 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'active_support/core_ext/kernel/reporting'
-ActionController::Base.helpers_path = [File.dirname(__FILE__) + '/../fixtures/helpers']
+ActionController::Base.helpers_path = File.expand_path('../../fixtures/helpers', __FILE__)
module Fun
class GamesController < ActionController::Base
@@ -106,7 +106,7 @@ class HelperTest < ActiveSupport::TestCase
end
def test_all_helpers_with_alternate_helper_dir
- @controller_class.helpers_path = [File.dirname(__FILE__) + '/../fixtures/alternate_helpers']
+ @controller_class.helpers_path = File.expand_path('../../fixtures/alternate_helpers', __FILE__)
# Reload helpers
@controller_class._helpers = Module.new
@@ -143,7 +143,7 @@ class HelperTest < ActiveSupport::TestCase
assert_equal ["some/foo/bar"], ActionController::Base.helpers_dir
end
ensure
- ActionController::Base.helpers_path = [File.dirname(__FILE__) + '/../fixtures/helpers']
+ ActionController::Base.helpers_path = File.expand_path('../../fixtures/helpers', __FILE__)
end
private