simple_form 2.1.0 → 3.0.0.rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +15 -32
  3. data/README.md +103 -71
  4. data/lib/generators/simple_form/install_generator.rb +3 -3
  5. data/lib/generators/simple_form/templates/README +1 -1
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +13 -13
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +14 -14
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +3 -3
  9. data/lib/simple_form/action_view_extensions/builder.rb +1 -319
  10. data/lib/simple_form/action_view_extensions/form_helper.rb +2 -9
  11. data/lib/simple_form/components/html5.rb +5 -2
  12. data/lib/simple_form/components/labels.rb +3 -3
  13. data/lib/simple_form/components/maxlength.rb +1 -8
  14. data/lib/simple_form/components/pattern.rb +2 -2
  15. data/lib/simple_form/components.rb +1 -1
  16. data/lib/simple_form/error_notification.rb +2 -2
  17. data/lib/simple_form/form_builder.rb +147 -49
  18. data/lib/simple_form/helpers.rb +1 -1
  19. data/lib/simple_form/inputs/base.rb +2 -6
  20. data/lib/simple_form/inputs/block_input.rb +1 -1
  21. data/lib/simple_form/inputs/boolean_input.rb +5 -4
  22. data/lib/simple_form/inputs/collection_input.rb +6 -6
  23. data/lib/simple_form/inputs/numeric_input.rb +0 -6
  24. data/lib/simple_form/inputs/password_input.rb +0 -1
  25. data/lib/simple_form/inputs/string_input.rb +0 -1
  26. data/lib/simple_form/railtie.rb +7 -0
  27. data/lib/simple_form/tags.rb +61 -0
  28. data/lib/simple_form/version.rb +1 -1
  29. data/lib/simple_form/wrappers/builder.rb +5 -29
  30. data/lib/simple_form/wrappers/many.rb +1 -1
  31. data/lib/simple_form/wrappers/root.rb +1 -1
  32. data/lib/simple_form/wrappers.rb +1 -1
  33. data/lib/simple_form.rb +39 -47
  34. data/test/action_view_extensions/builder_test.rb +75 -88
  35. data/test/action_view_extensions/form_helper_test.rb +25 -16
  36. data/test/components/label_test.rb +46 -46
  37. data/test/form_builder/association_test.rb +39 -29
  38. data/test/form_builder/button_test.rb +4 -4
  39. data/test/form_builder/error_notification_test.rb +8 -8
  40. data/test/form_builder/error_test.rb +12 -12
  41. data/test/form_builder/general_test.rb +58 -52
  42. data/test/form_builder/hint_test.rb +22 -22
  43. data/test/form_builder/input_field_test.rb +12 -12
  44. data/test/form_builder/label_test.rb +6 -6
  45. data/test/form_builder/wrapper_test.rb +21 -21
  46. data/test/inputs/boolean_input_test.rb +23 -23
  47. data/test/inputs/collection_check_boxes_input_test.rb +61 -55
  48. data/test/inputs/collection_radio_buttons_input_test.rb +76 -79
  49. data/test/inputs/collection_select_input_test.rb +70 -45
  50. data/test/inputs/datetime_input_test.rb +17 -11
  51. data/test/inputs/disabled_test.rb +10 -10
  52. data/test/inputs/discovery_test.rb +4 -4
  53. data/test/inputs/file_input_test.rb +1 -1
  54. data/test/inputs/general_test.rb +12 -12
  55. data/test/inputs/grouped_collection_select_input_test.rb +20 -20
  56. data/test/inputs/hidden_input_test.rb +3 -2
  57. data/test/inputs/numeric_input_test.rb +3 -3
  58. data/test/inputs/priority_input_test.rb +9 -3
  59. data/test/inputs/readonly_test.rb +12 -12
  60. data/test/inputs/required_test.rb +5 -5
  61. data/test/inputs/string_input_test.rb +15 -25
  62. data/test/inputs/text_input_test.rb +1 -1
  63. data/test/support/misc_helpers.rb +46 -24
  64. data/test/support/mock_controller.rb +6 -6
  65. data/test/support/models.rb +62 -61
  66. data/test/test_helper.rb +20 -24
  67. metadata +32 -33
  68. data/lib/simple_form/action_view_extensions/builder.rb.orig +0 -247
  69. data/lib/simple_form/core_ext/hash.rb +0 -16
  70. data/lib/simple_form/form_builder.rb.orig +0 -486
  71. data/lib/simple_form/version.rb.orig +0 -7
