simple_form 3.0.2 → 3.1.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -34
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +204 -81
  5. data/lib/generators/simple_form/install_generator.rb +3 -3
  6. data/lib/generators/simple_form/templates/README +3 -4
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +28 -7
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +115 -24
  9. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +86 -5
  10. data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +7 -2
  11. data/lib/simple_form/action_view_extensions/builder.rb +1 -0
  12. data/lib/simple_form/action_view_extensions/form_helper.rb +6 -2
  13. data/lib/simple_form/components/errors.rb +28 -2
  14. data/lib/simple_form/components/hints.rb +2 -2
  15. data/lib/simple_form/components/html5.rb +1 -1
  16. data/lib/simple_form/components/label_input.rb +20 -2
  17. data/lib/simple_form/components/labels.rb +10 -6
  18. data/lib/simple_form/components/maxlength.rb +1 -1
  19. data/lib/simple_form/components/min_max.rb +1 -1
  20. data/lib/simple_form/components/pattern.rb +1 -1
  21. data/lib/simple_form/components/placeholders.rb +2 -2
  22. data/lib/simple_form/components/readonly.rb +1 -1
  23. data/lib/simple_form/form_builder.rb +123 -73
  24. data/lib/simple_form/helpers.rb +5 -5
  25. data/lib/simple_form/inputs/base.rb +33 -11
  26. data/lib/simple_form/inputs/block_input.rb +1 -1
  27. data/lib/simple_form/inputs/boolean_input.rb +28 -15
  28. data/lib/simple_form/inputs/collection_input.rb +30 -9
  29. data/lib/simple_form/inputs/collection_radio_buttons_input.rb +6 -11
  30. data/lib/simple_form/inputs/collection_select_input.rb +4 -2
  31. data/lib/simple_form/inputs/date_time_input.rb +12 -2
  32. data/lib/simple_form/inputs/file_input.rb +4 -2
  33. data/lib/simple_form/inputs/grouped_collection_select_input.rb +15 -3
  34. data/lib/simple_form/inputs/hidden_input.rb +4 -2
  35. data/lib/simple_form/inputs/numeric_input.rb +5 -4
  36. data/lib/simple_form/inputs/password_input.rb +4 -2
  37. data/lib/simple_form/inputs/priority_input.rb +4 -2
  38. data/lib/simple_form/inputs/range_input.rb +1 -1
  39. data/lib/simple_form/inputs/string_input.rb +4 -2
  40. data/lib/simple_form/inputs/text_input.rb +4 -2
  41. data/lib/simple_form/railtie.rb +7 -0
  42. data/lib/simple_form/tags.rb +6 -0
  43. data/lib/simple_form/version.rb +1 -1
  44. data/lib/simple_form/wrappers/builder.rb +6 -6
  45. data/lib/simple_form/wrappers/leaf.rb +28 -0
  46. data/lib/simple_form/wrappers/many.rb +6 -6
  47. data/lib/simple_form/wrappers/root.rb +1 -1
  48. data/lib/simple_form/wrappers/single.rb +5 -3
  49. data/lib/simple_form/wrappers.rb +1 -0
  50. data/lib/simple_form.rb +59 -8
  51. data/test/action_view_extensions/builder_test.rb +36 -36
  52. data/test/action_view_extensions/form_helper_test.rb +33 -14
  53. data/test/components/label_test.rb +37 -37
  54. data/test/form_builder/association_test.rb +52 -35
  55. data/test/form_builder/button_test.rb +10 -10
  56. data/test/form_builder/error_notification_test.rb +1 -1
  57. data/test/form_builder/error_test.rb +144 -24
  58. data/test/form_builder/general_test.rb +89 -64
  59. data/test/form_builder/hint_test.rb +18 -18
  60. data/test/form_builder/input_field_test.rb +80 -16
  61. data/test/form_builder/label_test.rb +45 -13
  62. data/test/form_builder/wrapper_test.rb +135 -19
  63. data/test/generators/simple_form_generator_test.rb +4 -4
  64. data/test/inputs/boolean_input_test.rb +62 -6
  65. data/test/inputs/collection_check_boxes_input_test.rb +85 -17
  66. data/test/inputs/collection_radio_buttons_input_test.rb +134 -36
  67. data/test/inputs/collection_select_input_test.rb +146 -41
  68. data/test/inputs/datetime_input_test.rb +117 -50
  69. data/test/inputs/disabled_test.rb +15 -15
  70. data/test/inputs/discovery_test.rb +56 -6
  71. data/test/inputs/file_input_test.rb +2 -2
  72. data/test/inputs/general_test.rb +20 -20
  73. data/test/inputs/grouped_collection_select_input_test.rb +44 -8
  74. data/test/inputs/hidden_input_test.rb +4 -4
  75. data/test/inputs/numeric_input_test.rb +43 -43
  76. data/test/inputs/priority_input_test.rb +13 -13
  77. data/test/inputs/readonly_test.rb +19 -19
  78. data/test/inputs/required_test.rb +13 -13
  79. data/test/inputs/string_input_test.rb +50 -30
  80. data/test/inputs/text_input_test.rb +7 -7
  81. data/test/simple_form_test.rb +8 -0
  82. data/test/support/discovery_inputs.rb +32 -2
  83. data/test/support/misc_helpers.rb +77 -5
  84. data/test/support/models.rb +60 -24
  85. data/test/test_helper.rb +5 -1
  86. metadata +4 -3
