simple_form 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +3 -4
  5. data/lib/simple_form/components/label_input.rb +1 -1
  6. data/lib/simple_form/form_builder.rb +1 -5
  7. data/lib/simple_form/railtie.rb +4 -0
  8. data/lib/simple_form/version.rb +1 -1
  9. data/lib/simple_form/wrappers/leaf.rb +1 -1
  10. data/lib/simple_form.rb +8 -4
  11. metadata +5 -85
  12. data/test/action_view_extensions/builder_test.rb +0 -634
  13. data/test/action_view_extensions/form_helper_test.rb +0 -172
  14. data/test/components/custom_components_test.rb +0 -62
  15. data/test/components/label_test.rb +0 -352
  16. data/test/form_builder/association_test.rb +0 -252
  17. data/test/form_builder/button_test.rb +0 -48
  18. data/test/form_builder/error_notification_test.rb +0 -80
  19. data/test/form_builder/error_test.rb +0 -281
  20. data/test/form_builder/general_test.rb +0 -539
  21. data/test/form_builder/hint_test.rb +0 -150
  22. data/test/form_builder/input_field_test.rb +0 -195
  23. data/test/form_builder/label_test.rb +0 -136
  24. data/test/form_builder/wrapper_test.rb +0 -378
  25. data/test/generators/simple_form_generator_test.rb +0 -43
  26. data/test/inputs/boolean_input_test.rb +0 -256
  27. data/test/inputs/collection_check_boxes_input_test.rb +0 -323
  28. data/test/inputs/collection_radio_buttons_input_test.rb +0 -446
  29. data/test/inputs/collection_select_input_test.rb +0 -380
  30. data/test/inputs/color_input_test.rb +0 -10
  31. data/test/inputs/country_input_test.rb +0 -36
  32. data/test/inputs/datetime_input_test.rb +0 -176
  33. data/test/inputs/disabled_test.rb +0 -92
  34. data/test/inputs/discovery_test.rb +0 -142
  35. data/test/inputs/file_input_test.rb +0 -17
  36. data/test/inputs/general_test.rb +0 -133
  37. data/test/inputs/grouped_collection_select_input_test.rb +0 -196
  38. data/test/inputs/hidden_input_test.rb +0 -32
  39. data/test/inputs/numeric_input_test.rb +0 -177
  40. data/test/inputs/readonly_test.rb +0 -102
  41. data/test/inputs/required_test.rb +0 -158
  42. data/test/inputs/rich_text_area_input_test.rb +0 -15
  43. data/test/inputs/string_input_test.rb +0 -158
  44. data/test/inputs/text_input_test.rb +0 -37
  45. data/test/inputs/time_zone_input_test.rb +0 -36
  46. data/test/simple_form_test.rb +0 -18
  47. data/test/support/discovery_inputs.rb +0 -65
  48. data/test/support/misc_helpers.rb +0 -274
  49. data/test/support/mock_controller.rb +0 -30
  50. data/test/support/models.rb +0 -357
  51. data/test/test_helper.rb +0 -95
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'test_helper'
3
-
4
- class DisabledTest < ActionView::TestCase
5
- test 'string input is disabled when disabled option is true' do
6
- with_input_for @user, :name, :string, disabled: true
7
- assert_select 'input.string.disabled[disabled]'
8
- end
9
-
10
- test 'text input is disabled when disabled option is true' do
11
- with_input_for @user, :description, :text, disabled: true
12
- assert_select 'textarea.text.disabled[disabled]'
13
- end
14
-
15
- test 'numeric input is disabled when disabled option is true' do
16
- with_input_for @user, :age, :integer, disabled: true
17
- assert_select 'input.integer.disabled[disabled]'
18
- end
19
-
20
- test 'date input is disabled when disabled option is true' do
21
- with_input_for @user, :born_at, :date, disabled: true
22
- assert_select 'select.date.disabled[disabled]'
23
- end
24
-
25
- test 'datetime input is disabled when disabled option is true' do
26
- with_input_for @user, :created_at, :datetime, disabled: true
27
- assert_select 'select.datetime.disabled[disabled]'
28
- end
29
-
30
- test 'string input does not be disabled when disabled option is false' do
31
- with_input_for @user, :name, :string, disabled: false
32
- assert_no_select 'input.string.disabled[disabled]'
33
- end
34
-
35
- test 'text input does not be disabled when disabled option is false' do
36
- with_input_for @user, :description, :text, disabled: false
37
- assert_no_select 'textarea.text.disabled[disabled]'
38
- end
39
-
40
- test 'numeric input does not be disabled when disabled option is false' do
41
- with_input_for @user, :age, :integer, disabled: false
42
- assert_no_select 'input.integer.disabled[disabled]'
43
- end
44
-
45
- test 'date input does not be disabled when disabled option is false' do
46
- with_input_for @user, :born_at, :date, disabled: false
47
- assert_no_select 'select.date.disabled[disabled]'
48
- end
49
-
50
- test 'datetime input does not be disabled when disabled option is false' do
51
- with_input_for @user, :created_at, :datetime, disabled: false
52
- assert_no_select 'select.datetime.disabled[disabled]'
53
- end
54
-
55
- test 'string input does not be disabled when disabled option is not present' do
56
- with_input_for @user, :name, :string
57
- assert_no_select 'input.string.disabled[disabled]'
58
- end
59
-
60
- test 'text input does not be disabled when disabled option is not present' do
61
- with_input_for @user, :description, :text
62
- assert_no_select 'textarea.text.disabled[disabled]'
63
- end
64
-
65
- test 'numeric input does not be disabled when disabled option is not present' do
66
- with_input_for @user, :age, :integer
67
- assert_no_select 'input.integer.disabled[disabled]'
68
- end
69
-
70
- test 'date input does not be disabled when disabled option is not present' do
71
- with_input_for @user, :born_at, :date
72
- assert_no_select 'select.date.disabled[disabled]'
73
- end
74
-
75
- test 'datetime input does not be disabled when disabled option is not present' do
76
- with_input_for @user, :created_at, :datetime
77
- assert_no_select 'select.datetime.disabled[disabled]'
78
- end
79
-
80
- test 'input_field collection allows disabled select' do
81
- with_input_field_for @user, :description, collection: ['foo', 'bar'], disabled: true
82
- assert_select 'select[disabled]'
83
- assert_no_select 'option[disabled]'
84
- end
85
-
86
- test 'input_field collection allows individual disabled options' do
87
- with_input_field_for @user, :description, collection: ['foo', 'bar'], disabled: 'bar'
88
- assert_no_select 'select[disabled]'
89
- assert_no_select 'option[disabled][value=foo]'
90
- assert_select 'option[disabled][value=bar]'
91
- end
92
- end
@@ -1,142 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'test_helper'
3
-
4
- class DiscoveryTest < ActionView::TestCase
5
- # Setup new inputs and remove them after the test.
6
- def discovery(value = false)
7
- swap SimpleForm, cache_discovery: value do
8
- begin
9
- load "support/discovery_inputs.rb"
10
- yield
11
- ensure
12
- SimpleForm::FormBuilder.discovery_cache.clear
13
- Object.send :remove_const, :StringInput
14
- Object.send :remove_const, :NumericInput
15
- Object.send :remove_const, :CustomizedInput
16
- Object.send :remove_const, :DeprecatedInput
17
- Object.send :remove_const, :CollectionSelectInput
18
- Object.send :remove_const, :FileInput
19
- CustomInputs.send :remove_const, :CustomizedInput
20
- CustomInputs.send :remove_const, :PasswordInput
21
- CustomInputs.send :remove_const, :NumericInput
22
- end
23
- end
24
- end
25
-
26
- test 'builder does not discover new inputs if cached' do
27
- with_form_for @user, :name
28
- assert_select 'form input#user_name.string'
29
-
30
- discovery(true) do
31
- with_form_for @user, :name
32
- assert_no_select 'form section input#user_name.string'
33
- end
34
- end
35
-
36
- test 'builder discovers new inputs' do
37
- discovery do
38
- with_form_for @user, :name, as: :customized
39
- assert_select 'form section input#user_name.string'
40
- end
41
- end
42
-
43
- test 'builder does not discover new inputs if discovery is off' do
44
- with_form_for @user, :name
45
- assert_select 'form input#user_name.string'
46
-
47
- swap SimpleForm, inputs_discovery: false do
48
- discovery do
49
- with_form_for @user, :name
50
- assert_no_select 'form section input#user_name.string'
51
- end
52
- end
53
- end
54
-
55
- test 'builder discovers new inputs from mappings if not cached' do
56
- discovery do
57
- with_form_for @user, :name
58
- assert_select 'form section input#user_name.string'
59
- end
60
- end
61
-
62
- test 'builder discovers new inputs from internal fallbacks if not cached' do
63
- discovery do
64
- with_form_for @user, :age
65
- assert_select 'form section input#user_age.numeric.integer'
66
- end
67
- end
68
-
69
- test 'builder discovers new maped inputs from configured namespaces if not cached' do
70
- discovery do
71
- swap SimpleForm, custom_inputs_namespaces: ['CustomInputs'] do
72
- with_form_for @user, :password
73
- assert_select 'form input#user_password.password-custom-input'
74
- end
75
- end
76
- end
77
-
78
- test 'builder discovers new maped inputs from configured namespaces before the ones from top level namespace' do
79
- discovery do
80
- swap SimpleForm, custom_inputs_namespaces: ['CustomInputs'] do
81
- with_form_for @user, :age
82
- assert_select 'form input#user_age.numeric-custom-input'
83
- end
84
- end
85
- end
86
-
87
- test 'builder discovers new custom inputs from configured namespace before the ones from top level namespace' do
88
- discovery do
89
- swap SimpleForm, custom_inputs_namespaces: ['CustomInputs'] do
90
- with_form_for @user, :name, as: 'customized'
91
- assert_select 'form input#user_name.customized-namespace-custom-input'
92
- end
93
- end
94
- end
95
-
96
- test 'raises error when configured namespace does not exists' do
97
- discovery do
98
- swap SimpleForm, custom_inputs_namespaces: ['InvalidNamespace'] do
99
- assert_raise NameError do
100
- with_form_for @user, :age
101
- end
102
- end
103
- end
104
- end
105
-
106
- test 'new inputs can override the input_html_options' do
107
- discovery do
108
- with_form_for @user, :active, as: :select
109
- assert_select 'form select#user_active.select.chosen'
110
- end
111
- end
112
-
113
- test 'does not duplicate the html classes giving a extra class' do
114
- discovery do
115
- swap SimpleForm, input_class: 'custom-default-input-class' do
116
- with_form_for @user, :active, as: :select
117
- assert_select 'form select#user_active.select' do
118
- # Make sure class list contains 'chosen' only once.
119
- assert_select ":match('class', ?)", /^(?!.*\bchosen\b.*\bchosen\b).*\bchosen\b.*$/
120
- end
121
- end
122
- end
123
- end
124
-
125
- test 'new inputs can override the default input_html_classes' do
126
- discovery do
127
- with_form_for @user, :avatar, as: :file
128
- assert_no_select 'form input[type=file]#user_avatar.file.file-upload'
129
- assert_select 'form input[type=file]#user_avatar.file-upload'
130
- end
131
- end
132
-
133
- test 'inputs method without wrapper_options are deprecated' do
134
- discovery do
135
- assert_deprecated do
136
- with_form_for @user, :name, as: :deprecated
137
- end
138
-
139
- assert_select 'form section input#user_name.string'
140
- end
141
- end
142
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: UTF-8
3
- require 'test_helper'
4
-
5
- class FileInputTest < ActionView::TestCase
6
- test 'input generates a file field' do
7
- with_input_for @user, :name, :file
8
- assert_select 'input#user_name[type=file]'
9
- end
10
-
11
- test "input generates a file field that doesn't accept placeholder" do
12
- store_translations(:en, simple_form: { placeholders: { user: { name: "text" } } }) do
13
- with_input_for @user, :name, :file
14
- assert_no_select 'input[placeholder]'
15
- end
16
- end
17
- end
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: UTF-8
3
- require 'test_helper'
4
-
5
- class InputTest < ActionView::TestCase
6
- test 'input generates css class based on default input type' do
7
- with_input_for @user, :name, :string
8
- assert_select 'input.string'
9
- with_input_for @user, :description, :text
10
- assert_select 'textarea.text'
11
- with_input_for @user, :age, :integer
12
- assert_select 'input.integer'
13
- with_input_for @user, :born_at, :date
14
- assert_select 'select.date'
15
- with_input_for @user, :created_at, :datetime
16
- assert_select 'select.datetime'
17
- end
18
-
19
- test 'string input generates autofocus attribute when autofocus option is true' do
20
- with_input_for @user, :name, :string, autofocus: true
21
- assert_select 'input.string[autofocus]'
22
- end
23
-
24
- test 'input accepts input_class configuration' do
25
- swap SimpleForm, input_class: :xlarge do
26
- with_input_for @user, :name, :string
27
- assert_select 'input.xlarge'
28
- assert_no_select 'div.xlarge'
29
- end
30
- end
31
-
32
- test 'input does not add input_class when configured to not generate additional classes for input' do
33
- swap SimpleForm, input_class: 'xlarge', generate_additional_classes_for: [:wrapper] do
34
- with_input_for @user, :name, :string
35
- assert_select 'input'
36
- assert_no_select '.xlarge'
37
- end
38
- end
39
-
40
- test 'text input generates autofocus attribute when autofocus option is true' do
41
- with_input_for @user, :description, :text, autofocus: true
42
- assert_select 'textarea.text[autofocus]'
43
- end
44
-
45
- test 'numeric input generates autofocus attribute when autofocus option is true' do
46
- with_input_for @user, :age, :integer, autofocus: true
47
- assert_select 'input.integer[autofocus]'
48
- end
49
-
50
- test 'date input generates autofocus attribute when autofocus option is true' do
51
- with_input_for @user, :born_at, :date, autofocus: true
52
- assert_select 'select.date[autofocus]'
53
- end
54
-
55
- test 'datetime input generates autofocus attribute when autofocus option is true' do
56
- with_input_for @user, :created_at, :datetime, autofocus: true
57
- assert_select 'select.datetime[autofocus]'
58
- end
59
-
60
- test 'string input generates autofocus attribute when autofocus option is false' do
61
- with_input_for @user, :name, :string, autofocus: false
62
- assert_no_select 'input.string[autofocus]'
63
- end
64
-
65
- test 'text input generates autofocus attribute when autofocus option is false' do
66
- with_input_for @user, :description, :text, autofocus: false
67
- assert_no_select 'textarea.text[autofocus]'
68
- end
69
-
70
- test 'numeric input generates autofocus attribute when autofocus option is false' do
71
- with_input_for @user, :age, :integer, autofocus: false
72
- assert_no_select 'input.integer[autofocus]'
73
- end
74
-
75
- test 'date input generates autofocus attribute when autofocus option is false' do
76
- with_input_for @user, :born_at, :date, autofocus: false
77
- assert_no_select 'select.date[autofocus]'
78
- end
79
-
80
- test 'datetime input generates autofocus attribute when autofocus option is false' do
81
- with_input_for @user, :created_at, :datetime, autofocus: false
82
- assert_no_select 'select.datetime[autofocus]'
83
- end
84
-
85
- test 'string input generates autofocus attribute when autofocus option is not present' do
86
- with_input_for @user, :name, :string
87
- assert_no_select 'input.string[autofocus]'
88
- end
89
-
90
- test 'text input generates autofocus attribute when autofocus option is not present' do
91
- with_input_for @user, :description, :text
92
- assert_no_select 'textarea.text[autofocus]'
93
- end
94
-
95
- test 'numeric input generates autofocus attribute when autofocus option is not present' do
96
- with_input_for @user, :age, :integer
97
- assert_no_select 'input.integer[autofocus]'
98
- end
99
-
100
- test 'date input generates autofocus attribute when autofocus option is not present' do
101
- with_input_for @user, :born_at, :date
102
- assert_no_select 'select.date[autofocus]'
103
- end
104
-
105
- test 'datetime input generates autofocus attribute when autofocus option is not present' do
106
- with_input_for @user, :created_at, :datetime
107
- assert_no_select 'select.datetime[autofocus]'
108
- end
109
-
110
- # With no object
111
- test 'input is generated properly when object is not present' do
112
- with_input_for :project, :name, :string
113
- assert_select 'input.string.required#project_name'
114
- end
115
-
116
- test 'input as radio is generated properly when object is not present ' do
117
- with_input_for :project, :name, :radio_buttons
118
- assert_select 'input.radio_buttons#project_name_true'
119
- assert_select 'input.radio_buttons#project_name_false'
120
- end
121
-
122
- test 'input as select with collection is generated properly when object is not present' do
123
- with_input_for :project, :name, :select, collection: %w[Jose Carlos]
124
- assert_select 'select.select#project_name'
125
- end
126
-
127
- test 'input does not generate empty css class' do
128
- swap SimpleForm, generate_additional_classes_for: %i[wrapper label] do
129
- with_input_for :project, :name, :string
130
- assert_no_select 'input#project_name[class]'
131
- end
132
- end
133
- end
@@ -1,196 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: UTF-8
3
- require 'test_helper'
4
-
5
- class GroupedCollectionSelectInputTest < ActionView::TestCase
6
- test 'grouped collection accepts array collection form' do
7
- with_input_for @user, :tag_ids, :grouped_select,
8
- collection: [['Authors', %w[Jose Carlos]], ['General', %w[Bob John]]],
9
- group_method: :last
10
-
11
- assert_select 'select.grouped_select#user_tag_ids' do
12
- assert_select 'optgroup[label=Authors]' do
13
- assert_select 'option', 'Jose'
14
- assert_select 'option', 'Carlos'
15
- end
16
-
17
- assert_select 'optgroup[label=General]' do
18
- assert_select 'option', 'Bob'
19
- assert_select 'option', 'John'
20
- end
21
- end
22
- end
23
-
24
- test 'grouped collection accepts empty array collection form' do
25
- with_input_for @user, :tag_ids, :grouped_select,
26
- collection: [],
27
- group_method: :last
28
-
29
- assert_select 'select.grouped_select#user_tag_ids'
30
- end
31
-
32
-
33
- test 'grouped collection accepts proc as collection' do
34
- with_input_for @user, :tag_ids, :grouped_select,
35
- collection: proc { [['Authors', %w[Jose Carlos]], ['General', %w[Bob John]]] },
36
- group_method: :last
37
-
38
- assert_select 'select.grouped_select#user_tag_ids' do
39
- assert_select 'optgroup[label=Authors]' do
40
- assert_select 'option', 'Jose'
41
- assert_select 'option', 'Carlos'
42
- end
43
-
44
- assert_select 'optgroup[label=General]' do
45
- assert_select 'option', 'Bob'
46
- assert_select 'option', 'John'
47
- end
48
- end
49
- end
50
-
51
- test 'grouped collection accepts hash collection form' do
52
- with_input_for @user, :tag_ids, :grouped_select,
53
- collection: { Authors: %w[Jose Carlos], General: %w[Bob John] },
54
- group_method: :last
55
-
56
- assert_select 'select.grouped_select#user_tag_ids' do
57
- assert_select 'optgroup[label=Authors]' do
58
- assert_select 'option', 'Jose'
59
- assert_select 'option', 'Carlos'
60
- end
61
-
62
- assert_select 'optgroup[label=General]' do
63
- assert_select 'option', 'Bob'
64
- assert_select 'option', 'John'
65
- end
66
- end
67
- end
68
-
69
- test 'grouped collection allows overriding group_method using a lambda' do
70
- with_input_for @user, :tag_ids, :grouped_select,
71
- collection: { Authors: %w[Jose Carlos] },
72
- group_method: ->(i) { i.last }
73
-
74
- assert_select 'select.grouped_select#user_tag_ids' do
75
- assert_select 'optgroup[label=Authors]' do
76
- assert_select 'option[value=Jose]', 'Jose'
77
- assert_select 'option[value=Carlos]', 'Carlos'
78
- end
79
- end
80
- end
81
-
82
- test 'grouped collection accepts group_label_method option' do
83
- with_input_for @user, :tag_ids, :grouped_select,
84
- collection: { %w[Jose Carlos] => 'Authors' },
85
- group_method: :first,
86
- group_label_method: :last
87
-
88
- assert_select 'select.grouped_select#user_tag_ids' do
89
- assert_select 'optgroup[label=Authors]' do
90
- assert_select 'option', 'Jose'
91
- assert_select 'option', 'Carlos'
92
- end
93
- end
94
- end
95
-
96
- test 'grouped collection finds default label methods on the group objects' do
97
- option_list = %w[Jose Carlos]
98
-
99
- GroupedClass = Struct.new(:to_label, :options)
100
- group = GroupedClass.new("Authors", option_list)
101
-
102
- with_input_for @user, :tag_ids, :grouped_select,
103
- collection: [group],
104
- group_method: :options
105
-
106
- assert_select 'select.grouped_select#user_tag_ids' do
107
- assert_select 'optgroup[label=Authors]' do
108
- assert_select 'option', 'Jose'
109
- assert_select 'option', 'Carlos'
110
- end
111
- end
112
- end
113
-
114
- test 'grouped collections finds the default label method from the first non-empty object' do
115
- Agent = Struct.new(:id, :name)
116
- agents = [["First", []], ["Second", [Agent.new(7, 'Bond'), Agent.new(47, 'Hitman')]]]
117
-
118
- with_input_for @user, :tag_ids, :grouped_select,
119
- collection: agents,
120
- group_label_method: :first,
121
- group_method: :last,
122
- include_blank: false
123
-
124
- assert_select 'select.grouped_select#user_tag_ids' do
125
- assert_select 'optgroup[label=Second]' do
126
- assert_select 'option[value="7"]', 'Bond'
127
- assert_select 'option[value="47"]', 'Hitman'
128
- end
129
- end
130
- end
131
-
132
- test 'grouped collection accepts label and value methods options' do
133
- with_input_for @user, :tag_ids, :grouped_select,
134
- collection: { Authors: %w[Jose Carlos] },
135
- group_method: :last,
136
- label_method: :upcase,
137
- value_method: :downcase
138
-
139
- assert_select 'select.grouped_select#user_tag_ids' do
140
- assert_select 'optgroup[label=Authors]' do
141
- assert_select 'option[value=jose]', 'JOSE'
142
- assert_select 'option[value=carlos]', 'CARLOS'
143
- end
144
- end
145
- end
146
-
147
- test 'grouped collection allows overriding label and value methods using a lambda' do
148
- with_input_for @user, :tag_ids, :grouped_select,
149
- collection: { Authors: %w[Jose Carlos] },
150
- group_method: :last,
151
- label_method: ->(i) { i.upcase },
152
- value_method: ->(i) { i.downcase }
153
-
154
- assert_select 'select.grouped_select#user_tag_ids' do
155
- assert_select 'optgroup[label=Authors]' do
156
- assert_select 'option[value=jose]', 'JOSE'
157
- assert_select 'option[value=carlos]', 'CARLOS'
158
- end
159
- end
160
- end
161
-
162
- test 'grouped collection with associations' do
163
- tag_groups = [
164
- TagGroup.new(1, "Group of Tags", [Tag.new(1, "Tag 1"), Tag.new(2, "Tag 2")]),
165
- TagGroup.new(2, "Other group", [Tag.new(3, "Tag 3"), Tag.new(4, "Tag 4")])
166
- ]
167
-
168
- with_input_for @user, :tag_ids, :grouped_select,
169
- collection: tag_groups, group_method: :tags
170
-
171
- assert_select 'select.grouped_select#user_tag_ids' do
172
- assert_select 'optgroup[label="Group of Tags"]' do
173
- assert_select 'option[value="1"]', 'Tag 1'
174
- assert_select 'option[value="2"]', 'Tag 2'
175
- end
176
-
177
- assert_select 'optgroup[label="Other group"]' do
178
- assert_select 'option[value="3"]', 'Tag 3'
179
- assert_select 'option[value="4"]', 'Tag 4'
180
- end
181
- end
182
- end
183
-
184
- test 'grouped collection accepts html options as the last element of collection' do
185
- with_input_for @user, :tag_ids, :grouped_select,
186
- collection: [['Authors', [['Jose', 'jose', class: 'foo'], ['Carlos', 'carlos', class: 'bar']]]],
187
- group_method: :last
188
-
189
- assert_select 'select.grouped_select#user_tag_ids' do
190
- assert_select 'optgroup[label=Authors]' do
191
- assert_select 'option.foo', 'Jose'
192
- assert_select 'option.bar', 'Carlos'
193
- end
194
- end
195
- end
196
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: UTF-8
3
- require 'test_helper'
4
-
5
- class HiddenInputTest < ActionView::TestCase
6
- test 'input generates a hidden field' do
7
- with_input_for @user, :name, :hidden
8
- assert_no_select 'input[type=text]'
9
- assert_select 'input#user_name[type=hidden]'
10
- end
11
-
12
- test 'hint does not be generated for hidden fields' do
13
- store_translations(:en, simple_form: { hints: { user: { name: "text" } } }) do
14
- with_input_for @user, :name, :hidden
15
- assert_no_select 'span.hint'
16
- end
17
- end
18
-
19
- test 'label does not be generated for hidden inputs' do
20
- with_input_for @user, :name, :hidden
21
- assert_no_select 'label'
22
- end
23
-
24
- test 'required/aria-required/optional options does not be generated for hidden inputs' do
25
- with_input_for @user, :name, :hidden
26
- assert_no_select 'input.required'
27
- assert_no_select 'input[required]'
28
- assert_no_select 'input[aria-required]'
29
- assert_no_select 'input.optional'
30
- assert_select 'input.hidden#user_name'
31
- end
32
- end