2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:50:17 -04:00
|
|
|
require "abstract_unit"
|
2015-04-06 22:20:57 -04:00
|
|
|
|
|
|
|
class ControllerHelperTest < ActionView::TestCase
|
|
|
|
tests ActionView::Helpers::ControllerHelper
|
|
|
|
|
|
|
|
class SpecializedFormBuilder < ActionView::Helpers::FormBuilder ; end
|
|
|
|
|
|
|
|
def test_assign_controller_sets_default_form_builder
|
|
|
|
@controller = OpenStruct.new(default_form_builder: SpecializedFormBuilder)
|
|
|
|
assign_controller(@controller)
|
|
|
|
|
2016-08-07 19:05:28 -04:00
|
|
|
assert_equal SpecializedFormBuilder, default_form_builder
|
2015-04-06 22:20:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_assign_controller_skips_default_form_builder
|
|
|
|
@controller = OpenStruct.new
|
|
|
|
assign_controller(@controller)
|
|
|
|
|
2016-08-07 19:05:28 -04:00
|
|
|
assert_nil default_form_builder
|
2015-04-06 22:20:57 -04:00
|
|
|
end
|
2017-07-14 13:37:31 -04:00
|
|
|
|
|
|
|
def test_respond_to
|
|
|
|
@controller = OpenStruct.new
|
|
|
|
assign_controller(@controller)
|
|
|
|
assert_not respond_to?(:params)
|
|
|
|
assert respond_to?(:assign_controller)
|
|
|
|
|
|
|
|
@controller.params = {}
|
|
|
|
assert respond_to?(:params)
|
|
|
|
assert respond_to?(:assign_controller)
|
|
|
|
end
|
2015-04-06 22:20:57 -04:00
|
|
|
end
|