simple_form 2.1.3 → 3.0.0.beta1

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.

Potentially problematic release.


This version of simple_form might be problematic. Click here for more details.

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