1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Allow view in AV::TestCase to access it's controller helpers methods

This commit is contained in:
Santiago Pastorino 2011-01-12 12:14:00 -02:00
parent f8700038af
commit 6062d434f1
2 changed files with 22 additions and 0 deletions

View file

@ -157,6 +157,7 @@ module ActionView
def view
@view ||= begin
view = ActionView::Base.new(ActionController::Base.view_paths, {}, @controller)
view.singleton_class.send :include, @controller._helpers
view.singleton_class.send :include, _helpers
view.singleton_class.send :include, @controller._routes.url_helpers
view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"

View file

@ -116,6 +116,27 @@ module ActionView
end
end
class ControllerHelperMethod < ActionView::TestCase
module SomeHelper
def some_method
render :partial => 'test/from_helper'
end
end
helper SomeHelper
test "can call a helper method defined on the current controller from a helper" do
@controller.singleton_class.class_eval <<-EOF, __FILE__, __LINE__ + 1
def render_from_helper
'controller_helper_method'
end
EOF
@controller.class.helper_method :render_from_helper
assert_equal 'controller_helper_method', some_method
end
end
class AssignsTest < ActionView::TestCase
setup do
ActiveSupport::Deprecation.stubs(:warn)