@@ -8,13 +8,13 @@ class BuilderTest < ActionView::TestCase
8
8
  end
9
9
  end
10
10
 
11
- def with_collection_radio_buttons(object, attribute, collection, value_method, text_method, options={}, html_options={}, &block)
11
+ def with_collection_radio_buttons(object, attribute, collection, value_method, text_method, options = {}, html_options = {}, &block)
12
12
  with_concat_form_for(object) do |f|
13
13
  f.collection_radio_buttons attribute, collection, value_method, text_method, options, html_options, &block
14
14
  end
15
15
  end
16
16
 
17
- def with_collection_check_boxes(object, attribute, collection, value_method, text_method, options={}, html_options={}, &block)
17
+ def with_collection_check_boxes(object, attribute, collection, value_method, text_method, options = {}, html_options = {}, &block)
18
18
  with_concat_form_for(object) do |f|
19
19
  f.collection_check_boxes attribute, collection, value_method, text_method, options, html_options, &block
20
20
  end
@@ -42,7 +42,7 @@ class BuilderTest < ActionView::TestCase
42
42
  assert_select 'form label.collection_radio_buttons[for=user_active_no]', 'No'
43
43
  end
44
44
 
45
- test "collection radio should sanitize collection values for labels correctly" do
45
+ test "collection radio sanitizes collection values for labels correctly" do
46
46
  with_collection_radio_buttons @user, :name, ['$0.99', '$1.99'], :to_s, :to_s
47
47
  assert_select 'label.collection_radio_buttons[for=user_name_099]', '$0.99'
48
48
  assert_select 'label.collection_radio_buttons[for=user_name_199]', '$1.99'
@@ -263,15 +263,15 @@ class BuilderTest < ActionView::TestCase
263
263
  collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
264
264
  with_collection_check_boxes @user, :tag_ids, collection, :id, :name
265
265
 
266
- assert_select 'form input#user_tag_ids_1[type=checkbox][value=1]'
267
- assert_select 'form input#user_tag_ids_2[type=checkbox][value=2]'
266
+ assert_select 'form input#user_tag_ids_1[type=checkbox][value="1"]'
267
+ assert_select 'form input#user_tag_ids_2[type=checkbox][value="2"]'
268
268
  end
269
269
 
270
270
  test "collection check box generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection" do
271
271
  collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
272
272
  with_collection_check_boxes @user, :tag_ids, collection, :id, :name
273
273
 
274
- assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]", count: 1
274
+ assert_select "form input[type=hidden][name='user[tag_ids][]'][value='']", count: 1
275
275
  end
276
276
 
277
277
  test "collection check box accepts a collection and generate a serie of checkboxes with labels for label method" do
@@ -289,7 +289,7 @@ class BuilderTest < ActionView::TestCase
289
289
  assert_select 'form label.collection_check_boxes[for=user_active_no]', 'No'
290
290
  end
291
291
 
292
- test "collection check box should sanitize collection values for labels correctly" do
292
+ test "collection check box sanitizes collection values for labels correctly" do
293
293
  with_collection_check_boxes @user, :name, ['$0.99', '$1.99'], :to_s, :to_s
