simple_form 2.1.0 → 3.0.0.rc
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +15 -32
- data/README.md +103 -71
- data/lib/generators/simple_form/install_generator.rb +3 -3
- data/lib/generators/simple_form/templates/README +1 -1
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +13 -13
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +14 -14
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +3 -3
- data/lib/simple_form/action_view_extensions/builder.rb +1 -319
- data/lib/simple_form/action_view_extensions/form_helper.rb +2 -9
- data/lib/simple_form/components/html5.rb +5 -2
- data/lib/simple_form/components/labels.rb +3 -3
- data/lib/simple_form/components/maxlength.rb +1 -8
- data/lib/simple_form/components/pattern.rb +2 -2
- data/lib/simple_form/components.rb +1 -1
- data/lib/simple_form/error_notification.rb +2 -2
- data/lib/simple_form/form_builder.rb +147 -49
- data/lib/simple_form/helpers.rb +1 -1
- data/lib/simple_form/inputs/base.rb +2 -6
- data/lib/simple_form/inputs/block_input.rb +1 -1
- data/lib/simple_form/inputs/boolean_input.rb +5 -4
- data/lib/simple_form/inputs/collection_input.rb +6 -6
- data/lib/simple_form/inputs/numeric_input.rb +0 -6
- data/lib/simple_form/inputs/password_input.rb +0 -1
- data/lib/simple_form/inputs/string_input.rb +0 -1
- data/lib/simple_form/railtie.rb +7 -0
- data/lib/simple_form/tags.rb +61 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/wrappers/builder.rb +5 -29
- data/lib/simple_form/wrappers/many.rb +1 -1
- data/lib/simple_form/wrappers/root.rb +1 -1
- data/lib/simple_form/wrappers.rb +1 -1
- data/lib/simple_form.rb +39 -47
- data/test/action_view_extensions/builder_test.rb +75 -88
- data/test/action_view_extensions/form_helper_test.rb +25 -16
- data/test/components/label_test.rb +46 -46
- data/test/form_builder/association_test.rb +39 -29
- data/test/form_builder/button_test.rb +4 -4
- data/test/form_builder/error_notification_test.rb +8 -8
- data/test/form_builder/error_test.rb +12 -12
- data/test/form_builder/general_test.rb +58 -52
- data/test/form_builder/hint_test.rb +22 -22
- data/test/form_builder/input_field_test.rb +12 -12
- data/test/form_builder/label_test.rb +6 -6
- data/test/form_builder/wrapper_test.rb +21 -21
- data/test/inputs/boolean_input_test.rb +23 -23
- data/test/inputs/collection_check_boxes_input_test.rb +61 -55
- data/test/inputs/collection_radio_buttons_input_test.rb +76 -79
- data/test/inputs/collection_select_input_test.rb +70 -45
- data/test/inputs/datetime_input_test.rb +17 -11
- data/test/inputs/disabled_test.rb +10 -10
- data/test/inputs/discovery_test.rb +4 -4
- data/test/inputs/file_input_test.rb +1 -1
- data/test/inputs/general_test.rb +12 -12
- data/test/inputs/grouped_collection_select_input_test.rb +20 -20
- data/test/inputs/hidden_input_test.rb +3 -2
- data/test/inputs/numeric_input_test.rb +3 -3
- data/test/inputs/priority_input_test.rb +9 -3
- data/test/inputs/readonly_test.rb +12 -12
- data/test/inputs/required_test.rb +5 -5
- data/test/inputs/string_input_test.rb +15 -25
- data/test/inputs/text_input_test.rb +1 -1
- data/test/support/misc_helpers.rb +46 -24
- data/test/support/mock_controller.rb +6 -6
- data/test/support/models.rb +62 -61
- data/test/test_helper.rb +20 -24
- metadata +32 -33
- data/lib/simple_form/action_view_extensions/builder.rb.orig +0 -247
- data/lib/simple_form/core_ext/hash.rb +0 -16
- data/lib/simple_form/form_builder.rb.orig +0 -486
- data/lib/simple_form/version.rb.orig +0 -7
|
@@ -6,15 +6,6 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
6
6
|
SimpleForm::Inputs::CollectionRadioButtonsInput.reset_i18n_cache :boolean_collection
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
test 'input :as => :radio is deprecated in favor of :as => :radio_buttons' do
|
|
10
|
-
assert_deprecated "[SIMPLE_FORM] Using `:as => :radio` as " \
|
|
11
|
-
"input type is deprecated, please change it to `:as => :radio_buttons`." do
|
|
12
|
-
with_input_for @user, :active, :radio
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
assert_select 'input[type=radio].radio_buttons', :count => 2
|
|
16
|
-
end
|
|
17
|
-
|
|
18
9
|
test 'input should generate boolean radio buttons by default for radio types' do
|
|
19
10
|
with_input_for @user, :active, :radio_buttons
|
|
20
11
|
assert_select 'input[type=radio][value=true].radio_buttons#user_active_true'
|
|
@@ -28,7 +19,7 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
28
19
|
end
|
|
29
20
|
|
|
30
21
|
test 'input as radio should use i18n to translate internal labels' do
|
|
31
|
-
store_translations(:en, :
|
|
22
|
+
store_translations(:en, simple_form: { yes: 'Sim', no: 'Não' }) do
|
|
32
23
|
with_input_for @user, :active, :radio_buttons
|
|
33
24
|
assert_select 'label[for=user_active_true]', 'Sim'
|
|
34
25
|
assert_select 'label[for=user_active_false]', 'Não'
|
|
@@ -36,13 +27,13 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
36
27
|
end
|
|
37
28
|
|
|
38
29
|
test 'input radio should not include for attribute by default' do
|
|
39
|
-
with_input_for @user, :gender, :radio_buttons, :
|
|
30
|
+
with_input_for @user, :gender, :radio_buttons, collection: [:male, :female]
|
|
40
31
|
assert_select 'label'
|
|
41
32
|
assert_no_select 'label[for=user_gender]'
|
|
42
33
|
end
|
|
43
34
|
|
|
44
35
|
test 'input radio should include for attribute when giving as html option' do
|
|
45
|
-
with_input_for @user, :gender, :radio_buttons, :
|
|
36
|
+
with_input_for @user, :gender, :radio_buttons, collection: [:male, :female], label_html: { for: 'gender' }
|
|
46
37
|
assert_select 'label[for=gender]'
|
|
47
38
|
end
|
|
48
39
|
|
|
@@ -54,7 +45,7 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
54
45
|
end
|
|
55
46
|
|
|
56
47
|
test 'input should allow overriding collection for radio types' do
|
|
57
|
-
with_input_for @user, :name, :radio_buttons, :
|
|
48
|
+
with_input_for @user, :name, :radio_buttons, collection: ['Jose', 'Carlos']
|
|
58
49
|
assert_select 'input[type=radio][value=Jose]'
|
|
59
50
|
assert_select 'input[type=radio][value=Carlos]'
|
|
60
51
|
assert_select 'label.collection_radio_buttons', 'Jose'
|
|
@@ -62,10 +53,10 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
62
53
|
end
|
|
63
54
|
|
|
64
55
|
test 'input should do automatic collection translation for radio types using defaults key' do
|
|
65
|
-
store_translations(:en, :
|
|
66
|
-
:
|
|
56
|
+
store_translations(:en, simple_form: { options: { defaults: {
|
|
57
|
+
gender: { male: 'Male', female: 'Female'}
|
|
67
58
|
} } } ) do
|
|
68
|
-
with_input_for @user, :gender, :radio_buttons, :
|
|
59
|
+
with_input_for @user, :gender, :radio_buttons, collection: [:male, :female]
|
|
69
60
|
assert_select 'input[type=radio][value=male]'
|
|
70
61
|
assert_select 'input[type=radio][value=female]'
|
|
71
62
|
assert_select 'label.collection_radio_buttons', 'Male'
|
|
@@ -74,10 +65,10 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
74
65
|
end
|
|
75
66
|
|
|
76
67
|
test 'input should do automatic collection translation for radio types using specific object key' do
|
|
77
|
-
store_translations(:en, :
|
|
78
|
-
:
|
|
68
|
+
store_translations(:en, simple_form: { options: { user: {
|
|
69
|
+
gender: { male: 'Male', female: 'Female'}
|
|
79
70
|
} } } ) do
|
|
80
|
-
with_input_for @user, :gender, :radio_buttons, :
|
|
71
|
+
with_input_for @user, :gender, :radio_buttons, collection: [:male, :female]
|
|
81
72
|
assert_select 'input[type=radio][value=male]'
|
|
82
73
|
assert_select 'input[type=radio][value=female]'
|
|
83
74
|
assert_select 'label.collection_radio_buttons', 'Male'
|
|
@@ -87,12 +78,12 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
87
78
|
|
|
88
79
|
test 'input should mark the current radio value by default' do
|
|
89
80
|
@user.name = "Carlos"
|
|
90
|
-
with_input_for @user, :name, :radio_buttons, :
|
|
81
|
+
with_input_for @user, :name, :radio_buttons, collection: ['Jose', 'Carlos']
|
|
91
82
|
assert_select 'input[type=radio][value=Carlos][checked=checked]'
|
|
92
83
|
end
|
|
93
84
|
|
|
94
85
|
test 'input should allow using a collection with text/value arrays' do
|
|
95
|
-
with_input_for @user, :name, :radio_buttons, :
|
|
86
|
+
with_input_for @user, :name, :radio_buttons, collection: [['Jose', 'jose'], ['Carlos', 'carlos']]
|
|
96
87
|
assert_select 'input[type=radio][value=jose]'
|
|
97
88
|
assert_select 'input[type=radio][value=carlos]'
|
|
98
89
|
assert_select 'label.collection_radio_buttons', 'Jose'
|
|
@@ -100,32 +91,32 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
100
91
|
end
|
|
101
92
|
|
|
102
93
|
test 'input should allow using a collection with a Proc' do
|
|
103
|
-
with_input_for @user, :name, :radio_buttons, :
|
|
94
|
+
with_input_for @user, :name, :radio_buttons, collection: Proc.new { ['Jose', 'Carlos' ] }
|
|
104
95
|
assert_select 'label.collection_radio_buttons', 'Jose'
|
|
105
96
|
assert_select 'label.collection_radio_buttons', 'Carlos'
|
|
106
97
|
end
|
|
107
98
|
|
|
108
99
|
test 'input should allow overriding only label method for collections' do
|
|
109
100
|
with_input_for @user, :name, :radio_buttons,
|
|
110
|
-
:
|
|
111
|
-
:
|
|
101
|
+
collection: ['Jose', 'Carlos'],
|
|
102
|
+
label_method: :upcase
|
|
112
103
|
assert_select 'label.collection_radio_buttons', 'JOSE'
|
|
113
104
|
assert_select 'label.collection_radio_buttons', 'CARLOS'
|
|
114
105
|
end
|
|
115
106
|
|
|
116
107
|
test 'input should allow overriding only value method for collections' do
|
|
117
108
|
with_input_for @user, :name, :radio_buttons,
|
|
118
|
-
:
|
|
119
|
-
:
|
|
109
|
+
collection: ['Jose', 'Carlos'],
|
|
110
|
+
value_method: :upcase
|
|
120
111
|
assert_select 'input[type=radio][value=JOSE]'
|
|
121
112
|
assert_select 'input[type=radio][value=CARLOS]'
|
|
122
113
|
end
|
|
123
114
|
|
|
124
115
|
test 'input should allow overriding label and value method for collections' do
|
|
125
116
|
with_input_for @user, :name, :radio_buttons,
|
|
126
|
-
:
|
|
127
|
-
:
|
|
128
|
-
:
|
|
117
|
+
collection: ['Jose', 'Carlos'],
|
|
118
|
+
label_method: :upcase,
|
|
119
|
+
value_method: :downcase
|
|
129
120
|
assert_select 'input[type=radio][value=jose]'
|
|
130
121
|
assert_select 'input[type=radio][value=carlos]'
|
|
131
122
|
assert_select 'label.collection_radio_buttons', 'JOSE'
|
|
@@ -134,9 +125,9 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
134
125
|
|
|
135
126
|
test 'input should allow overriding label and value method using a lambda for collections' do
|
|
136
127
|
with_input_for @user, :name, :radio_buttons,
|
|
137
|
-
:
|
|
138
|
-
:
|
|
139
|
-
:
|
|
128
|
+
collection: ['Jose', 'Carlos'],
|
|
129
|
+
label_method: lambda { |i| i.upcase },
|
|
130
|
+
value_method: lambda { |i| i.downcase }
|
|
140
131
|
assert_select 'input[type=radio][value=jose]'
|
|
141
132
|
assert_select 'input[type=radio][value=carlos]'
|
|
142
133
|
assert_select 'label.collection_radio_buttons', 'JOSE'
|
|
@@ -144,108 +135,114 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
144
135
|
end
|
|
145
136
|
|
|
146
137
|
test 'collection input with radio type should generate required html attribute' do
|
|
147
|
-
with_input_for @user, :name, :radio_buttons, :
|
|
138
|
+
with_input_for @user, :name, :radio_buttons, collection: ['Jose', 'Carlos']
|
|
148
139
|
assert_select 'input[type=radio].required'
|
|
149
140
|
assert_select 'input[type=radio][required]'
|
|
150
141
|
end
|
|
151
142
|
|
|
143
|
+
test 'collection input with radio type should generate aria-required html attribute' do
|
|
144
|
+
with_input_for @user, :name, :radio_buttons, collection: ['Jose', 'Carlos']
|
|
145
|
+
assert_select 'input[type=radio].required'
|
|
146
|
+
assert_select 'input[type=radio][aria-required=true]'
|
|
147
|
+
end
|
|
148
|
+
|
|
152
149
|
test 'input radio does not wrap the collection by default' do
|
|
153
150
|
with_input_for @user, :active, :radio_buttons
|
|
154
151
|
|
|
155
|
-
assert_select 'form input[type=radio]', :
|
|
152
|
+
assert_select 'form input[type=radio]', count: 2
|
|
156
153
|
assert_no_select 'form ul'
|
|
157
154
|
end
|
|
158
155
|
|
|
159
156
|
test 'input radio wraps the collection in the configured collection wrapper tag' do
|
|
160
|
-
swap SimpleForm, :
|
|
157
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
|
161
158
|
with_input_for @user, :active, :radio_buttons
|
|
162
159
|
|
|
163
|
-
assert_select 'form ul input[type=radio]', :
|
|
160
|
+
assert_select 'form ul input[type=radio]', count: 2
|
|
164
161
|
end
|
|
165
162
|
end
|
|
166
163
|
|
|
167
164
|
test 'input radio does not wrap the collection when configured with falsy values' do
|
|
168
|
-
swap SimpleForm, :
|
|
165
|
+
swap SimpleForm, collection_wrapper_tag: false do
|
|
169
166
|
with_input_for @user, :active, :radio_buttons
|
|
170
167
|
|
|
171
|
-
assert_select 'form input[type=radio]', :
|
|
168
|
+
assert_select 'form input[type=radio]', count: 2
|
|
172
169
|
assert_no_select 'form ul'
|
|
173
170
|
end
|
|
174
171
|
end
|
|
175
172
|
|
|
176
173
|
test 'input radio allows overriding the collection wrapper tag at input level' do
|
|
177
|
-
swap SimpleForm, :
|
|
178
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
174
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
|
175
|
+
with_input_for @user, :active, :radio_buttons, collection_wrapper_tag: :section
|
|
179
176
|
|
|
180
|
-
assert_select 'form section input[type=radio]', :
|
|
177
|
+
assert_select 'form section input[type=radio]', count: 2
|
|
181
178
|
assert_no_select 'form ul'
|
|
182
179
|
end
|
|
183
180
|
end
|
|
184
181
|
|
|
185
182
|
test 'input radio allows disabling the collection wrapper tag at input level' do
|
|
186
|
-
swap SimpleForm, :
|
|
187
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
183
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
|
184
|
+
with_input_for @user, :active, :radio_buttons, collection_wrapper_tag: false
|
|
188
185
|
|
|
189
|
-
assert_select 'form input[type=radio]', :
|
|
186
|
+
assert_select 'form input[type=radio]', count: 2
|
|
190
187
|
assert_no_select 'form ul'
|
|
191
188
|
end
|
|
192
189
|
end
|
|
193
190
|
|
|
194
191
|
test 'input radio renders the wrapper tag with the configured wrapper class' do
|
|
195
|
-
swap SimpleForm, :
|
|
192
|
+
swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
|
|
196
193
|
with_input_for @user, :active, :radio_buttons
|
|
197
194
|
|
|
198
|
-
assert_select 'form ul.inputs-list input[type=radio]', :
|
|
195
|
+
assert_select 'form ul.inputs-list input[type=radio]', count: 2
|
|
199
196
|
end
|
|
200
197
|
end
|
|
201
198
|
|
|
202
199
|
test 'input radio allows giving wrapper class at input level only' do
|
|
203
|
-
swap SimpleForm, :
|
|
204
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
200
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
|
201
|
+
with_input_for @user, :active, :radio_buttons, collection_wrapper_class: 'items-list'
|
|
205
202
|
|
|
206
|
-
assert_select 'form ul.items-list input[type=radio]', :
|
|
203
|
+
assert_select 'form ul.items-list input[type=radio]', count: 2
|
|
207
204
|
end
|
|
208
205
|
end
|
|
209
206
|
|
|
210
207
|
test 'input radio uses both configured and given wrapper classes for wrapper tag' do
|
|
211
|
-
swap SimpleForm, :
|
|
212
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
208
|
+
swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
|
|
209
|
+
with_input_for @user, :active, :radio_buttons, collection_wrapper_class: 'items-list'
|
|
213
210
|
|
|
214
|
-
assert_select 'form ul.inputs-list.items-list input[type=radio]', :
|
|
211
|
+
assert_select 'form ul.inputs-list.items-list input[type=radio]', count: 2
|
|
215
212
|
end
|
|
216
213
|
end
|
|
217
214
|
|
|
218
215
|
test 'input radio wraps each item in the configured item wrapper tag' do
|
|
219
|
-
swap SimpleForm, :
|
|
216
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
|
220
217
|
with_input_for @user, :active, :radio_buttons
|
|
221
218
|
|
|
222
|
-
assert_select 'form li input[type=radio]', :
|
|
219
|
+
assert_select 'form li input[type=radio]', count: 2
|
|
223
220
|
end
|
|
224
221
|
end
|
|
225
222
|
|
|
226
223
|
test 'input radio does not wrap items when configured with falsy values' do
|
|
227
|
-
swap SimpleForm, :
|
|
224
|
+
swap SimpleForm, item_wrapper_tag: false do
|
|
228
225
|
with_input_for @user, :active, :radio_buttons
|
|
229
226
|
|
|
230
|
-
assert_select 'form input[type=radio]', :
|
|
227
|
+
assert_select 'form input[type=radio]', count: 2
|
|
231
228
|
assert_no_select 'form li'
|
|
232
229
|
end
|
|
233
230
|
end
|
|
234
231
|
|
|
235
232
|
test 'input radio allows overriding the item wrapper tag at input level' do
|
|
236
|
-
swap SimpleForm, :
|
|
237
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
233
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
|
234
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_tag: :dl
|
|
238
235
|
|
|
239
|
-
assert_select 'form dl input[type=radio]', :
|
|
236
|
+
assert_select 'form dl input[type=radio]', count: 2
|
|
240
237
|
assert_no_select 'form li'
|
|
241
238
|
end
|
|
242
239
|
end
|
|
243
240
|
|
|
244
241
|
test 'input radio allows disabling the item wrapper tag at input level' do
|
|
245
|
-
swap SimpleForm, :
|
|
246
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
242
|
+
swap SimpleForm, item_wrapper_tag: :ul do
|
|
243
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_tag: false
|
|
247
244
|
|
|
248
|
-
assert_select 'form input[type=radio]', :
|
|
245
|
+
assert_select 'form input[type=radio]', count: 2
|
|
249
246
|
assert_no_select 'form li'
|
|
250
247
|
end
|
|
251
248
|
end
|
|
@@ -253,41 +250,41 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
253
250
|
test 'input radio wraps items in a span tag by default' do
|
|
254
251
|
with_input_for @user, :active, :radio_buttons
|
|
255
252
|
|
|
256
|
-
assert_select 'form span input[type=radio]', :
|
|
253
|
+
assert_select 'form span input[type=radio]', count: 2
|
|
257
254
|
end
|
|
258
255
|
|
|
259
256
|
test 'input radio renders the item wrapper tag with a default class "radio"' do
|
|
260
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
257
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_tag: :li
|
|
261
258
|
|
|
262
|
-
assert_select 'form li.radio input[type=radio]', :
|
|
259
|
+
assert_select 'form li.radio input[type=radio]', count: 2
|
|
263
260
|
end
|
|
264
261
|
|
|
265
262
|
test 'input radio renders the item wrapper tag with the configured item wrapper class' do
|
|
266
|
-
swap SimpleForm, :
|
|
263
|
+
swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
|
|
267
264
|
with_input_for @user, :active, :radio_buttons
|
|
268
265
|
|
|
269
|
-
assert_select 'form li.radio.item input[type=radio]', :
|
|
266
|
+
assert_select 'form li.radio.item input[type=radio]', count: 2
|
|
270
267
|
end
|
|
271
268
|
end
|
|
272
269
|
|
|
273
270
|
test 'input radio allows giving item wrapper class at input level only' do
|
|
274
|
-
swap SimpleForm, :
|
|
275
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
271
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
|
272
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_class: 'item'
|
|
276
273
|
|
|
277
|
-
assert_select 'form li.radio.item input[type=radio]', :
|
|
274
|
+
assert_select 'form li.radio.item input[type=radio]', count: 2
|
|
278
275
|
end
|
|
279
276
|
end
|
|
280
277
|
|
|
281
278
|
test 'input radio uses both configured and given item wrapper classes for item wrapper tag' do
|
|
282
|
-
swap SimpleForm, :
|
|
283
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
279
|
+
swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
|
|
280
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_class: 'inline'
|
|
284
281
|
|
|
285
|
-
assert_select 'form li.radio.item.inline input[type=radio]', :
|
|
282
|
+
assert_select 'form li.radio.item.inline input[type=radio]', count: 2
|
|
286
283
|
end
|
|
287
284
|
end
|
|
288
285
|
|
|
289
286
|
test 'input radio respects the nested boolean style config, generating nested label > input' do
|
|
290
|
-
swap SimpleForm, :
|
|
287
|
+
swap SimpleForm, boolean_style: :nested do
|
|
291
288
|
with_input_for @user, :active, :radio_buttons
|
|
292
289
|
|
|
293
290
|
assert_select 'label.radio > input#user_active_true[type=radio]'
|
|
@@ -299,7 +296,7 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
299
296
|
end
|
|
300
297
|
|
|
301
298
|
test 'input radio with nested style overrides configured item wrapper tag, forcing the :label' do
|
|
302
|
-
swap SimpleForm, :
|
|
299
|
+
swap SimpleForm, boolean_style: :nested, item_wrapper_tag: :li do
|
|
303
300
|
with_input_for @user, :active, :radio_buttons
|
|
304
301
|
|
|
305
302
|
assert_select 'label.radio > input'
|
|
@@ -308,8 +305,8 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
308
305
|
end
|
|
309
306
|
|
|
310
307
|
test 'input radio with nested style overrides given item wrapper tag, forcing the :label' do
|
|
311
|
-
swap SimpleForm, :
|
|
312
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
308
|
+
swap SimpleForm, boolean_style: :nested do
|
|
309
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_tag: :li
|
|
313
310
|
|
|
314
311
|
assert_select 'label.radio > input'
|
|
315
312
|
assert_no_select 'li'
|
|
@@ -317,8 +314,8 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|
|
317
314
|
end
|
|
318
315
|
|
|
319
316
|
test 'input radio with nested style accepts giving extra wrapper classes' do
|
|
320
|
-
swap SimpleForm, :
|
|
321
|
-
with_input_for @user, :active, :radio_buttons, :
|
|
317
|
+
swap SimpleForm, boolean_style: :nested do
|
|
318
|
+
with_input_for @user, :active, :radio_buttons, item_wrapper_class: "inline"
|
|
322
319
|
|
|
323
320
|
assert_select 'label.radio.inline > input'
|
|
324
321
|
end
|