@@ -14,7 +14,7 @@ class LabelTest < ActionView::TestCase
14
14
  end
15
15
 
16
16
  test 'builder should generate a label for the boolean attrbiute' do
17
- with_label_for @user, :name, :as => :boolean
17
+ with_label_for @user, :name, as: :boolean
18
18
  assert_select 'label.boolean[for=user_name]', /Name/
19
19
  assert_no_select 'label[as=boolean]'
20
20
  end
@@ -30,22 +30,22 @@ class LabelTest < ActionView::TestCase
30
30
  end
31
31
 
32
32
  test 'builder should allow passing options to label tag' do
33
- with_label_for @user, :name, :label => 'My label', :id => 'name_label'
33
+ with_label_for @user, :name, label: 'My label', id: 'name_label'
34
34
  assert_select 'label.string#name_label', /My label/
35
35
  end
36
36
 
37
37
  test 'builder label should generate label tag with clean HTML' do
38
- with_label_for @user, :name, :label => 'My label', :required => true, :id => 'name_label'
38
+ with_label_for @user, :name, label: 'My label', required: true, id: 'name_label'
39
39
  assert_select 'label.string#name_label', /My label/
40
40
  assert_no_select 'label[label]'
41
41
  assert_no_select 'label[required]'
42
42
  end
43
43
 
44
44
  test 'builder should not modify the options hash' do
45
- options = { :label => 'My label', :id => 'name_label' }
45
+ options = { label: 'My label', id: 'name_label' }
46
46
  with_label_for @user, :name, options
47
47
  assert_select 'label.string#name_label', /My label/
48
- assert_equal({ :label => 'My label', :id => 'name_label' }, options)
48
+ assert_equal({ label: 'My label', id: 'name_label' }, options)
49
49
  end
50
50
 
51
51
  test 'builder should fallback to default label when string is given' do
@@ -63,7 +63,7 @@ class LabelTest < ActionView::TestCase
63
63
  end
64
64
 
65
65
  test 'builder allows label order to be changed' do
66
- swap SimpleForm, :label_text => lambda { |l, r| "#{l}:" } do
66
+ swap SimpleForm, label_text: lambda { |l, r| "#{l}:" } do
67
67
  with_label_for @user, :age
68
68
  assert_select 'label.integer[for=user_age]', "Age:"
69
69
  end
@@ -38,7 +38,7 @@ class WrapperTest < ActionView::TestCase
38
38
  end
39
39
 
40
40
  test 'wrapper should add hint class for attribute with a hint' do
41
- with_form_for @user, :name, :hint => 'hint'
41
+ with_form_for @user, :name, hint: 'hint'
42
42
  assert_select 'div.field_with_hint'
43
43
  end
44
44
 
@@ -48,18 +48,18 @@ class WrapperTest < ActionView::TestCase
48
48
  end
49
49
 
50
50
  test 'wrapper should have disabled class when input is disabled' do
51
- with_form_for @user, :active, :disabled => true
51
+ with_form_for @user, :active, disabled: true
52
52
  assert_select 'div.disabled'
53
53
  end
54
54
 
55
55
  test 'wrapper should support no wrapping when wrapper is false' do
56
- with_form_for @user, :name, :wrapper => false
56
+ with_form_for @user, :name, wrapper: false
57
57
  assert_select 'form > label[for=user_name]'
58
58
  assert_select 'form > input#user_name.string'
59
59
  end
60
60
 
61
61
  test 'wrapper should support no wrapping when wrapper tag is false' do
62
- with_form_for @user, :name, :wrapper => custom_wrapper_without_top_level
62
+ with_form_for @user, :name, wrapper: custom_wrapper_without_top_level
63
63
  assert_select 'form > label[for=user_name]'
