mirror of https://github.com/rails/rails
Move prefixes to view paths as they are now a lookup context dependency.
This commit is contained in:
parent
d9c39c3ae9
commit
6afc900191
|
@ -4,8 +4,6 @@ module AbstractController
|
|||
module Helpers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include Rendering
|
||||
|
||||
included do
|
||||
class_attribute :_helpers
|
||||
self._helpers = Module.new
|
||||
|
|
|
@ -62,20 +62,6 @@ module AbstractController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parent_prefixes
|
||||
@parent_prefixes ||= begin
|
||||
parent_controller = superclass
|
||||
prefixes = []
|
||||
|
||||
until parent_controller.abstract?
|
||||
prefixes << parent_controller.controller_path
|
||||
parent_controller = parent_controller.superclass
|
||||
end
|
||||
|
||||
prefixes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attr_writer :view_context_class
|
||||
|
@ -135,13 +121,6 @@ module AbstractController
|
|||
view_renderer.render(view_context, options)
|
||||
end
|
||||
|
||||
# The prefixes used in render "foo" shortcuts.
|
||||
def _prefixes
|
||||
@_prefixes ||= begin
|
||||
parent_prefixes = self.class.parent_prefixes
|
||||
parent_prefixes.dup.unshift(controller_path)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -11,6 +11,30 @@ module AbstractController
|
|||
delegate :find_template, :template_exists?, :view_paths, :formats, :formats=,
|
||||
:locale, :locale=, :to => :lookup_context
|
||||
|
||||
module ClassMethods
|
||||
def parent_prefixes
|
||||
@parent_prefixes ||= begin
|
||||
parent_controller = superclass
|
||||
prefixes = []
|
||||
|
||||
until parent_controller.abstract?
|
||||
prefixes << parent_controller.controller_path
|
||||
parent_controller = parent_controller.superclass
|
||||
end
|
||||
|
||||
prefixes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The prefixes used in render "foo" shortcuts.
|
||||
def _prefixes
|
||||
@_prefixes ||= begin
|
||||
parent_prefixes = self.class.parent_prefixes
|
||||
parent_prefixes.dup.unshift(controller_path)
|
||||
end
|
||||
end
|
||||
|
||||
# LookupContext is the object responsible to hold all information required to lookup
|
||||
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
|
||||
# information.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/module/delegation'
|
||||
require 'action_controller'
|
||||
require 'action_controller/test_case'
|
||||
require 'action_view'
|
||||
|
@ -43,6 +44,7 @@ module ActionView
|
|||
include AbstractController::Helpers
|
||||
include ActionView::Helpers
|
||||
|
||||
delegate :lookup_context, :to => :controller
|
||||
attr_accessor :controller, :output_buffer, :rendered
|
||||
|
||||
module ClassMethods
|
||||
|
|
|
@ -73,6 +73,10 @@ module ActionView
|
|||
view.request.flash.expects(:alert).with("this message")
|
||||
view.alert("this message")
|
||||
end
|
||||
|
||||
test "uses controller lookup context" do
|
||||
assert_equal self.lookup_context, @controller.lookup_context
|
||||
end
|
||||
end
|
||||
|
||||
class ClassMethodsTest < ActionView::TestCase
|
||||
|
|
Loading…
Reference in New Issue