simple_form 2.1.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -51
  3. data/README.md +195 -161
  4. data/lib/generators/simple_form/install_generator.rb +4 -4
  5. data/lib/generators/simple_form/templates/README +2 -2
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +16 -13
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +16 -16
  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 -320
  10. data/lib/simple_form/action_view_extensions/builder.rb.orig +247 -0
  11. data/lib/simple_form/action_view_extensions/form_helper.rb +2 -9
  12. data/lib/simple_form/components/errors.rb +1 -7
  13. data/lib/simple_form/components/hints.rb +2 -7
  14. data/lib/simple_form/components/html5.rb +5 -2
  15. data/lib/simple_form/components/labels.rb +4 -4
  16. data/lib/simple_form/components/maxlength.rb +1 -8
  17. data/lib/simple_form/components/pattern.rb +2 -2
  18. data/lib/simple_form/components.rb +1 -1
  19. data/lib/simple_form/error_notification.rb +2 -2
  20. data/lib/simple_form/form_builder.rb +154 -50
  21. data/lib/simple_form/form_builder.rb.orig +486 -0
  22. data/lib/simple_form/helpers.rb +1 -1
  23. data/lib/simple_form/inputs/base.rb +7 -10
  24. data/lib/simple_form/inputs/block_input.rb +1 -1
  25. data/lib/simple_form/inputs/boolean_input.rb +6 -5
  26. data/lib/simple_form/inputs/collection_input.rb +7 -7
  27. data/lib/simple_form/inputs/date_time_input.rb +1 -1
  28. data/lib/simple_form/inputs/numeric_input.rb +0 -6
  29. data/lib/simple_form/inputs/password_input.rb +0 -1
  30. data/lib/simple_form/inputs/string_input.rb +0 -1
  31. data/lib/simple_form/railtie.rb +7 -0
  32. data/lib/simple_form/tags.rb +62 -0
  33. data/lib/simple_form/version.rb +1 -1
  34. data/lib/simple_form/version.rb.orig +7 -0
  35. data/lib/simple_form/wrappers/builder.rb +5 -29
  36. data/lib/simple_form/wrappers/many.rb +1 -1
  37. data/lib/simple_form/wrappers/root.rb +1 -1
  38. data/lib/simple_form/wrappers.rb +1 -1
  39. data/lib/simple_form.rb +43 -47
  40. data/test/action_view_extensions/builder_test.rb +78 -99
  41. data/test/action_view_extensions/form_helper_test.rb +25 -16
  42. data/test/components/label_test.rb +46 -46
  43. data/test/form_builder/association_test.rb +47 -29
  44. data/test/form_builder/button_test.rb +4 -4
  45. data/test/form_builder/error_notification_test.rb +8 -8
  46. data/test/form_builder/error_test.rb +18 -65
  47. data/test/form_builder/general_test.rb +62 -63
  48. data/test/form_builder/hint_test.rb +23 -29
  49. data/test/form_builder/input_field_test.rb +29 -12
  50. data/test/form_builder/label_test.rb +7 -17
  51. data/test/form_builder/wrapper_test.rb +21 -21
  52. data/test/inputs/boolean_input_test.rb +24 -24
  53. data/test/inputs/collection_check_boxes_input_test.rb +66 -55
  54. data/test/inputs/collection_radio_buttons_input_test.rb +81 -79
  55. data/test/inputs/collection_select_input_test.rb +76 -51
  56. data/test/inputs/datetime_input_test.rb +17 -11
  57. data/test/inputs/disabled_test.rb +10 -10
  58. data/test/inputs/discovery_test.rb +4 -4
  59. data/test/inputs/file_input_test.rb +1 -1
  60. data/test/inputs/general_test.rb +28 -12
  61. data/test/inputs/grouped_collection_select_input_test.rb +33 -20
  62. data/test/inputs/hidden_input_test.rb +3 -2
  63. data/test/inputs/numeric_input_test.rb +3 -3
  64. data/test/inputs/priority_input_test.rb +9 -3
  65. data/test/inputs/readonly_test.rb +12 -12
  66. data/test/inputs/required_test.rb +5 -5
  67. data/test/inputs/string_input_test.rb +15 -25
  68. data/test/inputs/text_input_test.rb +1 -1
  69. data/test/support/misc_helpers.rb +46 -24
  70. data/test/support/mock_controller.rb +6 -6
  71. data/test/support/models.rb +77 -62
  72. data/test/test_helper.rb +17 -34
  73. metadata +39 -22
  74. data/lib/simple_form/core_ext/hash.rb +0 -16