64
64
  assert_select 'form > input#user_name.string'
65
65
  end
@@ -68,28 +68,28 @@ class WrapperTest < ActionView::TestCase
68
68
  with_form_for @user, :name
69
69
  assert_select 'form div.input.required.string'
70
70
 
71
- with_form_for @user, :age, :required => false
71
+ with_form_for @user, :age, required: false
72
72
  assert_select 'form div.input.optional.integer'
73
73
  end
74
74
 
75
75
  test 'wrapper should allow custom options to be given' do
76
- with_form_for @user, :name, :wrapper_html => { :id => "super_cool", :class => 'yay' }
76
+ with_form_for @user, :name, wrapper_html: { id: "super_cool", class: 'yay' }
77
77
  assert_select 'form #super_cool.required.string.yay'
78
78
  end
79
79
 
80
80
  test 'wrapper should allow tag to be given on demand' do
81
- with_form_for @user, :name, :wrapper_tag => :b
81
+ with_form_for @user, :name, wrapper_tag: :b
82
82
  assert_select 'form b.required.string'
83
83
  end
84
84
 
85
85
  test 'wrapper should allow wrapper class to be given on demand' do
86
- with_form_for @user, :name, :wrapper_class => :wrapper
86
+ with_form_for @user, :name, wrapper_class: :wrapper
87
87
  assert_select 'form div.wrapper.required.string'
88
88
  end
89
89
 
90
90
  test 'wrapper should skip additional classes when configured' do
91
- swap SimpleForm, :generate_additional_classes_for => [:input, :label] do
92
- with_form_for @user, :name, :wrapper_class => :wrapper
91
+ swap SimpleForm, generate_additional_classes_for: [:input, :label] do
92
+ with_form_for @user, :name, wrapper_class: :wrapper
93
93
  assert_select 'form div.wrapper'
94
94
  assert_no_select 'div.required'
95
95
  assert_no_select 'div.string'
@@ -98,7 +98,7 @@ class WrapperTest < ActionView::TestCase
98
98
  end
99
99
 
100
100
  test 'wrapper should not generate empty css class' do
101
- swap SimpleForm, :generate_additional_classes_for => [:input, :label] do
101
+ swap SimpleForm, generate_additional_classes_for: [:input, :label] do
102
102
  swap_wrapper :default, custom_wrapper_without_class do
103
103
  with_form_for @user, :name
104
104
  assert_no_select 'div#custom_wrapper_without_class[class]'
@@ -110,7 +110,7 @@ class WrapperTest < ActionView::TestCase
110
110
 
111
111
  test 'custom wrappers works' do
112
112
  swap_wrapper do
113
- with_form_for @user, :name, :hint => "cool"
113
+ with_form_for @user, :name, hint: "cool"
114
114
  assert_select "section.custom_wrapper div.another_wrapper label"
115
115
  assert_select "section.custom_wrapper div.another_wrapper input.string"
116
116
  assert_no_select "section.custom_wrapper div.another_wrapper span.omg_error"
@@ -121,7 +121,7 @@ class WrapperTest < ActionView::TestCase
121
121
 
122
122
  test 'custom wrappers can be turned off' do
123
123
  swap_wrapper do
124
- with_form_for @user, :name, :another => false
124
+ with_form_for @user, :name, another: false
125
125
  assert_no_select "section.custom_wrapper div.another_wrapper label"
126
126
  assert_no_select "section.custom_wrapper div.another_wrapper input.string"
127
127
  assert_select "section.custom_wrapper div.error_wrapper span.omg_error"
@@ -137,7 +137,7 @@ class WrapperTest < ActionView::TestCase
137
137
  assert_no_select "section.custom_wrapper div.another_wrapper label"
138
138
  assert_no_select "section.custom_wrapper div.another_wrapper input.string"
139
139
 
140
- with_concat_form_for(@user, :wrapper => :another) do |f|
140
+ with_concat_form_for(@user, wrapper: :another) do |f|
141
141
  f.input :name
142
142
  end
143
143
 
