提交 bd36418c 编写于 作者: J José Valim

Fix controller_path returnsing an empty string in Ruby 1.8.7 [#4036 status:resolved]

上级 4db72b70
......@@ -3,8 +3,10 @@
require 'active_support/ruby/shim'
require 'active_support/dependencies/autoload'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/anonymous'
module AbstractController
extend ActiveSupport::Autoload
......
......@@ -84,7 +84,7 @@ def action_methods
# ==== Returns
# String
def controller_path
@controller_path ||= name && name.sub(/Controller$/, '').underscore
@controller_path ||= name.sub(/Controller$/, '').underscore unless anonymous?
end
end
......
require 'active_support/dependencies'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/anonymous'
module AbstractController
module Helpers
......
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
module AbstractController
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
# repeated setups. The inclusion pattern has pages that look like this:
......
require 'active_support/core_ext/logger'
require 'active_support/benchmarkable'
require "active_support/core_ext/logger"
require "active_support/benchmarkable"
module AbstractController
module Logger
......
require "abstract_controller/base"
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/array/wrap'
require "active_support/core_ext/array/wrap"
module AbstractController
class DoubleRenderError < Error
......
......@@ -113,6 +113,15 @@ def test_action_methods
assert_equal Set.new(%w(public_action)), c.class.__send__(:action_methods), "#{c.controller_path} should not be empty!"
end
end
def test_temporary_anonymous_controllers
name = 'ExamplesController'
klass = Class.new(ActionController::Base)
Object.const_set(name, klass)
controller = klass.new
assert_equal "examples", controller.controller_path
end
end
class PerformActionTest < ActionController::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册