@@ -14,36 +14,53 @@ class InputFieldTest < ActionView::TestCase
14
14
 
15
15
  test 'builder input_field should allow overriding default input type' do
16
16
  with_concat_form_for(@user) do |f|
17
- f.input_field :name, :as => :text
17
+ f.input_field :name, as: :text
18
18
  end
19
19
 
20
20
  assert_no_select 'input#user_name'
21
21
  assert_select 'textarea#user_name.text'
22
22
  end
23
23
 
24
+ test 'builder input_field should generate input type based on column type' do
25
+ with_concat_form_for(@user) do |f|
26
+ f.input_field :age
27
+ end
28
+
29
+ assert_select 'input[type=number].integer#user_age'
30
+ end
31
+
32
+ test 'builder input_field should be able to disable any component' do
33
+ with_concat_form_for(@user) do |f|
34
+ f.input_field :age, html5: false
35
+ end
36
+
37
+ assert_no_select 'input[html5=false]#user_age'
38
+ assert_select 'input[type=text].integer#user_age'
39
+ end
40
+
24
41
  test 'builder input_field should allow passing options to input tag' do
25
42
  with_concat_form_for(@user) do |f|
26
- f.input_field :name, :id => 'name_input', :class => 'name'
43
+ f.input_field :name, id: 'name_input', class: 'name'
27
44
  end
28
45
 
29
46
  assert_select 'input.string.name#name_input'
30
47
  end
31
48
 
32
49
  test 'builder input_field should not modify the options hash' do
33
- options = { :id => 'name_input', :class => 'name' }
50
+ options = { id: 'name_input', class: 'name' }
34
51
 
35
52
  with_concat_form_for(@user) do |f|
36
53
  f.input_field :name, options
37
54
  end
38
55
 
39
56
  assert_select 'input.string.name#name_input'
40
- assert_equal({ :id => 'name_input', :class => 'name' }, options)
57
+ assert_equal({ id: 'name_input', class: 'name' }, options)
41
58
  end
42
59
 
43
60
 
44
61
  test 'builder input_field should generate an input tag with a clean HTML' do
45
62
  with_concat_form_for(@user) do |f|
46
- f.input_field :name, :as => :integer, :class => 'name'
63
+ f.input_field :name, as: :integer, class: 'name'
47
64
  end
48
65
 
49
66
  assert_no_select 'input.integer[input_html]'
@@ -51,8 +68,8 @@ class InputFieldTest < ActionView::TestCase
51
68
  end
52
69
 
53
70
  test 'builder input_field should use i18n to translate placeholder text' do