@@ -153,20 +153,20 @@ class WrapperTest < ActionView::TestCase
153
153
  assert_no_select "section.custom_wrapper div.another_wrapper input.string"
154
154
  output_buffer.replace ""
155
155
 
156
- with_form_for @user, :name, :wrapper => :another
156
+ with_form_for @user, :name, wrapper: :another
157
157
  assert_select "section.custom_wrapper div.another_wrapper label"
158
158
  assert_select "section.custom_wrapper div.another_wrapper input.string"
159
159
  output_buffer.replace ""
160
160
  end
161
161
 
162
- with_form_for @user, :name, :wrapper => custom_wrapper
162
+ with_form_for @user, :name, wrapper: custom_wrapper
163
163
  assert_select "section.custom_wrapper div.another_wrapper label"
164
164
  assert_select "section.custom_wrapper div.another_wrapper input.string"
165
165
  end
166
166
 
167
167
  test 'access wrappers with indifferent access' do
168
168
  swap_wrapper :another do
169
- with_form_for @user, :name, :wrapper => "another"
169
+ with_form_for @user, :name, wrapper: "another"
170
170
  assert_select "section.custom_wrapper div.another_wrapper label"
171
171
  assert_select "section.custom_wrapper div.another_wrapper input.string"
172
172
  end
@@ -175,8 +175,8 @@ class WrapperTest < ActionView::TestCase
175
175
  test 'do not duplicate label classes for different inputs' do
176
176
  swap_wrapper :default, self.custom_wrapper_with_label_html_option do
177
177
  with_concat_form_for(@user) do |f|
178
- concat f.input :name, :required => false
179
- concat f.input :email, :as => :email, :required => true
178
+ concat f.input :name, required: false
179
+ concat f.input :email, as: :email, required: true
180
180
  end
181
181
 
182
182
  assert_select "label.string.optional.extra-label-class[for='user_name']"
@@ -187,13 +187,13 @@ class WrapperTest < ActionView::TestCase
187
187
 
188
188
  test 'raise error when wrapper not found' do
189
189
  assert_raise SimpleForm::WrapperNotFound do
190
- with_form_for @user, :name, :wrapper => :not_found
190
+ with_form_for @user, :name, wrapper: :not_found
191
191
  end
192
192
  end
193
193
 
194
194
  test 'use wrapper for specified in config mapping' do
195
195
  swap_wrapper :another do
196
- swap SimpleForm, :wrapper_mappings => { :string => :another } do
196
+ swap SimpleForm, wrapper_mappings: { string: :another } do
197
197
  with_form_for @user, :name
198
198
  assert_select "section.custom_wrapper div.another_wrapper label"
199
199
  assert_select "section.custom_wrapper div.another_wrapper input.string"
@@ -9,26 +9,26 @@ class BooleanInputTest < ActionView::TestCase
9
9
  end
10
10
 
11
11
  test 'input does not generate the label with the checkbox when label option is false' do
12
- with_input_for @user, :active, :boolean, :label => false
12
+ with_input_for @user, :active, :boolean, label: false
13
13
  assert_select 'input[type=checkbox].boolean#user_active'
14
14
  assert_no_select 'label'
15
15
  end
16
16
 
17
17
  test 'input uses custom checked value' do
18
18
  @user.action = 'on'
19
- with_input_for @user, :action, :boolean, :checked_value => 'on', :unchecked_value => 'off'
19
+ with_input_for @user, :action, :boolean, checked_value: 'on', unchecked_value: 'off'
20
20
  assert_select 'input[type=checkbox][value=on][checked=checked]'
21
21
  end
22
22
 
23
23
  test 'input uses custom unchecked value' do
24
24
  @user.action = 'off'
25
- with_input_for @user, :action, :boolean, :checked_value => 'on', :unchecked_value => 'off'
25
+ with_input_for @user, :action, :boolean, checked_value: 'on', unchecked_value: 'off'
26
26
  assert_select 'input[type=checkbox][value=on]'
27
27
  assert_no_select 'input[checked=checked][value=on]'
28
28
  end
29
29
 
30
30
  test 'input generates hidden input with custom unchecked value' do
