simple_form 5.1.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +64 -16
  5. data/lib/generators/simple_form/install_generator.rb +2 -2
  6. data/lib/generators/simple_form/templates/README +1 -1
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +1 -1
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +126 -194
  9. data/lib/simple_form/components/label_input.rb +1 -1
  10. data/lib/simple_form/form_builder.rb +2 -6
  11. data/lib/simple_form/inputs/boolean_input.rb +6 -2
  12. data/lib/simple_form/inputs/grouped_collection_select_input.rb +1 -1
  13. data/lib/simple_form/inputs/priority_input.rb +16 -2
  14. data/lib/simple_form/railtie.rb +4 -0
  15. data/lib/simple_form/version.rb +1 -1
  16. data/lib/simple_form/wrappers/leaf.rb +1 -1
  17. data/lib/simple_form.rb +9 -5
  18. metadata +11 -83
  19. data/test/action_view_extensions/builder_test.rb +0 -634
  20. data/test/action_view_extensions/form_helper_test.rb +0 -172
  21. data/test/components/custom_components_test.rb +0 -62
  22. data/test/components/label_test.rb +0 -352
  23. data/test/form_builder/association_test.rb +0 -252
  24. data/test/form_builder/button_test.rb +0 -48
  25. data/test/form_builder/error_notification_test.rb +0 -80
  26. data/test/form_builder/error_test.rb +0 -281
  27. data/test/form_builder/general_test.rb +0 -539
  28. data/test/form_builder/hint_test.rb +0 -150
  29. data/test/form_builder/input_field_test.rb +0 -195
  30. data/test/form_builder/label_test.rb +0 -136
  31. data/test/form_builder/wrapper_test.rb +0 -378
  32. data/test/generators/simple_form_generator_test.rb +0 -43
  33. data/test/inputs/boolean_input_test.rb +0 -243
  34. data/test/inputs/collection_check_boxes_input_test.rb +0 -323
  35. data/test/inputs/collection_radio_buttons_input_test.rb +0 -446
  36. data/test/inputs/collection_select_input_test.rb +0 -380
  37. data/test/inputs/color_input_test.rb +0 -10
  38. data/test/inputs/datetime_input_test.rb +0 -176
  39. data/test/inputs/disabled_test.rb +0 -92
  40. data/test/inputs/discovery_test.rb +0 -142
  41. data/test/inputs/file_input_test.rb +0 -17
  42. data/test/inputs/general_test.rb +0 -133
  43. data/test/inputs/grouped_collection_select_input_test.rb +0 -183
  44. data/test/inputs/hidden_input_test.rb +0 -32
  45. data/test/inputs/numeric_input_test.rb +0 -177
  46. data/test/inputs/priority_input_test.rb +0 -50
  47. data/test/inputs/readonly_test.rb +0 -102
  48. data/test/inputs/required_test.rb +0 -158
  49. data/test/inputs/rich_text_area_input_test.rb +0 -15
  50. data/test/inputs/string_input_test.rb +0 -158
  51. data/test/inputs/text_input_test.rb +0 -37
  52. data/test/simple_form_test.rb +0 -18
  53. data/test/support/discovery_inputs.rb +0 -65
  54. data/test/support/misc_helpers.rb +0 -274
  55. data/test/support/mock_controller.rb +0 -30
  56. data/test/support/models.rb +0 -357
  57. data/test/test_helper.rb +0 -95