294
294
  assert_select 'label.collection_check_boxes[for=user_name_099]', '$0.99'
295
295
  assert_select 'label.collection_check_boxes[for=user_name_199]', '$1.99'
@@ -301,36 +301,36 @@ class BuilderTest < ActionView::TestCase
301
301
 
302
302
  with_collection_check_boxes user, :tag_ids, collection, :first, :last
303
303
 
304
- assert_select 'form input[type=checkbox][value=1][checked=checked]'
305
- assert_select 'form input[type=checkbox][value=3][checked=checked]'
306
- assert_no_select 'form input[type=checkbox][value=2][checked=checked]'
304
+ assert_select 'form input[type=checkbox][value="1"][checked=checked]'
305
+ assert_select 'form input[type=checkbox][value="3"][checked=checked]'
306
+ assert_no_select 'form input[type=checkbox][value="2"][checked=checked]'
307
307
  end
308
308
 
309
309
  test "collection check box accepts selected values as :checked option" do
310
310
  collection = (1..3).map { |i| [i, "Tag #{i}"] }
311
311
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: [1, 3]
312
312
 
313
- assert_select 'form input[type=checkbox][value=1][checked=checked]'
314
- assert_select 'form input[type=checkbox][value=3][checked=checked]'
315
- assert_no_select 'form input[type=checkbox][value=2][checked=checked]'
313
+ assert_select 'form input[type=checkbox][value="1"][checked=checked]'
314
+ assert_select 'form input[type=checkbox][value="3"][checked=checked]'
315
+ assert_no_select 'form input[type=checkbox][value="2"][checked=checked]'
316
316
  end
317
317
 
318
318
  test "collection check boxes accepts selected string values as :checked option" do
319
319
  collection = (1..3).map { |i| [i, "Category #{i}"] }
320
320
  with_collection_check_boxes :user, :category_ids, collection, :first, :last, checked: ['1', '3']
321
321
 
322
- assert_select 'input[type=checkbox][value=1][checked=checked]'
323
- assert_select 'input[type=checkbox][value=3][checked=checked]'
324
- assert_no_select 'input[type=checkbox][value=2][checked=checked]'
322
+ assert_select 'input[type=checkbox][value="1"][checked=checked]'
323
+ assert_select 'input[type=checkbox][value="3"][checked=checked]'
324
+ assert_no_select 'input[type=checkbox][value="2"][checked=checked]'
325
325
  end
326
326
 
327
327
  test "collection check box accepts a single checked value" do
328
328
  collection = (1..3).map { |i| [i, "Tag #{i}"] }
329
329
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: 3
330
330
 
331
- assert_select 'form input[type=checkbox][value=3][checked=checked]'
332
- assert_no_select 'form input[type=checkbox][value=1][checked=checked]'
333
- assert_no_select 'form input[type=checkbox][value=2][checked=checked]'
331
+ assert_select 'form input[type=checkbox][value="3"][checked=checked]'
332
+ assert_no_select 'form input[type=checkbox][value="1"][checked=checked]'
333
+ assert_no_select 'form input[type=checkbox][value="2"][checked=checked]'
334
334
  end
335
335
 
336
336
  test "collection check box accepts selected values as :checked option and override the model values" do
@@ -338,44 +338,44 @@ class BuilderTest < ActionView::TestCase
338
338
  @user.tag_ids = [2]
339
339
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, checked: [1, 3]
340
340
 
341
- assert_select 'form input[type=checkbox][value=1][checked=checked]'
342
- assert_select 'form input[type=checkbox][value=3][checked=checked]'
343
- assert_no_select 'form input[type=checkbox][value=2][checked=checked]'
341
+ assert_select 'form input[type=checkbox][value="1"][checked=checked]'
342
+ assert_select 'form input[type=checkbox][value="3"][checked=checked]'
343
+ assert_no_select 'form input[type=checkbox][value="2"][checked=checked]'
344
344
  end
345
345
 
346
346
  test "collection check box accepts multiple disabled items" do
347
347
  collection = (1..3).map { |i| [i, "Tag #{i}"] }
348
348
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: [1, 3]
349
349
 
350
- assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
351
- assert_select 'form input[type=checkbox][value=3][disabled=disabled]'
352
- assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]'
350
+ assert_select 'form input[type=checkbox][value="1"][disabled=disabled]'
351
+ assert_select 'form input[type=checkbox][value="3"][disabled=disabled]'
352
+ assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]'
353
353
  end