31
- with_input_for @user, :action, :boolean, :checked_value => 'on', :unchecked_value => 'off'
31
+ with_input_for @user, :action, :boolean, checked_value: 'on', unchecked_value: 'off'
32
32
  assert_select 'input[type=hidden][value=off]'
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ class BooleanInputTest < ActionView::TestCase
39
39
  end
40
40
 
41
41
  test 'input allows changing default boolean style config to nested, generating a default label and a manual hidden field for checkbox' do
42
- swap SimpleForm, :boolean_style => :nested do
42
+ swap SimpleForm, boolean_style: :nested do
43
43
  with_input_for @user, :active, :boolean
44
44
  assert_select 'label[for=user_active]', 'Active'
45
45
  assert_select 'label.boolean > input.boolean'
@@ -48,21 +48,21 @@ class BooleanInputTest < ActionView::TestCase
48
48
  end
49
49
 
50
50
  test 'input boolean with nested allows :inline_label' do
51
- swap SimpleForm, :boolean_style => :nested do
52
- with_input_for @user, :active, :boolean, :label => false, :inline_label => 'I am so inline.'
53
- assert_select 'label.checkbox', :text => 'I am so inline.'
51
+ swap SimpleForm, boolean_style: :nested do
52
+ with_input_for @user, :active, :boolean, label: false, inline_label: 'I am so inline.'
53
+ assert_select 'label.checkbox', text: 'I am so inline.'
54
54
  end
55
55
  end
56
56
 
57
57
  test 'input boolean with nested style creates an inline label using the default label text when inline_label option set to true' do
58
- swap SimpleForm, :boolean_style => :nested do
59
- with_input_for @user, :active, :boolean, :label => false, :inline_label => true
60
- assert_select 'label.checkbox', :text => 'Active'
58
+ swap SimpleForm, boolean_style: :nested do
59
+ with_input_for @user, :active, :boolean, label: false, inline_label: true
60
+ assert_select 'label.checkbox', text: 'Active'
61
61
  end
62
62
  end
63
63
 
64
64
  test 'input boolean with nested generates a manual hidden field for checkbox outside the label, to recreate Rails functionality with valid html5' do
65
- swap SimpleForm, :boolean_style => :nested do
65
+ swap SimpleForm, boolean_style: :nested do
66
66
  with_input_for @user, :active, :boolean
67
67
 
68
68
  assert_select "input[type=hidden][name='user[active]'] + label.boolean > input.boolean"
@@ -71,23 +71,23 @@ class BooleanInputTest < ActionView::TestCase
71
71
  end
72
72
 
73
73
  test 'input boolean with nested generates a disabled hidden field for checkbox outside the label, if the field is disabled' do
74
- swap SimpleForm, :boolean_style => :nested do
75
- with_input_for @user, :active, :boolean, :disabled => true
74
+ swap SimpleForm, boolean_style: :nested do
75
+ with_input_for @user, :active, :boolean, disabled: true
76
76
 
77
77
  assert_select "input[type=hidden][name='user[active]'][disabled] + label.boolean > input.boolean[disabled]"
78
78
  end
79
79
  end
80
80
 
81
81
  test 'input accepts changing boolean style to nested through given options' do
82
- with_input_for @user, :active, :boolean, :boolean_style => :nested
82
+ with_input_for @user, :active, :boolean, boolean_style: :nested
83
83
  assert_select 'label[for=user_active]', 'Active'
84
84
  assert_select 'label.boolean > input.boolean'
85
85
  assert_no_select 'input[type=checkbox] + label'
86
86
  end
87
87
 
88
88
  test 'input accepts changing boolean style to inline through given options, when default is nested' do
89
- swap SimpleForm, :boolean_style => :nested do
90
- with_input_for @user, :active, :boolean, :boolean_style => :inline
89
+ swap SimpleForm, boolean_style: :nested do
90
+ with_input_for @user, :active, :boolean, boolean_style: :inline
91
91
  assert_select 'label[for=user_active]', 'Active'
92
92
  assert_select 'input.boolean + label.boolean'
