mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Pull generated methods up in to the anonymous subclass
Then we don't need the extra module.
This commit is contained in:
parent
6dcd43b2a8
commit
517b96207d
3 changed files with 8 additions and 19 deletions
|
@ -9,11 +9,6 @@ module ActionDispatch
|
||||||
class DebugView < ActionView::Base # :nodoc:
|
class DebugView < ActionView::Base # :nodoc:
|
||||||
RESCUES_TEMPLATE_PATH = File.expand_path("templates", __dir__)
|
RESCUES_TEMPLATE_PATH = File.expand_path("templates", __dir__)
|
||||||
|
|
||||||
module CompiledTemplates
|
|
||||||
end
|
|
||||||
|
|
||||||
include CompiledTemplates
|
|
||||||
|
|
||||||
def initialize(assigns)
|
def initialize(assigns)
|
||||||
paths = [RESCUES_TEMPLATE_PATH]
|
paths = [RESCUES_TEMPLATE_PATH]
|
||||||
renderer = ActionView::Renderer.new ActionView::LookupContext.new(paths)
|
renderer = ActionView::Renderer.new ActionView::LookupContext.new(paths)
|
||||||
|
@ -21,7 +16,7 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def compiled_method_container
|
def compiled_method_container
|
||||||
CompiledTemplates
|
self.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def debug_params(params)
|
def debug_params(params)
|
||||||
|
|
|
@ -182,11 +182,12 @@ module ActionView #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_empty_template_cache # :nodoc:
|
def with_empty_template_cache # :nodoc:
|
||||||
template_container = Module.new
|
subclass = Class.new(self) {
|
||||||
Class.new(self) {
|
# We can't implement these as self.class because subclasses will
|
||||||
include template_container
|
# share the same template cache as superclasses, so "changed?" won't work
|
||||||
define_method(:compiled_method_container) { template_container }
|
# correctly.
|
||||||
define_singleton_method(:compiled_method_container) { template_container }
|
define_method(:compiled_method_container) { subclass }
|
||||||
|
define_singleton_method(:compiled_method_container) { subclass }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,8 @@ module RenderTestCases
|
||||||
end.with_view_paths(paths, @assigns)
|
end.with_view_paths(paths, @assigns)
|
||||||
|
|
||||||
controller = TestController.new
|
controller = TestController.new
|
||||||
view = @view
|
|
||||||
|
|
||||||
@controller_view = Class.new(controller.view_context_class) do
|
@controller_view = controller.view_context_class.with_empty_template_cache.new(controller.view_renderer, controller.view_assigns, controller)
|
||||||
include view.compiled_method_container
|
|
||||||
|
|
||||||
define_method(:compiled_method_container) do
|
|
||||||
view.compiled_method_container
|
|
||||||
end
|
|
||||||
end.new(controller.view_renderer, controller.view_assigns, controller)
|
|
||||||
|
|
||||||
# Reload and register danish language for testing
|
# Reload and register danish language for testing
|
||||||
I18n.backend.store_translations "da", {}
|
I18n.backend.store_translations "da", {}
|
||||||
|
|
Loading…
Reference in a new issue