@@ -1,172 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'test_helper'
3
-
4
- class FormHelperTest < ActionView::TestCase
5
-
6
- test 'SimpleForm for yields an instance of FormBuilder' do
7
- simple_form_for :user do |f|
8
- assert f.instance_of?(SimpleForm::FormBuilder)
9
- end
10
- end
11
-
12
- test 'SimpleForm adds default class to form' do
13
- with_concat_form_for(:user)
14
- assert_select 'form.simple_form'
15
- end
16
-
17
- test 'SimpleForm allows overriding default form class' do
18
- swap SimpleForm, default_form_class: "my_custom_class" do
19
- with_concat_form_for :user, html: { class: "override_class" }
20
- assert_no_select 'form.my_custom_class'
21
- assert_select 'form.override_class'
22
- end
23
- end
24
-
25
- # Remove this test when SimpleForm.form_class is removed in 4.x
26
- test 'SimpleForm allows overriding default form class, but not form class' do
27
- ActiveSupport::Deprecation.silence do
28
- swap SimpleForm, form_class: "fixed_class", default_form_class: "my_custom_class" do
29
- with_concat_form_for :user, html: { class: "override_class" }
30
- assert_no_select 'form.my_custom_class'
31
- assert_select 'form.fixed_class.override_class'
32
- end
33
- end
34
- end
35
-
36
- test 'SimpleForm uses default browser validations by default' do
37
- with_concat_form_for(:user)
38
- assert_no_select 'form[novalidate]'
39
- end
40
-
41
- test 'SimpleForm does not use default browser validations if specified in the configuration options' do
42
- swap SimpleForm, browser_validations: false do
43
- with_concat_form_for(:user)
44
- assert_select 'form[novalidate="novalidate"]'
45
- end
46
- end
47
-
48
- test 'disabled browser validations overrides default configuration' do
49
- with_concat_form_for(:user, html: { novalidate: true })
50
- assert_select 'form[novalidate="novalidate"]'
51
- end
52
-
53
- test 'enabled browser validations overrides disabled configuration' do
54
- swap SimpleForm, browser_validations: false do
55
- with_concat_form_for(:user, html: { novalidate: false })
56
- assert_no_select 'form[novalidate]'
57
- end
58
- end
59
-
60
- test 'SimpleForm adds object name as css class to form when object is not present' do
61
- with_concat_form_for(:user, html: { novalidate: true })
62
- assert_select 'form.simple_form.user'
63
- end
64
-
65
- test 'SimpleForm adds :as option as css class to form when object is not present' do
66
- with_concat_form_for(:user, as: 'superuser')
67
- assert_select 'form.simple_form.superuser'
68
- end
69
-
70
- test 'SimpleForm adds object class name with new prefix as css class to form if record is not persisted' do
71
- @user.new_record!
72
- with_concat_form_for(@user)
73
- assert_select 'form.simple_form.new_user'
74
- end
75
-
76
- test 'SimpleForm adds :as option with new prefix as css class to form if record is not persisted' do
77
- @user.new_record!
78
- with_concat_form_for(@user, as: 'superuser')
79
- assert_select 'form.simple_form.new_superuser'
80
- end
81
-
82
- test 'SimpleForm adds edit class prefix as css class to form if record is persisted' do
83
- with_concat_form_for(@user)
84
- assert_select 'form.simple_form.edit_user'
85
- end
86
-
87
- test 'SimpleForm adds :as options with edit prefix as css class to form if record is persisted' do
88
- with_concat_form_for(@user, as: 'superuser')
89
- assert_select 'form.simple_form.edit_superuser'
90
- end
91
-
92
- test 'SimpleForm adds last object name as css class to form when there is array of objects' do
93
- with_concat_form_for([Company.new, @user])
94
- assert_select 'form.simple_form.edit_user'
95
- end
96
-
97
- test 'SimpleForm does not add object class to form if css_class is specified' do
98
- with_concat_form_for(:user, html: { class: nil })
99
- assert_no_select 'form.user'
100
- end
101
-
102
- test 'SimpleForm adds custom class to form if css_class is specified' do
103
- with_concat_form_for(:user, html: { class: 'my_class' })
104
- assert_select 'form.my_class'
105
- end
106
-
107
- test 'passes options to SimpleForm' do
108
- with_concat_form_for(:user, url: '/account', html: { id: 'my_form' })
109
- assert_select 'form#my_form'
110
- assert_select 'form[action="/account"]'
111
- end
112
-
113
- test 'form_for yields an instance of FormBuilder' do
114
- with_concat_form_for(:user) do |f|
115
- assert f.instance_of?(SimpleForm::FormBuilder)
116
- end
117
- end
118
-
119
- test 'fields_for with a hash like model yields an instance of FormBuilder' do
120
- with_concat_fields_for(:author, HashBackedAuthor.new) do |f|
121
- assert f.instance_of?(SimpleForm::FormBuilder)
122
- f.input :name
123
- end
124
-
125
- assert_select "input[name='author[name]'][value='hash backed author']"
126
- end
127
-
128
- test 'custom error proc is not destructive' do
129
- swap_field_error_proc do
130
- result = nil
131
- simple_form_for :user do |f|
132
- result = simple_fields_for 'address' do
133
- 'hello'
134
- end
135
- end
136
-
137
- assert_equal 'hello', result
138
- end
139
- end
140
-
141
- test 'custom error proc survives an exception' do
142
- swap_field_error_proc do
143
- begin
144
- simple_form_for :user do |f|
145
- simple_fields_for 'address' do
146
- raise 'an exception'
147
- end
148
- end
149
- rescue StandardError
150
- end
151
- end
152
- end
153
-
154
- test 'SimpleForm for swaps default action view field_error_proc' do
155
- expected_error_proc = -> {}
156
- swap SimpleForm, field_error_proc: expected_error_proc do
157
- simple_form_for :user do |f|
158
- assert_equal expected_error_proc, ::ActionView::Base.field_error_proc
159
- end
160
- end
161
- end
162
-
163
- private
164
-
165
- def swap_field_error_proc(expected_error_proc = -> {})
166
- swap ActionView::Base, field_error_proc: expected_error_proc do
167
- yield
168
-
169
- assert_equal expected_error_proc, ActionView::Base.field_error_proc
170
- end
171
- end
172
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- # Module that represents a custom component.
6
- module Numbers
7
- def number(wrapper_options = nil)
8
- @number ||= options[:number].to_s.html_safe
9
- end
10
- end
11
-
12
- # Module that represents a custom component.
13
- module InputGroup
14
- def prepend(wrapper_options = nil)
15
- span_tag = content_tag(:span, options[:prepend], class: 'input-group-text')
16
- template.content_tag(:div, span_tag, class: 'input-group-prepend')
17
- end
18
-
19
- def append(wrapper_options = nil)
20
- span_tag = content_tag(:span, options[:append], class: 'input-group-text')
21
- template.content_tag(:div, span_tag, class: 'input-group-append')
22
- end
23
- end
24
-
25
- class CustomComponentsTest < ActionView::TestCase
26
- test 'includes the custom components' do
27
- SimpleForm.include_component Numbers
28
-
29
- custom_wrapper = SimpleForm.build tag: :div, class: "custom_wrapper" do |b|
30
- b.use :number, wrap_with: { tag: 'div', class: 'number' }
31
- end
32
-
33
- with_form_for @user, :name, number: 1, wrapper: custom_wrapper
34
-
35
- assert_select 'div.number', text: '1'
36
- end
37
-
38
- test 'includes custom components and use it as optional in the wrapper' do
39
- SimpleForm.include_component InputGroup
40
-
41
- custom_wrapper = SimpleForm.build tag: :div, class: 'custom_wrapper' do |b|
42
- b.use :label
43
- b.optional :prepend
44
- b.use :input
45
- b.use :append
46
- end
47
-
48
- with_form_for @user, :name, prepend: true, wrapper: custom_wrapper
49
-
50
- assert_select 'div.input-group-prepend > span.input-group-text'
51
- assert_select 'div.input-group-append > span.input-group-text'
52
- end
53
-
54
- test 'raises a TypeError when the component is not a Module' do
55
- component = 'MyComponent'
56
-
57
- exception = assert_raises TypeError do
58
- SimpleForm.include_component(component)
59
- end
60
- assert_equal exception.message, "SimpleForm.include_component expects a module but got: String"
61
- end
62
- end
@@ -1,352 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: UTF-8
3
- require 'test_helper'
4
-
5
- # Isolated tests for label without triggering f.label.
6
- class IsolatedLabelTest < ActionView::TestCase
7
- def with_label_for(object, attribute_name, type, options = {})
8
- with_concat_form_for(object) do |f|
9
- options[:reflection] = Association.new(Company, :company, {}) if options.delete(:setup_association)
10
- SimpleForm::Inputs::Base.new(f, attribute_name, nil, type, options).label
11
- end
12
- end
13
-
14
- test 'label generates a default humanized description' do
15
- with_label_for @user, :name, :string
16
- assert_select 'label[for=user_name]', /Name/
17
- end
18
-
19
- test 'label allows a customized description' do
20
- with_label_for @user, :name, :string, label: 'My label!'
21
- assert_select 'label[for=user_name]', /My label!/
22
- end
23
-
24
- test 'label uses human attribute name from object when available' do
25
- with_label_for @user, :description, :text
26
- assert_select 'label[for=user_description]', /User Description!/
27
- end
28
-
29
- test 'label uses human attribute name based on association name' do
30
- with_label_for @user, :company_id, :string, setup_association: true
31
- assert_select 'label', /Company Human Name!/
32
- end
33
-
34
- test 'label uses i18n based on model, action, and attribute to lookup translation' do
35
- @controller.action_name = "new"
36
- store_translations(:en, simple_form: { labels: { user: {
37
- new: { description: 'Nova descrição' }
38
- } } }) do
39
- with_label_for @user, :description, :text
40
- assert_select 'label[for=user_description]', /Nova descrição/
41
- end
42
- end
43
-
44
- test 'label fallbacks to new when action is create' do
45
- @controller.action_name = "create"
46
- store_translations(:en, simple_form: { labels: { user: {
47
- new: { description: 'Nova descrição' }
48
- } } }) do
49
- with_label_for @user, :description, :text
50
- assert_select 'label[for=user_description]', /Nova descrição/
51
- end
52
- end
53
-
54
- test 'label does not explode while looking for i18n translation when action is not set' do
55
- def @controller.action_name; nil; end
56
-
57
- assert_nothing_raised do
58
- with_label_for @user, :description, :text
59
- end
60
- assert_select 'label[for=user_description]'
61
- end
62
-
63
- test 'label uses i18n based on model and attribute to lookup translation' do
64
- store_translations(:en, simple_form: { labels: { user: {
65
- description: 'Descrição'
66
- } } }) do
67
- with_label_for @user, :description, :text
68
- assert_select 'label[for=user_description]', /Descrição/
69
- end
70
- end
71
-
72
- test 'label uses i18n under defaults to lookup translation' do
73
- store_translations(:en, simple_form: { labels: { defaults: { age: 'Idade' } } }) do
74
- with_label_for @user, :age, :integer
75
- assert_select 'label[for=user_age]', /Idade/
76
- end
77
- end
78
-
79
- test 'label does not use i18n label if translate is false' do
80
- swap SimpleForm, translate_labels: false do
81
- store_translations(:en, simple_form: { labels: { defaults: { age: 'Idade' } } }) do
82
- with_label_for @user, :age, :integer
83
- assert_select 'label[for=user_age]', /Age/
84
- end
85
- end
86
- end
87
-
88
- test 'label uses i18n with lookup for association name' do
89
- store_translations(:en, simple_form: { labels: {
90
- user: { company: 'My company!' }
91
- } }) do
92
- with_label_for @user, :company_id, :string, setup_association: true
93
- assert_select 'label[for=user_company_id]', /My company!/
94
- end
95
- end
96
-
97
- test 'label uses i18n under defaults namespace to lookup for association name' do
98
- store_translations(:en, simple_form: { labels: {
99
- defaults: { company: 'Plataformatec' }
100
- } }) do
101
- with_label_for @user, :company, :string, setup_association: true
102
-
103
- assert_select 'form label', /Plataformatec/
104
- end
105
- end
106
-
107
- test 'label does correct i18n lookup for nested models with nested translation' do
108
- @user.company = Company.new(1, 'Empresa')
109
-
110
- store_translations(:en, simple_form: { labels: {
111
- user: { name: 'Usuario', company: { name: 'Nome da empresa' } }
112
- } }) do
113
- with_concat_form_for @user do |f|
114
- concat f.input :name
115
- concat(f.simple_fields_for(:company) do |company_form|
116
- concat(company_form.input :name)
117
- end)
118
- end
119
-
120
- assert_select 'label[for=user_name]', /Usuario/
121
- assert_select 'label[for=user_company_attributes_name]', /Nome da empresa/
122
- end
123
- end
124
-
125
- test 'label does correct i18n lookup for nested models with no nested translation' do
126
- @user.company = Company.new(1, 'Empresa')
127
-
128
- store_translations(:en, simple_form: { labels: {
129
- user: { name: 'Usuario' },
130
- company: { name: 'Nome da empresa' }
131
- } }) do
132
- with_concat_form_for @user do |f|
133
- concat f.input :name
134
- concat(f.simple_fields_for(:company) do |company_form|
135
- concat(company_form.input :name)
136
- end)
137
- end
138
-
139
- assert_select 'label[for=user_name]', /Usuario/
140
- assert_select 'label[for=user_company_attributes_name]', /Nome da empresa/
141
- end
142
- end
143
-
144
- test 'label does correct i18n lookup for nested has_many models with no nested translation' do
145
- @user.tags = [Tag.new(1, 'Empresa')]
146
-
147
- store_translations(:en, simple_form: { labels: {
148
- user: { name: 'Usuario' },
149
- tags: { name: 'Nome da empresa' }
150
- } }) do
151
- with_concat_form_for @user do |f|
152
- concat f.input :name
153
- concat(f.simple_fields_for(:tags, child_index: "new_index") do |tags_form|
154
- concat(tags_form.input :name)
155
- end)
156
- end
157
-
158
- assert_select 'label[for=user_name]', /Usuario/
159
- assert_select 'label[for=user_tags_attributes_new_index_name]', /Nome da empresa/
160
- end
161
- end
162
-
163
- test 'label has css class from type' do
164
- with_label_for @user, :name, :string
165
- assert_select 'label.string'
166
- with_label_for @user, :description, :text
167
- assert_select 'label.text'
168
- with_label_for @user, :age, :integer
169
- assert_select 'label.integer'
170
- with_label_for @user, :born_at, :date
171
- assert_select 'label.date'
172
- with_label_for @user, :created_at, :datetime
173
- assert_select 'label.datetime'
174
- end
175
-
176
- test 'label does not have css class from type when generate_additional_classes_for does not include :label' do
177
- swap SimpleForm, generate_additional_classes_for: %i[wrapper input] do
178
- with_label_for @user, :name, :string
179
- assert_no_select 'label.string'
180
- with_label_for @user, :description, :text
181
- assert_no_select 'label.text'
182
- with_label_for @user, :age, :integer
183
- assert_no_select 'label.integer'
184
- with_label_for @user, :born_at, :date
185
- assert_no_select 'label.date'
186
- with_label_for @user, :created_at, :datetime
187
- assert_no_select 'label.datetime'
188
- end
189
- end
190
-
191
- test 'label does not generate empty css class' do
192
- swap SimpleForm, generate_additional_classes_for: %i[wrapper input] do
193
- with_label_for @user, :name, :string
194
- assert_no_select 'label[class]'
195
- end
196
- end
197
-
198
- test 'label obtains required from ActiveModel::Validations when it is included' do
199
- with_label_for @validating_user, :name, :string
200
- assert_select 'label.required'
201
- with_label_for @validating_user, :status, :string
202
- assert_select 'label.optional'
203
- end
204
-
205
- test 'label does not obtain required from ActiveModel::Validations when generate_additional_classes_for does not include :label' do
206
- swap SimpleForm, generate_additional_classes_for: %i[wrapper input] do
207
- with_label_for @validating_user, :name, :string
208
- assert_no_select 'label.required'
209
- with_label_for @validating_user, :status, :string
210
- assert_no_select 'label.optional'
211
- end
212
- end
213
-
214
- test 'label allows overriding required when ActiveModel::Validations is included' do
215
- with_label_for @validating_user, :name, :string, required: false
216
- assert_select 'label.optional'
217
- with_label_for @validating_user, :status, :string, required: true
218
- assert_select 'label.required'
219
- end
220
-
221
- test 'label is required by default when ActiveModel::Validations is not included' do
222
- with_label_for @user, :name, :string
223
- assert_select 'label.required'
224
- end
225
-
226
- test 'label is able to disable required when ActiveModel::Validations is not included' do
227
- with_label_for @user, :name, :string, required: false
228
- assert_no_select 'label.required'
229
- end
230
-
231
- test 'label adds required text when required' do
232
- with_label_for @user, :name, :string
233
- assert_select 'label.required abbr[title=required]', '*'
234
- end
235
-
236
- test 'label does not have required text in no required inputs' do
237
- with_label_for @user, :name, :string, required: false
238
- assert_no_select 'form label abbr'
239
- end
240
-
241
- test 'label uses i18n to find required text' do
242
- store_translations(:en, simple_form: { required: { text: 'campo requerido' } }) do
243
- with_label_for @user, :name, :string
244
- assert_select 'form label abbr[title="campo requerido"]', '*'
245
- end
246
- end
247
-
248
- test 'label uses custom i18n scope to find required text' do
249
- store_translations(:en, my_scope: { required: { text: 'Pflichtfeld' } }) do
250
- swap SimpleForm, i18n_scope: :my_scope do
251
- with_label_for @user, :name, :string
252
- assert_select 'form label abbr[title="Pflichtfeld"]', '*'
253
- end
254
- end
255
- end
256
-
257
- test 'label uses i18n to find required mark' do
258
- store_translations(:en, simple_form: { required: { mark: '*-*' } }) do
259
- with_label_for @user, :name, :string
260
- assert_select 'form label abbr', '*-*'
261
- end
262
- end
263
-
264
- test 'label uses custom i18n scope to find required mark' do
265
- store_translations(:en, my_scope: { required: { mark: '!!' } }) do
266
- swap SimpleForm, i18n_scope: :my_scope do
267
- with_label_for @user, :name, :string
268
- assert_select 'form label abbr', '!!'
269
- end
270
- end
271
- end
272
-
273
- test 'label uses i18n to find required string tag' do
274
- store_translations(:en, simple_form: { required: { html: '<span class="required" title="requerido">*</span>' } }) do
275
- with_label_for @user, :name, :string
276
- assert_no_select 'form label abbr'
277
- assert_select 'form label span.required[title=requerido]', '*'
278
- end
279
- end
280
-
281
- test 'label uses custom i18n scope to find required string tag' do
282
- store_translations(:en, my_scope: { required: { html: '<span class="mandatory" title="Pflichtfeld">!!</span>' } }) do
283
- swap SimpleForm, i18n_scope: :my_scope do
284
- with_label_for @user, :name, :string
285
- assert_no_select 'form label abbr'
286
- assert_select 'form label span.mandatory[title=Pflichtfeld]', '!!'
287
- end
288
- end
289
- end
290
-
291
- test 'label allows overwriting input id' do
292
- with_label_for @user, :name, :string, input_html: { id: 'my_new_id' }
293
- assert_select 'label[for=my_new_id]'
294
- end
295
-
296
- test 'label allows overwriting of for attribute' do
297
- with_label_for @user, :name, :string, label_html: { for: 'my_new_id' }
298
- assert_select 'label[for=my_new_id]'
299
- end
300
-
301
- test 'label allows overwriting of for attribute with input_html not containing id' do
302
- with_label_for @user, :name, :string, label_html: { for: 'my_new_id' }, input_html: { class: 'foo' }
303
- assert_select 'label[for=my_new_id]'
304
- end
305
-
306
- test 'label uses default input id when it was not overridden' do
307
- with_label_for @user, :name, :string, input_html: { class: 'my_new_id' }
308
- assert_select 'label[for=user_name]'
309
- end
310
-
311
- test 'label is generated properly when object is not present' do
312
- with_label_for :project, :name, :string
313
- assert_select 'label[for=project_name]', /Name/
314
- end
315
-
316
- test 'label includes for attribute for select collection' do
317
- with_label_for @user, :sex, :select, collection: %i[male female]
318
- assert_select 'label[for=user_sex]'
319
- end
320
-
321
- test 'label uses i18n properly when object is not present' do
322
- store_translations(:en, simple_form: { labels: {
323
- project: { name: 'Nome' }
324
- } }) do
325
- with_label_for :project, :name, :string
326
- assert_select 'label[for=project_name]', /Nome/
327
- end
328
- end
329
-
330
- test 'label adds required by default when object is not present' do
331
- with_label_for :project, :name, :string
332
- assert_select 'label.required[for=project_name]'
333
- with_label_for :project, :description, :string, required: false
334
- assert_no_select 'label.required[for=project_description]'
335
- end
336
-
337
- test 'label adds chosen label class' do
338
- swap SimpleForm, label_class: :my_custom_class do
339
- with_label_for @user, :name, :string
340
- assert_select 'label.my_custom_class'
341
- end
342
- end
343
-
344
- test 'label strips extra classes even when label_class is nil' do
345
- swap SimpleForm, label_class: nil do
346
- with_label_for @user, :name, :string
347
- assert_select "label[class='string required']"
348
- assert_no_select "label[class='string required ']"
349
- assert_no_select "label[class=' string required']"
350
- end
351
- end
352
- end