93
93
  assert_no_select 'label > input'
@@ -95,16 +95,16 @@ class BooleanInputTest < ActionView::TestCase
95
95
  end
96
96
 
97
97
  test 'input with nested style allows disabling label' do
98
- swap SimpleForm, :boolean_style => :nested do
99
- with_input_for @user, :active, :boolean, :label => false
98
+ swap SimpleForm, boolean_style: :nested do
99
+ with_input_for @user, :active, :boolean, label: false
100
100
  assert_select 'input.boolean'
101
101
  assert_no_select 'label.boolean'
102
102
  end
103
103
  end
104
104
 
105
105
  test 'input with nested style allows customizing input_html' do
106
- swap SimpleForm, :boolean_style => :nested do
107
- with_input_for @user, :active, :boolean, :input_html => { :name => 'active_user' }
106
+ swap SimpleForm, boolean_style: :nested do
107
+ with_input_for @user, :active, :boolean, input_html: { name: 'active_user' }
108
108
  assert_select "input[type=hidden][name=active_user] + label.boolean > input.boolean[name=active_user]"
109
109
  end
110
110
  end
@@ -120,7 +120,7 @@ class BooleanInputTest < ActionView::TestCase
120
120
 
121
121
  test 'input boolean with nested style works using :input only in wrapper config (no label_input), adding the extra "checkbox" label wrapper' do
122
122
  swap_wrapper do
123
- swap SimpleForm, :boolean_style => :nested do
123
+ swap SimpleForm, boolean_style: :nested do
124
124
  with_input_for @user, :active, :boolean
125
125
 
126
126
  assert_select 'label.boolean + input[type=hidden] + label.checkbox > input.boolean'
@@ -130,7 +130,7 @@ class BooleanInputTest < ActionView::TestCase
130
130
 
131
131
  test 'input boolean with nested style works using :label_input in wrapper config, adding "checkbox" class to label' do
132
132
  swap_wrapper :default, self.custom_wrapper_without_top_level do
133
- swap SimpleForm, :boolean_style => :nested do
133
+ swap SimpleForm, boolean_style: :nested do
134
134
  with_input_for @user, :active, :boolean
135
135
 
136
136
  assert_select 'input[type=hidden] + label.boolean.checkbox > input.boolean'
@@ -7,27 +7,33 @@ 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
+ test 'collection input with check_boxes type should not generate aria-required html attribute' do
27
+ with_input_for @user, :name, :check_boxes, collection: ['Jose', 'Carlos']
28
+ assert_select 'input.required'
29
+ assert_no_select 'input[aria-required]'
30
+ end
31
+
26
32
  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'}
33
+ store_translations(:en, simple_form: { options: { defaults: {
34
+ gender: { male: 'Male', female: 'Female'}
29
35
  } } } ) do
30
- with_input_for @user, :gender, :check_boxes, :collection => [:male, :female]
36
+ with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
31
37
  assert_select 'input[type=checkbox][value=male]'
32
38
  assert_select 'input[type=checkbox][value=female]'
33
39
  assert_select 'label.collection_check_boxes', 'Male'
@@ -36,10 +42,10 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
36
42
  end
37
43
 
38
44
  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'}
45
+ store_translations(:en, simple_form: { options: { user: {
46
+ gender: { male: 'Male', female: 'Female'}
41
47
  } } } ) do
42
- with_input_for @user, :gender, :check_boxes, :collection => [:male, :female]
48
+ with_input_for @user, :gender, :check_boxes, collection: [:male, :female]
43
49
  assert_select 'input[type=checkbox][value=male]'
44
50
  assert_select 'input[type=checkbox][value=female]'
45
51
  assert_select 'label.collection_check_boxes', 'Male'
@@ -50,100 +56,100 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
50
56
  test 'input check boxes does not wrap the collection by default' do
51
57
  with_input_for @user, :active, :check_boxes
52
58
 
53
- assert_select 'form input[type=checkbox]', :count => 2
59
+ assert_select 'form input[type=checkbox]', count: 2
54
60
  assert_no_select 'form ul'
55
61
  end