354
354
 
355
355
  test "collection check box accepts single disable item" do
356
356
  collection = (1..3).map { |i| [i, "Tag #{i}"] }
357
357
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: 1
358
358
 
359
- assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
360
- assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]'
361
- assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]'
359
+ assert_select 'form input[type=checkbox][value="1"][disabled=disabled]'
360
+ assert_no_select 'form input[type=checkbox][value="3"][disabled=disabled]'
361
+ assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]'
362
362
  end
363
363
 
364
364
  test "collection check box accepts a proc to disabled items" do
365
365
  collection = (1..3).map { |i| [i, "Tag #{i}"] }
366
366
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, disabled: proc { |i| i.first == 1 }
367
367
 
368
- assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
369
- assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]'
370
- assert_no_select 'form input[type=checkbox][value=2][disabled=disabled]'
368
+ assert_select 'form input[type=checkbox][value="1"][disabled=disabled]'
369
+ assert_no_select 'form input[type=checkbox][value="3"][disabled=disabled]'
370
+ assert_no_select 'form input[type=checkbox][value="2"][disabled=disabled]'
371
371
  end
372
372
 
373
373
  test "collection check box accepts html options" do
374
374
  collection = [[1, 'Tag 1'], [2, 'Tag 2']]
375
375
  with_collection_check_boxes @user, :tag_ids, collection, :first, :last, {}, class: 'check'
376
376
 
377
- assert_select 'form input.check[type=checkbox][value=1]'
378
- assert_select 'form input.check[type=checkbox][value=2]'
377
+ assert_select 'form input.check[type=checkbox][value="1"]'
378
+ assert_select 'form input.check[type=checkbox][value="2"]'
379
379
  end
380
380
 
381
381
  test "collection check box with fields for" do
@@ -386,8 +386,8 @@ class BuilderTest < ActionView::TestCase
386
386
  end
387
387
  end
388
388
 
389
- assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]'
390
- assert_select 'form input#user_post_tag_ids_2[type=checkbox][value=2]'
389
+ assert_select 'form input#user_post_tag_ids_1[type=checkbox][value="1"]'
390
+ assert_select 'form input#user_post_tag_ids_2[type=checkbox][value="2"]'
391
391
 
392
392
  assert_select 'form label.collection_check_boxes[for=user_post_tag_ids_1]', 'Tag 1'
393
393
  assert_select 'form label.collection_check_boxes[for=user_post_tag_ids_2]', 'Tag 2'
@@ -593,7 +593,7 @@ class BuilderTest < ActionView::TestCase
593
593
  end
594
594
  end
595
595
 
596
- test "fields inherites wrapper option from the parent form" do
596
+ test "fields inherits wrapper option from the parent form" do
597
597
  swap_wrapper :another do
598
598
  simple_form_for(:user, wrapper: :another) do |f|
599
599
  f.simple_fields_for(:company) do |company|
@@ -8,17 +8,36 @@ class FormHelperTest < ActionView::TestCase
8
8
  end
9
9
  end
10
10
 
11
- test 'SimpleForm should add default class to form' do
11
+ test 'SimpleForm adds default class to form' do
12
12
  with_concat_form_for(:user)
13
13
  assert_select 'form.simple_form'
14
14
  end
15
15
 
16
- test 'SimpleForm should use default browser validations by default' do
16
+ test 'SimpleForm allows overriding default form class' do
17
+ swap SimpleForm, default_form_class: "my_custom_class" do
18
+ with_concat_form_for :user, html: { class: "override_class" }
19
+ assert_no_select 'form.my_custom_class'
20
+ assert_select 'form.override_class'
21
+ end
22
+ end
23
+
24
+ # Remove this test when SimpleForm.form_class is removed in 4.x
25
+ test 'SimpleForm allows overriding default form class, but not form class' do
26
+ ActiveSupport::Deprecation.silence do
27
+ swap SimpleForm, form_class: "fixed_class", default_form_class: "my_custom_class" do
28
+ with_concat_form_for :user, html: { class: "override_class" }
29
+ assert_no_select 'form.my_custom_class'
30
+ assert_select 'form.fixed_class.override_class'
31
+ end
32
+ end
33
+ end
34
+
35
+ test 'SimpleForm uses default browser validations by default' do
17
36
  with_concat_form_for(:user)