54
- store_translations(:en, :simple_form => { :placeholders => { :user => {
55
- :name => 'Name goes here'
71
+ store_translations(:en, simple_form: { placeholders: { user: {
72
+ name: 'Name goes here'
56
73
  } } }) do
57
74
 
58
75
  with_concat_form_for(@user) do |f|
@@ -65,7 +82,7 @@ class InputFieldTest < ActionView::TestCase
65
82
 
66
83
  test 'builder input_field should use min_max component' do
67
84
  with_concat_form_for(@other_validating_user) do |f|
68
- f.input_field :age, :as => :integer
85
+ f.input_field :age, as: :integer
69
86
  end
70
87
 
71
88
  assert_select 'input[min=18]'
@@ -73,7 +90,7 @@ class InputFieldTest < ActionView::TestCase
73
90
 
74
91
  test 'builder input_field should use pattern component' do
75
92
  with_concat_form_for(@other_validating_user) do |f|
76
- f.input_field :country, :as => :string
93
+ f.input_field :country, as: :string
77
94
  end
78
95
 
79
96
  assert_select 'input[pattern="\w+"]'
@@ -81,7 +98,7 @@ class InputFieldTest < ActionView::TestCase
81
98
 
82
99
  test 'builder input_field should use readonly component' do
83
100
  with_concat_form_for(@other_validating_user) do |f|
84
- f.input_field :age, :as => :integer, :readonly => true
101
+ f.input_field :age, as: :integer, readonly: true
85
102
  end
86
103
 
87
104
  assert_select 'input.integer.readonly[readonly]'
@@ -89,7 +106,7 @@ class InputFieldTest < ActionView::TestCase
89
106
 
90
107
  test 'builder input_field should use maxlength component' do
91
108
  with_concat_form_for(@validating_user) do |f|
92
- f.input_field :name, :as => :string
109
+ f.input_field :name, as: :string
93
110
  end
94
111
 
95
112
  assert_select 'input.string[maxlength=25]'
@@ -97,7 +114,7 @@ class InputFieldTest < ActionView::TestCase
97
114
 
98
115
  test 'builder collection input_field should generate input tag with a clean HTML' do
99
116
  with_concat_form_for(@user) do |f|
100
- f.input_field :status, :collection => ['Open', 'Closed'], :class => 'status', :label_method => :to_s, :value_method => :to_s
117
+ f.input_field :status, collection: ['Open', 'Closed'], class: 'status', label_method: :to_s, value_method: :to_s
101
118
  end
102
119
 
103
120
  assert_no_select 'select.status[input_html]'
@@ -14,12 +14,12 @@ 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
21
21
 
22
- test 'builder should generate a label componet tag with a clean HTML' do
22
+ test 'builder should generate a label component tag with a clean HTML' do
23
23
  with_label_for @user, :name
24
24
  assert_no_select 'label.string[label_html]'
25
25
  end
@@ -29,33 +29,23 @@ class LabelTest < ActionView::TestCase
29
29
  assert_select 'label.string.required[for=validating_user_name]', /Name/
30
30
  end
31
31
 
32
- test 'builder should escape label text' do
33
- with_label_for @user, :name, :label => '<script>alert(1337)</script>', :required => false
34
- assert_select 'label.string', "&lt;script&gt;alert(1337)&lt;/script&gt;"
35
- end
36
-
37
- test 'builder should not escape label text if it is safe' do
38
- with_label_for @user, :name, :label => '<script>alert(1337)</script>'.html_safe, :required => false
39
- assert_select 'label.string script', "alert(1337)"
40
- end
41
-
42
32
  test 'builder should allow passing options to label tag' do
43
- with_label_for @user, :name, :label => 'My label', :id => 'name_label'
33
+ with_label_for @user, :name, label: 'My label', id: 'name_label'
44
34
  assert_select 'label.string#name_label', /My label/
45
35
  end
46
36
 
47
37
  test 'builder label should generate label tag with clean HTML' do
48
- 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'
49
39
  assert_select 'label.string#name_label', /My label/
50
40
  assert_no_select 'label[label]'
51
41
  assert_no_select 'label[required]'
52
42
  end
53
43
 
54
44
  test 'builder should not modify the options hash' do
55
- options = { :label => 'My label', :id => 'name_label' }
45
+ options = { label: 'My label', id: 'name_label' }
56
46
  with_label_for @user, :name, options
57
47
  assert_select 'label.string#name_label', /My label/
58
- assert_equal({ :label => 'My label', :id => 'name_label' }, options)
48
+ assert_equal({ label: 'My label', id: 'name_label' }, options)
59
49
  end
60
50
 
61
51
  test 'builder should fallback to default label when string is given' do
@@ -73,7 +63,7 @@ class LabelTest < ActionView::TestCase
73
63
  end
74
64
 
75
65
  test 'builder allows label order to be changed' do
76
- swap SimpleForm, :label_text => lambda { |l, r| "#{l}:" } do
66
+ swap SimpleForm, label_text: lambda { |l, r| "#{l}:" } do
77
67
  with_label_for @user, :age
78
68
  assert_select 'label.integer[for=user_age]', "Age:"
79
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'
@@ -140,7 +140,7 @@ class BooleanInputTest < ActionView::TestCase
140
140
 
141
141
  test 'input boolean without additional classes should add "checkbox" class to label' do
142
142
  swap_wrapper :default, self.custom_wrapper_without_top_level do
143
- swap SimpleForm, :boolean_style => :nested, :generate_additional_classes_for => [:input] do
143
+ swap SimpleForm, boolean_style: :nested, generate_additional_classes_for: [:input] do
144
144
  with_input_for @user, :active, :boolean
145
145
 
146
146
  assert_select 'label'