aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/controller_helper_test.rb
blob: 46d20c188c2b88f6288f74eb056ce07d17314699 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

require "abstract_unit"

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)

    assert_equal SpecializedFormBuilder, default_form_builder
  end

  def test_assign_controller_skips_default_form_builder
    @controller = OpenStruct.new
    assign_controller(@controller)

    assert_nil default_form_builder
  end

  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
end