18
37
  assert_no_select 'form[novalidate]'
19
38
  end
20
39
 
21
- test 'SimpleForm should not use default browser validations if specified in the configuration options' do
40
+ test 'SimpleForm does not use default browser validations if specified in the configuration options' do
22
41
  swap SimpleForm, browser_validations: false do
23
42
  with_concat_form_for(:user)
24
43
  assert_select 'form[novalidate="novalidate"]'
@@ -37,57 +56,57 @@ class FormHelperTest < ActionView::TestCase
37
56
  end
38
57
  end
39
58
 
40
- test 'SimpleForm should add object name as css class to form when object is not present' do
59
+ test 'SimpleForm adds object name as css class to form when object is not present' do
41
60
  with_concat_form_for(:user, html: { novalidate: true })
42
61
  assert_select 'form.simple_form.user'
43
62
  end
44
63
 
45
- test 'SimpleForm should add :as option as css class to form when object is not present' do
64
+ test 'SimpleForm adds :as option as css class to form when object is not present' do
46
65
  with_concat_form_for(:user, as: 'superuser')
47
66
  assert_select 'form.simple_form.superuser'
48
67
  end
49
68
 
50
- test 'SimpleForm should add object class name with new prefix as css class to form if record is not persisted' do
69
+ test 'SimpleForm adds object class name with new prefix as css class to form if record is not persisted' do
51
70
  @user.new_record!
52
71
  with_concat_form_for(@user)
53
72
  assert_select 'form.simple_form.new_user'
54
73
  end
55
74
 
56
- test 'SimpleForm should add :as option with new prefix as css class to form if record is not persisted' do
75
+ test 'SimpleForm adds :as option with new prefix as css class to form if record is not persisted' do
57
76
  @user.new_record!
58
77
  with_concat_form_for(@user, as: 'superuser')
59
78
  assert_select 'form.simple_form.new_superuser'
60
79
  end
61
80
 
62
- test 'SimpleForm should add edit class prefix as css class to form if record is persisted' do
81
+ test 'SimpleForm adds edit class prefix as css class to form if record is persisted' do
63
82
  with_concat_form_for(@user)
64
83
  assert_select 'form.simple_form.edit_user'
65
84
  end
66
85
 
67
- test 'SimpleForm should add :as options with edit prefix as css class to form if record is persisted' do
86
+ test 'SimpleForm adds :as options with edit prefix as css class to form if record is persisted' do
68
87
  with_concat_form_for(@user, as: 'superuser')
69
88
  assert_select 'form.simple_form.edit_superuser'
70
89
  end
71
90
 
72
- test 'SimpleForm should add last object name as css class to form when there is array of objects' do
91
+ test 'SimpleForm adds last object name as css class to form when there is array of objects' do
73
92
  with_concat_form_for([Company.new, @user])
74
93
  assert_select 'form.simple_form.edit_user'
75
94
  end
76
95
 
77
- test 'SimpleForm should not add object class to form if css_class is specified' do
96
+ test 'SimpleForm does not add object class to form if css_class is specified' do
78
97
  with_concat_form_for(:user, html: { class: nil })
79
98
  assert_no_select 'form.user'
80
99
  end
81
100
 
82
- test 'SimpleForm should add custom class to form if css_class is specified' do
101
+ test 'SimpleForm adds custom class to form if css_class is specified' do
83
102
  with_concat_form_for(:user, html: { class: 'my_class' })
84
103
  assert_select 'form.my_class'
85
104
  end
86
105
 
87
- test 'pass options to SimpleForm' do
106
+ test 'passes options to SimpleForm' do
88
107
  with_concat_form_for(:user, url: '/account', html: { id: 'my_form' })
89
108
  assert_select 'form#my_form'
90
- assert_select 'form[action=/account]'
109
+ assert_select 'form[action="/account"]'
91
110
  end
92
111
 
93
112
  test 'form_for yields an instance of FormBuilder' do
@@ -7,34 +7,34 @@ class IsolatedLabelTest < ActionView::TestCase
7
7
  SimpleForm::Inputs::Base.reset_i18n_cache :translate_required_html
8
8
  end
9
9
 
