diff options
author | David Chelimsky <dchelimsky@gmail.com> | 2010-06-22 01:40:22 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-22 14:51:22 +0200 |
commit | 0576ec4ddd5f806c6ae98184d28391fc239db1ef (patch) | |
tree | a0563ebe3f34e2f99c25554c2e57d38d8b37067c /actionpack/lib/action_view/test_case.rb | |
parent | 02399a1184d0f87b14af461fab731120d92c5ad8 (diff) | |
download | rails-0576ec4ddd5f806c6ae98184d28391fc239db1ef.tar.gz rails-0576ec4ddd5f806c6ae98184d28391fc239db1ef.tar.bz2 rails-0576ec4ddd5f806c6ae98184d28391fc239db1ef.zip |
Add support for specifying locals in view tests with assert template [#4927 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_view/test_case.rb')
-rw-r--r-- | actionpack/lib/action_view/test_case.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index b698b4cfec..fcfbb92157 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -103,6 +103,10 @@ module ActionView output end + def locals + @locals ||= {} + end + included do setup :setup_with_controller end @@ -132,12 +136,23 @@ module ActionView end end + module Locals + attr_accessor :locals + + def _render_partial(options) + locals[options[:partial]] = options[:locals] + super(options) + end + end + def _view @_view ||= begin view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) view.singleton_class.send :include, _helpers view.singleton_class.send :include, @controller._router.url_helpers view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash" + view.extend(Locals) + view.locals = self.locals view.output_buffer = self.output_buffer view end |