56
62
 
57
63
  test 'input check boxes wraps the collection in the configured collection wrapper tag' do
58
- swap SimpleForm, :collection_wrapper_tag => :ul do
64
+ swap SimpleForm, collection_wrapper_tag: :ul do
59
65
  with_input_for @user, :active, :check_boxes
60
66
 
61
- assert_select 'form ul input[type=checkbox]', :count => 2
67
+ assert_select 'form ul input[type=checkbox]', count: 2
62
68
  end
63
69
  end
64
70
 
65
71
  test 'input check boxes does not wrap the collection when configured with falsy values' do
66
- swap SimpleForm, :collection_wrapper_tag => false do
72
+ swap SimpleForm, collection_wrapper_tag: false do
67
73
  with_input_for @user, :active, :check_boxes
68
74
 
69
- assert_select 'form input[type=checkbox]', :count => 2
75
+ assert_select 'form input[type=checkbox]', count: 2
70
76
  assert_no_select 'form ul'
71
77
  end
72
78
  end
73
79
 
74
80
  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
81
+ swap SimpleForm, collection_wrapper_tag: :ul do
82
+ with_input_for @user, :active, :check_boxes, collection_wrapper_tag: :section
77
83
 
78
- assert_select 'form section input[type=checkbox]', :count => 2
84
+ assert_select 'form section input[type=checkbox]', count: 2
79
85
  assert_no_select 'form ul'
80
86
  end
81
87
  end
82
88
 
83
89
  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
90
+ swap SimpleForm, collection_wrapper_tag: :ul do
91
+ with_input_for @user, :active, :check_boxes, collection_wrapper_tag: false
86
92
 
87
- assert_select 'form input[type=checkbox]', :count => 2
93
+ assert_select 'form input[type=checkbox]', count: 2
88
94
  assert_no_select 'form ul'
89
95
  end
90
96
  end
91
97
 
92
98
  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
99
+ swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
94
100
  with_input_for @user, :active, :check_boxes
95
101
 
96
- assert_select 'form ul.inputs-list input[type=checkbox]', :count => 2
102
+ assert_select 'form ul.inputs-list input[type=checkbox]', count: 2
97
103
  end
98
104
  end
99
105
 
100
106
  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'
107
+ swap SimpleForm, collection_wrapper_tag: :ul do
108
+ with_input_for @user, :active, :check_boxes, collection_wrapper_class: 'items-list'
103
109
 
104
- assert_select 'form ul.items-list input[type=checkbox]', :count => 2
110
+ assert_select 'form ul.items-list input[type=checkbox]', count: 2
105
111
  end
106
112
  end
107
113
 
108
114
  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'
115
+ swap SimpleForm, collection_wrapper_tag: :ul, collection_wrapper_class: 'inputs-list' do
116
+ with_input_for @user, :active, :check_boxes, collection_wrapper_class: 'items-list'
111
117
 
112
- assert_select 'form ul.inputs-list.items-list input[type=checkbox]', :count => 2
118
+ assert_select 'form ul.inputs-list.items-list input[type=checkbox]', count: 2
113
119
  end
114
120
  end
115
121
 
116
122
  test 'input check boxes wraps each item in the configured item wrapper tag' do
117
- swap SimpleForm, :item_wrapper_tag => :li do
123
+ swap SimpleForm, item_wrapper_tag: :li do
118
124
  with_input_for @user, :active, :check_boxes
119
125
 
120
- assert_select 'form li input[type=checkbox]', :count => 2
126
+ assert_select 'form li input[type=checkbox]', count: 2
121
127
  end
122
128
  end
123
129
 
124
130
  test 'input check boxes does not wrap items when configured with falsy values' do
125
- swap SimpleForm, :item_wrapper_tag => false do
131
+ swap SimpleForm, item_wrapper_tag: false do
126
132
  with_input_for @user, :active, :check_boxes
127
133
 
128
- assert_select 'form input[type=checkbox]', :count => 2
134
+ assert_select 'form input[type=checkbox]', count: 2
129
135
  assert_no_select 'form li'
130
136
  end
131
137
  end