10
- def with_label_for(object, attribute_name, type, options={})
10
+ def with_label_for(object, attribute_name, type, options = {})
11
11
  with_concat_form_for(object) do |f|
12
12
  options[:reflection] = Association.new(Company, :company, {}) if options.delete(:setup_association)
13
13
  SimpleForm::Inputs::Base.new(f, attribute_name, nil, type, options).label
14
14
  end
15
15
  end
16
16
 
17
- test 'label should generate a default humanized description' do
17
+ test 'label generates a default humanized description' do
18
18
  with_label_for @user, :name, :string
19
19
  assert_select 'label[for=user_name]', /Name/
20
20
  end
21
21
 
22
- test 'label should allow a customized description' do
22
+ test 'label allows a customized description' do
23
23
  with_label_for @user, :name, :string, label: 'My label!'
24
24
  assert_select 'label[for=user_name]', /My label!/
25
25
  end
26
26
 
27
- test 'label should use human attribute name from object when available' do
27
+ test 'label uses human attribute name from object when available' do
28
28
  with_label_for @user, :description, :text
29
29
  assert_select 'label[for=user_description]', /User Description!/
30
30
  end
31
31
 
32
- test 'label should use human attribute name based on association name' do
32
+ test 'label uses human attribute name based on association name' do
33
33
  with_label_for @user, :company_id, :string, setup_association: true
34
34
  assert_select 'label', /Company Human Name!/
35
35
  end
36
36
 
37
- test 'label should use i18n based on model, action, and attribute to lookup translation' do
37
+ test 'label uses i18n based on model, action, and attribute to lookup translation' do
38
38
  @controller.action_name = "new"
