simple_form 2.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of simple_form might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +77 -33
- data/MIT-LICENSE +1 -1
- data/README.md +387 -187
- data/lib/generators/simple_form/install_generator.rb +4 -4
- data/lib/generators/simple_form/templates/README +3 -4
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +45 -22
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +128 -24
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +87 -6
- data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +7 -2
- data/lib/simple_form/action_view_extensions/builder.rb +2 -319
- data/lib/simple_form/action_view_extensions/form_helper.rb +8 -11
- data/lib/simple_form/components/errors.rb +28 -2
- data/lib/simple_form/components/hints.rb +8 -3
- data/lib/simple_form/components/html5.rb +6 -3
- data/lib/simple_form/components/label_input.rb +20 -2
- data/lib/simple_form/components/labels.rb +14 -10
- data/lib/simple_form/components/maxlength.rb +2 -9
- data/lib/simple_form/components/min_max.rb +1 -1
- data/lib/simple_form/components/pattern.rb +3 -3
- data/lib/simple_form/components/placeholders.rb +2 -2
- data/lib/simple_form/components/readonly.rb +1 -1
- data/lib/simple_form/components.rb +1 -1
- data/lib/simple_form/error_notification.rb +2 -2
- data/lib/simple_form/form_builder.rb +262 -107
- data/lib/simple_form/helpers.rb +6 -6
- data/lib/simple_form/inputs/base.rb +37 -16
- data/lib/simple_form/inputs/block_input.rb +2 -2
- data/lib/simple_form/inputs/boolean_input.rb +33 -18
- data/lib/simple_form/inputs/collection_input.rb +34 -13
- data/lib/simple_form/inputs/collection_radio_buttons_input.rb +7 -12
- data/lib/simple_form/inputs/collection_select_input.rb +4 -2
- data/lib/simple_form/inputs/date_time_input.rb +23 -9
- data/lib/simple_form/inputs/file_input.rb +4 -2
- data/lib/simple_form/inputs/grouped_collection_select_input.rb +15 -3
- data/lib/simple_form/inputs/hidden_input.rb +4 -2
- data/lib/simple_form/inputs/numeric_input.rb +3 -8
- data/lib/simple_form/inputs/password_input.rb +4 -3
- data/lib/simple_form/inputs/priority_input.rb +4 -2
- data/lib/simple_form/inputs/range_input.rb +1 -1
- data/lib/simple_form/inputs/string_input.rb +4 -3
- data/lib/simple_form/inputs/text_input.rb +4 -2
- data/lib/simple_form/railtie.rb +14 -0
- data/lib/simple_form/tags.rb +68 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/wrappers/builder.rb +11 -35
- data/lib/simple_form/wrappers/leaf.rb +28 -0
- data/lib/simple_form/wrappers/many.rb +7 -7
- data/lib/simple_form/wrappers/root.rb +2 -2
- data/lib/simple_form/wrappers/single.rb +5 -3
- data/lib/simple_form/wrappers.rb +2 -1
- data/lib/simple_form.rb +99 -52
- data/test/action_view_extensions/builder_test.rb +113 -127
- data/test/action_view_extensions/form_helper_test.rb +58 -30
- data/test/components/label_test.rb +83 -83
- data/test/form_builder/association_test.rb +96 -61
- data/test/form_builder/button_test.rb +14 -14
- data/test/form_builder/error_notification_test.rb +9 -9
- data/test/form_builder/error_test.rb +159 -34
- data/test/form_builder/general_test.rb +176 -121
- data/test/form_builder/hint_test.rb +43 -37
- data/test/form_builder/input_field_test.rb +99 -52
- data/test/form_builder/label_test.rb +67 -15
- data/test/form_builder/wrapper_test.rb +157 -41
- data/test/generators/simple_form_generator_test.rb +4 -4
- data/test/inputs/boolean_input_test.rb +92 -24
- data/test/inputs/collection_check_boxes_input_test.rb +150 -71
- data/test/inputs/collection_radio_buttons_input_test.rb +213 -113
- data/test/inputs/collection_select_input_test.rb +221 -85
- data/test/inputs/datetime_input_test.rb +125 -47
- data/test/inputs/disabled_test.rb +25 -25
- data/test/inputs/discovery_test.rb +60 -10
- data/test/inputs/file_input_test.rb +3 -3
- data/test/inputs/general_test.rb +48 -32
- data/test/inputs/grouped_collection_select_input_test.rb +76 -27
- data/test/inputs/hidden_input_test.rb +6 -5
- data/test/inputs/numeric_input_test.rb +46 -46
- data/test/inputs/priority_input_test.rb +21 -15
- data/test/inputs/readonly_test.rb +31 -31
- data/test/inputs/required_test.rb +30 -18
- data/test/inputs/string_input_test.rb +53 -52
- data/test/inputs/text_input_test.rb +15 -8
- data/test/simple_form_test.rb +8 -0
- data/test/support/discovery_inputs.rb +32 -2
- data/test/support/misc_helpers.rb +130 -29
- data/test/support/mock_controller.rb +6 -6
- data/test/support/models.rb +125 -71
- data/test/test_helper.rb +28 -35
- metadata +17 -29
- 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,28 +6,34 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
|
|
6
6
|
SimpleForm::Inputs::CollectionCheckBoxesInput.reset_i18n_cache :boolean_collection
|
7
7
|
end
|
8
8
|
|
9
|
-
test 'input check boxes
|
10
|
-
with_input_for @user, :gender, :check_boxes, :
|
9
|
+
test 'input check boxes does not include for attribute by default' do
|
10
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
|
11
11
|
assert_select 'label'
|
12
12
|
assert_no_select 'label[for=user_gender]'
|
13
13
|
end
|
14
14
|
|
15
|
-
test 'input check boxes
|
16
|
-
with_input_for @user, :gender, :check_boxes, :
|
15
|
+
test 'input check boxes includes for attribute when giving as html option' do
|
16
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female], label_html: { for: 'gender' }
|
17
17
|
assert_select 'label[for=gender]'
|
18
18
|
end
|
19
19
|
|
20
|
-
test 'collection input with check_boxes type
|
21
|
-
with_input_for @user, :name, :check_boxes, :
|
20
|
+
test 'collection input with check_boxes type does not generate required html attribute' do
|
21
|
+
with_input_for @user, :name, :check_boxes, collection: ['Jose', 'Carlos']
|
22
22
|
assert_select 'input.required'
|
23
23
|
assert_no_select 'input[required]'
|
24
24
|
end
|
25
25
|
|
26
|
-
test 'input
|
27
|
-
|
28
|
-
|
26
|
+
test 'collection input with check_boxes type does not generate aria-required html attribute' do
|
27
|
+
with_input_for @user, :name, :check_boxes, collection: ['Jose', 'Carlos']
|
28
|
+
assert_select 'input.required'
|
29
|
+
assert_no_select 'input[aria-required]'
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'input does automatic collection translation for check_box types using defaults key' do
|
33
|
+
store_translations(:en, simple_form: { options: { defaults: {
|
34
|
+
gender: { male: 'Male', female: 'Female'}
|
29
35
|
} } } ) do
|
30
|
-
with_input_for @user, :gender, :check_boxes, :
|
36
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
|
31
37
|
assert_select 'input[type=checkbox][value=male]'
|
32
38
|
assert_select 'input[type=checkbox][value=female]'
|
33
39
|
assert_select 'label.collection_check_boxes', 'Male'
|
@@ -35,11 +41,11 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
|
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
|
-
test 'input
|
39
|
-
store_translations(:en, :
|
40
|
-
:
|
44
|
+
test 'input does automatic collection translation for check_box types using specific object key' do
|
45
|
+
store_translations(:en, simple_form: { options: { user: {
|
46
|
+
gender: { male: 'Male', female: 'Female'}
|
41
47
|
} } } ) do
|
42
|
-
with_input_for @user, :gender, :check_boxes, :
|
48
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
|
43
49
|
assert_select 'input[type=checkbox][value=male]'
|
44
50
|
assert_select 'input[type=checkbox][value=female]'
|
45
51
|
assert_select 'label.collection_check_boxes', 'Male'
|
@@ -47,103 +53,122 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
|
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
56
|
+
test 'input that uses automatic collection translation for check_boxes properly sets checked values' do
|
57
|
+
store_translations(:en, simple_form: { options: { defaults: {
|
58
|
+
gender: { male: 'Male', female: 'Female'}
|
59
|
+
} } } ) do
|
60
|
+
@user.gender = 'male'
|
61
|
+
|
62
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
|
63
|
+
assert_select 'input[type=checkbox][value=male][checked=checked]'
|
64
|
+
assert_select 'input[type=checkbox][value=female]'
|
65
|
+
assert_select 'label.collection_check_boxes', 'Male'
|
66
|
+
assert_select 'label.collection_check_boxes', 'Female'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
test 'input check boxes does not wrap the collection by default' do
|
51
71
|
with_input_for @user, :active, :check_boxes
|
52
72
|
|
53
|
-
assert_select 'form input[type=checkbox]', :
|
73
|
+
assert_select 'form input[type=checkbox]', count: 2
|
54
74
|
assert_no_select 'form ul'
|
55
75
|
end
|
56
76
|
|
77
|
+
test 'input check boxes accepts html options as the last element of collection' do
|
78
|
+
with_input_for @user, :name, :check_boxes, collection: [['Jose', 'jose', class: 'foo']]
|
79
|
+
assert_select 'input.foo[type=checkbox][value=jose]'
|
80
|
+
end
|
81
|
+
|
57
82
|
test 'input check boxes wraps the collection in the configured collection wrapper tag' do
|
58
|
-
swap SimpleForm, :
|
83
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
59
84
|
with_input_for @user, :active, :check_boxes
|
60
85
|
|
61
|
-
assert_select 'form ul input[type=checkbox]', :
|
86
|
+
assert_select 'form ul input[type=checkbox]', count: 2
|
62
87
|
end
|
63
88
|
end
|
64
89
|
|
65
90
|
test 'input check boxes does not wrap the collection when configured with falsy values' do
|
66
|
-
swap SimpleForm, :
|
91
|
+
swap SimpleForm, collection_wrapper_tag: false do
|
67
92
|
with_input_for @user, :active, :check_boxes
|
68
93
|
|
69
|
-
assert_select 'form input[type=checkbox]', :
|
94
|
+
assert_select 'form input[type=checkbox]', count: 2
|
70
95
|
assert_no_select 'form ul'
|
71
96
|
end
|
72
97
|
end
|
73
98
|
|
74
99
|
test 'input check boxes allows overriding the collection wrapper tag at input level' do
|
75
|
-
swap SimpleForm, :
|
76
|
-
with_input_for @user, :active, :check_boxes, :
|
100
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
101
|
+
with_input_for @user, :active, :check_boxes, collection_wrapper_tag: :section
|
77
102
|
|
78
|
-
assert_select 'form section input[type=checkbox]', :
|
103
|
+
assert_select 'form section input[type=checkbox]', count: 2
|
79
104
|
assert_no_select 'form ul'
|
80
105
|
end
|
81
106
|
end
|
82
107
|
|
83
108
|
test 'input check boxes allows disabling the collection wrapper tag at input level' do
|
84
|
-
swap SimpleForm, :
|
85
|
-
with_input_for @user, :active, :check_boxes, :
|
109
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
110
|
+
with_input_for @user, :active, :check_boxes, collection_wrapper_tag: false
|
86
111
|
|
87
|
-
assert_select 'form input[type=checkbox]', :
|
112
|
+
assert_select 'form input[type=checkbox]', count: 2
|
88
113
|
assert_no_select 'form ul'
|
89
114
|
end
|
90
115
|
end
|
91
116
|
|
92
117
|
test 'input check boxes renders the wrapper tag with the configured wrapper class' do
|
93
|
-
swap SimpleForm, :
|
118
|
+
swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
|
94
119
|
with_input_for @user, :active, :check_boxes
|
95
120
|
|
96
|
-
assert_select 'form ul.inputs-list input[type=checkbox]', :
|
121
|
+
assert_select 'form ul.inputs-list input[type=checkbox]', count: 2
|
97
122
|
end
|
98
123
|
end
|
99
124
|
|
100
125
|
test 'input check boxes allows giving wrapper class at input level only' do
|
101
|
-
swap SimpleForm, :
|
102
|
-
with_input_for @user, :active, :check_boxes, :
|
126
|
+
swap SimpleForm, collection_wrapper_tag: :ul do
|
127
|
+
with_input_for @user, :active, :check_boxes, collection_wrapper_class: 'items-list'
|
103
128
|
|
104
|
-
assert_select 'form ul.items-list input[type=checkbox]', :
|
129
|
+
assert_select 'form ul.items-list input[type=checkbox]', count: 2
|
105
130
|
end
|
106
131
|
end
|
107
132
|
|
108
133
|
test 'input check boxes uses both configured and given wrapper classes for wrapper tag' do
|
109
|
-
swap SimpleForm, :
|
110
|
-
with_input_for @user, :active, :check_boxes, :
|
134
|
+
swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
|
135
|
+
with_input_for @user, :active, :check_boxes, collection_wrapper_class: 'items-list'
|
111
136
|
|
112
|
-
assert_select 'form ul.inputs-list.items-list input[type=checkbox]', :
|
137
|
+
assert_select 'form ul.inputs-list.items-list input[type=checkbox]', count: 2
|
113
138
|
end
|
114
139
|
end
|
115
140
|
|
116
141
|
test 'input check boxes wraps each item in the configured item wrapper tag' do
|
117
|
-
swap SimpleForm, :
|
142
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
118
143
|
with_input_for @user, :active, :check_boxes
|
119
144
|
|
120
|
-
assert_select 'form li input[type=checkbox]', :
|
145
|
+
assert_select 'form li input[type=checkbox]', count: 2
|
121
146
|
end
|
122
147
|
end
|
123
148
|
|
124
149
|
test 'input check boxes does not wrap items when configured with falsy values' do
|
125
|
-
swap SimpleForm, :
|
150
|
+
swap SimpleForm, item_wrapper_tag: false do
|
126
151
|
with_input_for @user, :active, :check_boxes
|
127
152
|
|
128
|
-
assert_select 'form input[type=checkbox]', :
|
153
|
+
assert_select 'form input[type=checkbox]', count: 2
|
129
154
|
assert_no_select 'form li'
|
130
155
|
end
|
131
156
|
end
|
132
157
|
|
133
158
|
test 'input check boxes allows overriding the item wrapper tag at input level' do
|
134
|
-
swap SimpleForm, :
|
135
|
-
with_input_for @user, :active, :check_boxes, :
|
159
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
160
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_tag: :dl
|
136
161
|
|
137
|
-
assert_select 'form dl input[type=checkbox]', :
|
162
|
+
assert_select 'form dl input[type=checkbox]', count: 2
|
138
163
|
assert_no_select 'form li'
|
139
164
|
end
|
140
165
|
end
|
141
166
|
|
142
167
|
test 'input check boxes allows disabling the item wrapper tag at input level' do
|
143
|
-
swap SimpleForm, :
|
144
|
-
with_input_for @user, :active, :check_boxes, :
|
168
|
+
swap SimpleForm, item_wrapper_tag: :ul do
|
169
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_tag: false
|
145
170
|
|
146
|
-
assert_select 'form input[type=checkbox]', :
|
171
|
+
assert_select 'form input[type=checkbox]', count: 2
|
147
172
|
assert_no_select 'form li'
|
148
173
|
end
|
149
174
|
end
|
@@ -151,74 +176,128 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
|
|
151
176
|
test 'input check boxes wraps items in a span tag by default' do
|
152
177
|
with_input_for @user, :active, :check_boxes
|
153
178
|
|
154
|
-
assert_select 'form span input[type=checkbox]', :
|
179
|
+
assert_select 'form span input[type=checkbox]', count: 2
|
155
180
|
end
|
156
181
|
|
157
182
|
test 'input check boxes renders the item wrapper tag with a default class "checkbox"' do
|
158
|
-
with_input_for @user, :active, :check_boxes, :
|
183
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_tag: :li
|
159
184
|
|
160
|
-
assert_select 'form li.checkbox input[type=checkbox]', :
|
185
|
+
assert_select 'form li.checkbox input[type=checkbox]', count: 2
|
161
186
|
end
|
162
187
|
|
163
188
|
test 'input check boxes renders the item wrapper tag with the configured item wrapper class' do
|
164
|
-
swap SimpleForm, :
|
189
|
+
swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
|
165
190
|
with_input_for @user, :active, :check_boxes
|
166
191
|
|
167
|
-
assert_select 'form li.checkbox.item input[type=checkbox]', :
|
192
|
+
assert_select 'form li.checkbox.item input[type=checkbox]', count: 2
|
168
193
|
end
|
169
194
|
end
|
170
195
|
|
171
196
|
test 'input check boxes allows giving item wrapper class at input level only' do
|
172
|
-
swap SimpleForm, :
|
173
|
-
with_input_for @user, :active, :check_boxes, :
|
197
|
+
swap SimpleForm, item_wrapper_tag: :li do
|
198
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_class: 'item'
|
174
199
|
|
175
|
-
assert_select 'form li.checkbox.item input[type=checkbox]', :
|
200
|
+
assert_select 'form li.checkbox.item input[type=checkbox]', count: 2
|
176
201
|
end
|
177
202
|
end
|
178
203
|
|
179
204
|
test 'input check boxes uses both configured and given item wrapper classes for item wrapper tag' do
|
180
|
-
swap SimpleForm, :
|
181
|
-
with_input_for @user, :active, :check_boxes, :
|
205
|
+
swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
|
206
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_class: 'inline'
|
182
207
|
|
183
|
-
assert_select 'form li.checkbox.item.inline input[type=checkbox]', :
|
208
|
+
assert_select 'form li.checkbox.item.inline input[type=checkbox]', count: 2
|
184
209
|
end
|
185
210
|
end
|
186
211
|
|
187
212
|
test 'input check boxes respects the nested boolean style config, generating nested label > input' do
|
188
|
-
swap SimpleForm, :
|
213
|
+
swap SimpleForm, boolean_style: :nested do
|
189
214
|
with_input_for @user, :active, :check_boxes
|
190
215
|
|
191
|
-
assert_select '
|
192
|
-
assert_select '
|
193
|
-
assert_select '
|
194
|
-
assert_select '
|
216
|
+
assert_select 'span.checkbox > label > input#user_active_true[type=checkbox]'
|
217
|
+
assert_select 'span.checkbox > label', 'Yes'
|
218
|
+
assert_select 'span.checkbox > label > input#user_active_false[type=checkbox]'
|
219
|
+
assert_select 'span.checkbox > label', 'No'
|
195
220
|
assert_no_select 'label.collection_radio_buttons'
|
196
221
|
end
|
197
222
|
end
|
198
223
|
|
199
|
-
test 'input check boxes with nested style overrides configured item wrapper tag
|
200
|
-
swap SimpleForm, :
|
224
|
+
test 'input check boxes with nested style does not overrides configured item wrapper tag' do
|
225
|
+
swap SimpleForm, boolean_style: :nested, item_wrapper_tag: :li do
|
201
226
|
with_input_for @user, :active, :check_boxes
|
202
227
|
|
203
|
-
assert_select '
|
204
|
-
assert_no_select 'li'
|
228
|
+
assert_select 'li.checkbox > label > input'
|
205
229
|
end
|
206
230
|
end
|
207
231
|
|
208
|
-
test 'input check boxes with nested style overrides given item wrapper tag
|
209
|
-
swap SimpleForm, :
|
210
|
-
with_input_for @user, :active, :check_boxes, :
|
232
|
+
test 'input check boxes with nested style does not overrides given item wrapper tag' do
|
233
|
+
swap SimpleForm, boolean_style: :nested do
|
234
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_tag: :li
|
211
235
|
|
212
|
-
assert_select '
|
213
|
-
assert_no_select 'li'
|
236
|
+
assert_select 'li.checkbox > label > input'
|
214
237
|
end
|
215
238
|
end
|
216
239
|
|
217
240
|
test 'input check boxes with nested style accepts giving extra wrapper classes' do
|
218
|
-
swap SimpleForm, :
|
219
|
-
with_input_for @user, :active, :check_boxes, :
|
241
|
+
swap SimpleForm, boolean_style: :nested do
|
242
|
+
with_input_for @user, :active, :check_boxes, item_wrapper_class: "inline"
|
243
|
+
|
244
|
+
assert_select 'span.checkbox.inline > label > input'
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
test 'input check boxes with nested style renders item labels with specified class' do
|
249
|
+
swap SimpleForm, boolean_style: :nested do
|
250
|
+
with_input_for @user, :active, :check_boxes, item_label_class: "test"
|
251
|
+
|
252
|
+
assert_select 'span.checkbox > label.test > input'
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
test 'input check boxes with nested style and falsey input wrapper renders item labels with specified class' do
|
257
|
+
swap SimpleForm, boolean_style: :nested, item_wrapper_tag: false do
|
258
|
+
with_input_for @user, :active, :check_boxes, item_label_class: "checkbox-inline"
|
259
|
+
|
260
|
+
assert_select 'label.checkbox-inline > input'
|
261
|
+
assert_no_select 'span.checkbox'
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
test 'input check boxes wrapper class are not included when set to falsey' do
|
266
|
+
swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
|
267
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
|
268
|
+
|
269
|
+
assert_no_select 'label.checkbox'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
test 'input check boxes custom wrapper class is included when include input wrapper class is falsey' do
|
274
|
+
swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
|
275
|
+
with_input_for @user, :gender, :check_boxes, collection: [:male, :female], item_wrapper_class: 'custom'
|
276
|
+
|
277
|
+
assert_no_select 'label.checkbox'
|
278
|
+
assert_select 'span.custom'
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
test 'input check boxes with nested style and namespace uses the right for attribute' do
|
283
|
+
swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
|
284
|
+
with_concat_form_for @user, namespace: :foo do |f|
|
285
|
+
concat f.input :gender, as: :check_boxes, collection: [:male, :female]
|
286
|
+
end
|
287
|
+
|
288
|
+
assert_select 'label[for=foo_user_gender_male]'
|
289
|
+
assert_select 'label[for=foo_user_gender_female]'
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
test 'input check boxes with nested style and index uses the right for attribute' do
|
294
|
+
swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
|
295
|
+
with_concat_form_for @user, index: 1 do |f|
|
296
|
+
concat f.input :gender, as: :check_boxes, collection: [:male, :female]
|
297
|
+
end
|
220
298
|
|
221
|
-
assert_select 'label
|
299
|
+
assert_select 'label[for=user_1_gender_male]'
|
300
|
+
assert_select 'label[for=user_1_gender_female]'
|
222
301
|
end
|
223
302
|
end
|
224
303
|
end
|