132
138
 
133
139
  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
140
+ swap SimpleForm, item_wrapper_tag: :li do
141
+ with_input_for @user, :active, :check_boxes, item_wrapper_tag: :dl
136
142
 
137
- assert_select 'form dl input[type=checkbox]', :count => 2
143
+ assert_select 'form dl input[type=checkbox]', count: 2
138
144
  assert_no_select 'form li'
139
145
  end
140
146
  end
141
147
 
142
148
  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
149
+ swap SimpleForm, item_wrapper_tag: :ul do
150
+ with_input_for @user, :active, :check_boxes, item_wrapper_tag: false
145
151
 
146
- assert_select 'form input[type=checkbox]', :count => 2
152
+ assert_select 'form input[type=checkbox]', count: 2
147
153
  assert_no_select 'form li'
148
154
  end
149
155
  end
@@ -151,41 +157,41 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
151
157
  test 'input check boxes wraps items in a span tag by default' do
152
158
  with_input_for @user, :active, :check_boxes
153
159
 
154
- assert_select 'form span input[type=checkbox]', :count => 2
160
+ assert_select 'form span input[type=checkbox]', count: 2
155
161
  end
156
162
 
157
163
  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
164
+ with_input_for @user, :active, :check_boxes, item_wrapper_tag: :li
159
165
 
160
- assert_select 'form li.checkbox input[type=checkbox]', :count => 2
166
+ assert_select 'form li.checkbox input[type=checkbox]', count: 2
161
167
  end
162
168
 
163
169
  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
170
+ swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
165
171
  with_input_for @user, :active, :check_boxes
166
172
 
167
- assert_select 'form li.checkbox.item input[type=checkbox]', :count => 2
173
+ assert_select 'form li.checkbox.item input[type=checkbox]', count: 2
168
174
  end
169
175
  end
170
176
 
171
177
  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'
178
+ swap SimpleForm, item_wrapper_tag: :li do
179
+ with_input_for @user, :active, :check_boxes, item_wrapper_class: 'item'
174
180
 
175
- assert_select 'form li.checkbox.item input[type=checkbox]', :count => 2
181
+ assert_select 'form li.checkbox.item input[type=checkbox]', count: 2
176
182
  end
177
183
  end
178
184
 
179
185
  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'
186
+ swap SimpleForm, item_wrapper_tag: :li, item_wrapper_class: 'item' do
187
+ with_input_for @user, :active, :check_boxes, item_wrapper_class: 'inline'
182
188
 
183
- assert_select 'form li.checkbox.item.inline input[type=checkbox]', :count => 2
189
+ assert_select 'form li.checkbox.item.inline input[type=checkbox]', count: 2
184
190
  end
185
191
  end
186
192
 
187
193
  test 'input check boxes respects the nested boolean style config, generating nested label > input' do
188
- swap SimpleForm, :boolean_style => :nested do
194
+ swap SimpleForm, boolean_style: :nested do
189
195
  with_input_for @user, :active, :check_boxes
190
196
 
191
197
  assert_select 'label.checkbox > input#user_active_true[type=checkbox]'
@@ -197,7 +203,7 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
197
203
  end
198
204
 
199
205
  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
206
+ swap SimpleForm, boolean_style: :nested, item_wrapper_tag: :li do
201
207
  with_input_for @user, :active, :check_boxes
202
208
 
203
209
  assert_select 'label.checkbox > input'
@@ -206,8 +212,8 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
206
212
  end
207
213
 
208
214
  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
215
+ swap SimpleForm, boolean_style: :nested do
216
+ with_input_for @user, :active, :check_boxes, item_wrapper_tag: :li
211
217
 
212
218
  assert_select 'label.checkbox > input'
213
219
  assert_no_select 'li'
@@ -215,8 +221,8 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
215
221
  end
216
222
 
217
223
  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"
224
+ swap SimpleForm, boolean_style: :nested do
225
+ with_input_for @user, :active, :check_boxes, item_wrapper_class: "inline"
220
226
 
221
227
  assert_select 'label.checkbox.inline > input'
222
228
  end