39
39
  store_translations(:en, simple_form: { labels: { user: {
40
40
  new: { description: 'Nova descrição' }
@@ -44,7 +44,7 @@ class IsolatedLabelTest < ActionView::TestCase
44
44
  end
45
45
  end
46
46
 
47
- test 'label should fallback to new when action is create' do
47
+ test 'label fallbacks to new when action is create' do
48
48
  @controller.action_name = "create"
49
49
  store_translations(:en, simple_form: { labels: { user: {
50
50
  new: { description: 'Nova descrição' }
@@ -54,7 +54,7 @@ class IsolatedLabelTest < ActionView::TestCase
54
54
  end
55
55
  end
56
56
 
57
- test 'label should not explode while looking for i18n translation when action is not set' do
57
+ test 'label does not explode while looking for i18n translation when action is not set' do
58
58
  def @controller.action_name; nil; end
59
59
 
60
60
  assert_nothing_raised do
@@ -63,7 +63,7 @@ class IsolatedLabelTest < ActionView::TestCase
63
63
  assert_select 'label[for=user_description]'
64
64
  end
65
65
 
66
- test 'label should use i18n based on model and attribute to lookup translation' do
66
+ test 'label uses i18n based on model and attribute to lookup translation' do
67
67
  store_translations(:en, simple_form: { labels: { user: {
68
68
  description: 'Descrição'
69
69
  } } }) do
@@ -72,14 +72,14 @@ class IsolatedLabelTest < ActionView::TestCase
72
72
  end
73
73
  end
74
74
 
75
- test 'label should use i18n under defaults to lookup translation' do
75
+ test 'label uses i18n under defaults to lookup translation' do
76
76
  store_translations(:en, simple_form: { labels: { defaults: { age: 'Idade' } } }) do
77
77
  with_label_for @user, :age, :integer
78
78
  assert_select 'label[for=user_age]', /Idade/
79
79
  end
80
80
  end
81
81
 
82
- test 'label should not use i18n label if translate is false' do
82
+ test 'label does not use i18n label if translate is false' do
83
83
  swap SimpleForm, translate_labels: false do
84
84
  store_translations(:en, simple_form: { labels: { defaults: { age: 'Idade' } } }) do
85
85
  with_label_for @user, :age, :integer
@@ -107,7 +107,7 @@ class IsolatedLabelTest < ActionView::TestCase
107
107
  end
108
108
  end
109
109
 
110
- test 'label should do correct i18n lookup for nested models with nested translation' do
110
+ test 'label does correct i18n lookup for nested models with nested translation' do
111
111
  @user.company = Company.new(1, 'Empresa')
112
112
 
113
113
  store_translations(:en, simple_form: { labels: {
@@ -125,7 +125,7 @@ class IsolatedLabelTest < ActionView::TestCase
125
125
  end
126
126
  end
127
127
 
128
- test 'label should do correct i18n lookup for nested models with no nested translation' do
128
+ test 'label does correct i18n lookup for nested models with no nested translation' do
129
129
  @user.company = Company.new(1, 'Empresa')
130
130
 
131
131
  store_translations(:en, simple_form: { labels: {
@@ -144,7 +144,7 @@ class IsolatedLabelTest < ActionView::TestCase
144
144
  end
145
145
  end
146
146
 
147
- test 'label should do correct i18n lookup for nested has_many models with no nested translation' do
147
+ test 'label does correct i18n lookup for nested has_many models with no nested translation' do
148
148
  @user.tags = [Tag.new(1, 'Empresa')]
149
149
 
150
150
  store_translations(:en, simple_form: { labels: {
@@ -163,7 +163,7 @@ class IsolatedLabelTest < ActionView::TestCase
163
163
  end
164
164
  end
165
165
 
166
- test 'label should have css class from type' do
166
+ test 'label has css class from type' do
167
167
  with_label_for @user, :name, :string
168
168
  assert_select 'label.string'
169
169
  with_label_for @user, :description, :text
@@ -176,7 +176,7 @@ class IsolatedLabelTest < ActionView::TestCase
176
176
  assert_select 'label.datetime'
177
177
  end
178
178
 
179
- test 'label should not have css class from type when generate_additional_classes_for does not include :label' do
179
+ test 'label does not have css class from type when generate_additional_classes_for does not include :label' do
180
180
  swap SimpleForm, generate_additional_classes_for: [:wrapper, :input] do
181
181
  with_label_for @user, :name, :string
182
182
  assert_no_select 'label.string'
@@ -191,21 +191,21 @@ class IsolatedLabelTest < ActionView::TestCase
191
191
  end
192
192
  end
193
193
 
194
- test 'label should not generate empty css class' do
194
+ test 'label does not generate empty css class' do
195
195
  swap SimpleForm, generate_additional_classes_for: [:wrapper, :input] do
196
196
  with_label_for @user, :name, :string
197
197
  assert_no_select 'label[class]'
198
198
  end
199
199
  end
200
200
 
201
- test 'label should obtain required from ActiveModel::Validations when it is included' do
201
+ test 'label obtains required from ActiveModel::Validations when it is included' do
202
202
  with_label_for @validating_user, :name, :string
203
203
  assert_select 'label.required'
204
204
  with_label_for @validating_user, :status, :string
205
205
  assert_select 'label.optional'
206
206
  end
207
207
 
208
- test 'label should not obtain required from ActiveModel::Validations when generate_additional_classes_for does not include :label' do
208
+ test 'label does not obtain required from ActiveModel::Validations when generate_additional_classes_for does not include :label' do
209
209
  swap SimpleForm, generate_additional_classes_for: [:wrapper, :input] do
210
210
  with_label_for @validating_user, :name, :string
211
211
  assert_no_select 'label.required'
@@ -214,48 +214,48 @@ class IsolatedLabelTest < ActionView::TestCase
214
214
  end
215
215
  end
216
216
 
217
- test 'label should allow overriding required when ActiveModel::Validations is included' do
217
+ test 'label allows overriding required when ActiveModel::Validations is included' do
218
218
  with_label_for @validating_user, :name, :string, required: false
219
219
  assert_select 'label.optional'
220
220
  with_label_for @validating_user, :status, :string, required: true
221
221
  assert_select 'label.required'
222
222
  end
223
223
 
224
- test 'label should be required by default when ActiveModel::Validations is not included' do
224
+ test 'label is required by default when ActiveModel::Validations is not included' do
225
225
  with_label_for @user, :name, :string
226
226
  assert_select 'label.required'
227
227
  end
228
228
 
229
- test 'label should be able to disable required when ActiveModel::Validations is not included' do
229
+ test 'label is able to disable required when ActiveModel::Validations is not included' do
230
230
  with_label_for @user, :name, :string, required: false
231
231
  assert_no_select 'label.required'
232
232
  end
233
233
 
234
- test 'label should add required text when required' do
234
+ test 'label adds required text when required' do
235
235
  with_label_for @user, :name, :string
236
236
  assert_select 'label.required abbr[title=required]', '*'
237
237
  end
238
238
 
239
- test 'label should not have required text in no required inputs' do
239
+ test 'label does not have required text in no required inputs' do
240
240
  with_label_for @user, :name, :string, required: false
241
241
  assert_no_select 'form label abbr'
242
242
  end
243
243
 
244
- test 'label should use i18n to find required text' do
244
+ test 'label uses i18n to find required text' do
245
245
  store_translations(:en, simple_form: { required: { text: 'campo requerido' } }) do
246
246
  with_label_for @user, :name, :string
247
- assert_select 'form label abbr[title=campo requerido]', '*'
247
+ assert_select 'form label abbr[title="campo requerido"]', '*'
248
248
  end
249
249
  end
250
250
 
251
- test 'label should use i18n to find required mark' do
251
+ test 'label uses i18n to find required mark' do
252
252
  store_translations(:en, simple_form: { required: { mark: '*-*' } }) do
253
253
  with_label_for @user, :name, :string
254
254
  assert_select 'form label abbr', '*-*'
255
255
  end
256
256
  end
257
257
 
258
- test 'label should use i18n to find required string tag' do
258
+ test 'label uses i18n to find required string tag' do
259
259
  store_translations(:en, simple_form: { required: { html: '<span class="required" title="requerido">*</span>' } }) do
260
260
  with_label_for @user, :name, :string
261
261
  assert_no_select 'form label abbr'
@@ -263,37 +263,37 @@ class IsolatedLabelTest < ActionView::TestCase
263
263
  end
264
264
  end
265
265
 
266
- test 'label should allow overwriting input id' do
266
+ test 'label allows overwriting input id' do
267
267
  with_label_for @user, :name, :string, input_html: { id: 'my_new_id' }
268
268
  assert_select 'label[for=my_new_id]'
269
269
  end
270
270
 
271
- test 'label should allow overwriting of for attribute' do
271
+ test 'label allows overwriting of for attribute' do
272
272
  with_label_for @user, :name, :string, label_html: { for: 'my_new_id' }
273
273
  assert_select 'label[for=my_new_id]'
274
274
  end
275
275
 
276
- test 'label should allow overwriting of for attribute with input_html not containing id' do
276
+ test 'label allows overwriting of for attribute with input_html not containing id' do
277
277
  with_label_for @user, :name, :string, label_html: { for: 'my_new_id' }, input_html: { class: 'foo' }
278
278
  assert_select 'label[for=my_new_id]'
279
279
  end
280
280
 
281
- test 'label should use default input id when it was not overridden' do
281
+ test 'label uses default input id when it was not overridden' do
282
282
  with_label_for @user, :name, :string, input_html: { class: 'my_new_id' }
283
283
  assert_select 'label[for=user_name]'
284
284
  end
285
285
 
286
- test 'label should be generated properly when object is not present' do
286
+ test 'label is generated properly when object is not present' do
287
287
  with_label_for :project, :name, :string
288
288
  assert_select 'label[for=project_name]', /Name/
289
289
  end
290
290
 
291
- test 'label should include for attribute for select collection' do
291
+ test 'label includes for attribute for select collection' do
292
292
  with_label_for @user, :sex, :select, collection: [:male, :female]
293
293
  assert_select 'label[for=user_sex]'
294
294
  end
295
295
 
296
- test 'label should use i18n properly when object is not present' do
296
+ test 'label uses i18n properly when object is not present' do
297
297
  store_translations(:en, simple_form: { labels: {
298
298
  project: { name: 'Nome' }
299
299
  } }) do
@@ -302,14 +302,14 @@ class IsolatedLabelTest < ActionView::TestCase
302
302
  end
303
303
  end
304
304
 
305
- test 'label should add required by default when object is not present' do
305
+ test 'label adds required by default when object is not present' do
306
306
  with_label_for :project, :name, :string
307
307
  assert_select 'label.required[for=project_name]'
308
308
  with_label_for :project, :description, :string, required: false
309
309
  assert_no_select 'label.required[for=project_description]'
310
310
  end
311
311
 
312
- test 'label should add chosen label class' do
312
+ test 'label adds chosen label class' do
313
313
  swap SimpleForm, label_class: :my_custom_class do
314
314
  with_label_for @user, :name, :string
315
315
  assert_select 'label.my_custom_class'