simple_form 2.1.3 → 3.0.0.beta1

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 (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
@@ -14,7 +14,7 @@ class CollectionSelectInputTest < ActionView::TestCase
14
14
  end
15
15
 
16
16
  test 'input as select should use i18n to translate select boolean options' do
17
- store_translations(:en, :simple_form => { :yes => 'Sim', :no => 'Não' }) do
17
+ store_translations(:en, simple_form: { yes: 'Sim', no: 'Não' }) do
18
18
  with_input_for @user, :active, :select
19
19
  assert_select 'select option[value=true]', 'Sim'
20
20
  assert_select 'select option[value=false]', 'Não'
@@ -22,17 +22,17 @@ class CollectionSelectInputTest < ActionView::TestCase
22
22
  end
23
23
 
24
24
  test 'input should allow overriding collection for select types' do
25
- with_input_for @user, :name, :select, :collection => ['Jose', 'Carlos']
25
+ with_input_for @user, :name, :select, collection: ['Jose', 'Carlos']
26
26
  assert_select 'select.select#user_name'
27
27
  assert_select 'select option', 'Jose'
28
28
  assert_select 'select option', 'Carlos'
29
29
  end
30
30
 
31
31
  test 'input should do automatic collection translation for select types using defaults key' do
32
- store_translations(:en, :simple_form => { :options => { :defaults => {
33
- :gender => { :male => 'Male', :female => 'Female'}
32
+ store_translations(:en, simple_form: { options: { defaults: {
33
+ gender: { male: 'Male', female: 'Female'}
34
34
  } } } ) do
35
- with_input_for @user, :gender, :select, :collection => [:male, :female]
35
+ with_input_for @user, :gender, :select, collection: [:male, :female]
36
36
  assert_select 'select.select#user_gender'
37
37
  assert_select 'select option', 'Male'
38
38
  assert_select 'select option', 'Female'
@@ -40,10 +40,10 @@ class CollectionSelectInputTest < ActionView::TestCase
40
40
  end
41
41
 
42
42
  test 'input should do automatic collection translation for select types using specific object key' do
43
- store_translations(:en, :simple_form => { :options => { :user => {
44
- :gender => { :male => 'Male', :female => 'Female'}
43
+ store_translations(:en, simple_form: { options: { user: {
44
+ gender: { male: 'Male', female: 'Female'}
45
45
  } } } ) do
46
- with_input_for @user, :gender, :select, :collection => [:male, :female]
46
+ with_input_for @user, :gender, :select, collection: [:male, :female]
47
47
  assert_select 'select.select#user_gender'
48
48
  assert_select 'select option', 'Male'
49
49
  assert_select 'select option', 'Female'
@@ -52,13 +52,13 @@ class CollectionSelectInputTest < ActionView::TestCase
52
52
 
53
53
  test 'input should mark the selected value by default' do
54
54
  @user.name = "Carlos"
55
- with_input_for @user, :name, :select, :collection => ['Jose', 'Carlos']
55
+ with_input_for @user, :name, :select, collection: ['Jose', 'Carlos']
56
56
  assert_select 'select option[selected=selected]', 'Carlos'
57
57
  end
58
58
 
59
59
  test 'input should mark the selected value also when using integers' do
60
60
  @user.age = 18
61
- with_input_for @user, :age, :select, :collection => 18..60
61
+ with_input_for @user, :age, :select, collection: 18..60
62
62
  assert_select 'select option[selected=selected]', '18'
63
63
  end
64
64
 
@@ -70,13 +70,13 @@ class CollectionSelectInputTest < ActionView::TestCase
70
70
  end
71
71
 
72
72
  test 'input should set the correct value when using a collection that includes floats' do
73
- with_input_for @user, :age, :select, :collection => [2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
73
+ with_input_for @user, :age, :select, collection: [2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
74
74
  assert_select 'select option[value="2.0"]'
75
75
  assert_select 'select option[value="2.5"]'
76
76
  end
77
77
 
78
78
  test 'input should set the correct values when using a collection that uses mixed values' do
79
- with_input_for @user, :age, :select, :collection => ["Hello Kitty", 2, 4.5, :johnny, nil, true, false]
79
+ with_input_for @user, :age, :select, collection: ["Hello Kitty", 2, 4.5, :johnny, nil, true, false]
80
80
  assert_select 'select option[value="Hello Kitty"]'
81
81
  assert_select 'select option[value="2"]'
82
82
  assert_select 'select option[value="4.5"]'
@@ -87,39 +87,39 @@ class CollectionSelectInputTest < ActionView::TestCase
87
87
  end
88
88
 
89
89
  test 'input should include a blank option even if :include_blank is set to false if the collection includes a nil value' do
90
- with_input_for @user, :age, :select, :collection => [nil], :include_blank => false
90
+ with_input_for @user, :age, :select, collection: [nil], include_blank: false
91
91
  assert_select 'select option[value=""]'
92
92
  end
93
93
 
94
94
  test 'input should automatically set include blank' do
95
- with_input_for @user, :age, :select, :collection => 18..30
95
+ with_input_for @user, :age, :select, collection: 18..30
96
96
  assert_select 'select option[value=]', ''
97
97
  end
98
98
 
99
99
  test 'input should not set include blank if otherwise is told' do
100
- with_input_for @user, :age, :select, :collection => 18..30, :include_blank => false
100
+ with_input_for @user, :age, :select, collection: 18..30, include_blank: false
101
101
  assert_no_select 'select option[value=]', ''
102
102
  end
103
103
 
104
104
  test 'input should not set include blank if prompt is given' do
105
- with_input_for @user, :age, :select, :collection => 18..30, :prompt => "Please select foo"
105
+ with_input_for @user, :age, :select, collection: 18..30, prompt: "Please select foo"
106
106
  assert_no_select 'select option[value=]', ''
107
107
  end
108
108
 
109
109
  test 'input should not set include blank if multiple is given' do
110
- with_input_for @user, :age, :select, :collection => 18..30, :input_html => { :multiple => true }
110
+ with_input_for @user, :age, :select, collection: 18..30, input_html: { multiple: true }
111
111
  assert_no_select 'select option[value=]', ''
112
112
  end
113
113
 
114
114
  test 'input should detect label and value on collections' do
115
- users = [ setup_new_user(:id => 1, :name => "Jose"), setup_new_user(:id => 2, :name => "Carlos") ]
116
- with_input_for @user, :description, :select, :collection => users
115
+ users = [ setup_new_user(id: 1, name: "Jose"), setup_new_user(id: 2, name: "Carlos") ]
116
+ with_input_for @user, :description, :select, collection: users
117
117
  assert_select 'select option[value=1]', 'Jose'
118
118
  assert_select 'select option[value=2]', 'Carlos'
119
119
  end
120
120
 
121
121
  test 'input should disable the anothers components when the option is a object' do
122
- with_input_for @user, :description, :select, :collection => ["Jose", "Carlos"], :disabled => true
122
+ with_input_for @user, :description, :select, collection: ["Jose", "Carlos"], disabled: true
123
123
  assert_no_select 'select option[value=Jose][disabled=disabled]', 'Jose'
124
124
  assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
125
125
  assert_select 'select[disabled=disabled]'
@@ -127,7 +127,7 @@ class CollectionSelectInputTest < ActionView::TestCase
127
127
  end
128
128
 
129
129
  test 'input should not disable the anothers components when the option is a object' do
130
- with_input_for @user, :description, :select, :collection => ["Jose", "Carlos"], :disabled => 'Jose'
130
+ with_input_for @user, :description, :select, collection: ["Jose", "Carlos"], disabled: 'Jose'
131
131
  assert_select 'select option[value=Jose][disabled=disabled]', 'Jose'
132
132
  assert_no_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
133
133
  assert_no_select 'select[disabled=disabled]'
@@ -136,101 +136,95 @@ class CollectionSelectInputTest < ActionView::TestCase
136
136
 
137
137
  test 'input should allow overriding label and value method using a lambda for collection selects' do
138
138
  with_input_for @user, :name, :select,
139
- :collection => ['Jose' , 'Carlos'],
140
- :label_method => lambda { |i| i.upcase },
141
- :value_method => lambda { |i| i.downcase }
139
+ collection: ['Jose' , 'Carlos'],
140
+ label_method: lambda { |i| i.upcase },
141
+ value_method: lambda { |i| i.downcase }
142
142
  assert_select 'select option[value=jose]', "JOSE"
143
143
  assert_select 'select option[value=carlos]', "CARLOS"
144
144
  end
145
145
 
146
146
  test 'input should allow overriding only label but not value method using a lambda for collection select' do
147
147
  with_input_for @user, :name, :select,
148
- :collection => ['Jose' , 'Carlos'],
149
- :label_method => lambda { |i| i.upcase }
148
+ collection: ['Jose' , 'Carlos'],
149
+ label_method: lambda { |i| i.upcase }
150
150
  assert_select 'select option[value=Jose]', "JOSE"
151
151
  assert_select 'select option[value=Carlos]', "CARLOS"
152
152
  end
153
153
 
154
154
  test 'input should allow overriding only value but not label method using a lambda for collection select' do
155
155
  with_input_for @user, :name, :select,
156
- :collection => ['Jose' , 'Carlos'],
157
- :value_method => lambda { |i| i.downcase }
156
+ collection: ['Jose' , 'Carlos'],
157
+ value_method: lambda { |i| i.downcase }
158
158
  assert_select 'select option[value=jose]', "Jose"
159
159
  assert_select 'select option[value=carlos]', "Carlos"
160
160
  end
161
161
 
162
162
  test 'input should allow symbols for collections' do
163
- with_input_for @user, :name, :select, :collection => [:jose, :carlos]
163
+ with_input_for @user, :name, :select, collection: [:jose, :carlos]
164
164
  assert_select 'select.select#user_name'
165
165
  assert_select 'select option[value=jose]', 'jose'
166
166
  assert_select 'select option[value=carlos]', 'carlos'
167
167
  end
168
168
 
169
169
  test 'collection input with select type should generate required html attribute only with blank option' do
170
- with_input_for @user, :name, :select, :include_blank => true, :collection => ['Jose' , 'Carlos']
171
- assert_select 'select.required'
172
- assert_select 'select[required]'
173
- end
174
-
175
- test 'collection input with select type should generate required html attribute only with blank option or prompt' do
176
- with_input_for @user, :name, :select, :prompt => 'Name...', :collection => ['Jose', 'Carlos']
170
+ with_input_for @user, :name, :select, include_blank: true, collection: ['Jose' , 'Carlos']
177
171
  assert_select 'select.required'
178
172
  assert_select 'select[required]'
179
173
  end
180
174
 
181
175
  test 'collection input with select type should not generate required html attribute without blank option' do
182
- with_input_for @user, :name, :select, :include_blank => false, :collection => ['Jose' , 'Carlos']
176
+ with_input_for @user, :name, :select, include_blank: false, collection: ['Jose' , 'Carlos']
183
177
  assert_select 'select.required'
184
178
  assert_no_select 'select[required]'
185
179
  end
186
180
 
187
181
  test 'collection input with select type with multiple attribute should generate required html attribute without blank option' do
188
- with_input_for @user, :name, :select, :include_blank => false, :input_html => {:multiple => true}, :collection => ['Jose' , 'Carlos']
182
+ with_input_for @user, :name, :select, include_blank: false, input_html: {multiple: true}, collection: ['Jose' , 'Carlos']
189
183
  assert_select 'select.required'
190
184
  assert_select 'select[required]'
191
185
  end
192
186
 
193
187
  test 'collection input with select type with multiple attribute should generate required html attribute with blank option' do
194
- with_input_for @user, :name, :select, :include_blank => true, :input_html => {:multiple => true}, :collection => ['Jose' , 'Carlos']
188
+ with_input_for @user, :name, :select, include_blank: true, input_html: {multiple: true}, collection: ['Jose' , 'Carlos']
195
189
  assert_select 'select.required'
196
190
  assert_select 'select[required]'
197
191
  end
198
192
 
199
193
  test 'input should allow disabled options with a lambda for collection select' do
200
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
201
- :disabled => lambda { |x| x == "Carlos" }
194
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
195
+ disabled: lambda { |x| x == "Carlos" }
202
196
  assert_select 'select option[value=Carlos][disabled=disabled]', 'Carlos'
203
197
  assert_select 'select option[value=Antonio]', 'Antonio'
204
198
  assert_no_select 'select option[value=Antonio][disabled]'
205
199
  end
206
200
 
207
201
  test 'input should allow disabled and label method with lambdas for collection select' do
208
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
209
- :disabled => lambda { |x| x == "Carlos" }, :label_method => lambda { |x| x.upcase }
202
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
203
+ disabled: lambda { |x| x == "Carlos" }, label_method: lambda { |x| x.upcase }
210
204
  assert_select 'select option[value=Carlos][disabled=disabled]', 'CARLOS'
211
205
  assert_select 'select option[value=Antonio]', 'ANTONIO'
212
206
  assert_no_select 'select option[value=Antonio][disabled]'
213
207
  end
214
208
 
215
209
  test 'input should allow a non lambda disabled option with lambda label method for collections' do
216
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
217
- :disabled => "Carlos", :label_method => lambda { |x| x.upcase }
210
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
211
+ disabled: "Carlos", label_method: lambda { |x| x.upcase }
218
212
  assert_select 'select option[value=Carlos][disabled=disabled]', 'CARLOS'
219
213
  assert_select 'select option[value=Antonio]', 'ANTONIO'
220
214
  assert_no_select 'select option[value=Antonio][disabled]'
221
215
  end
222
216
 
223
217
  test 'input should allow selected and label method with lambdas for collection select' do
224
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
225
- :selected => lambda { |x| x == "Carlos" }, :label_method => lambda { |x| x.upcase }
218
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
219
+ selected: lambda { |x| x == "Carlos" }, label_method: lambda { |x| x.upcase }
226
220
  assert_select 'select option[value=Carlos][selected=selected]', 'CARLOS'
227
221
  assert_select 'select option[value=Antonio]', 'ANTONIO'
228
222
  assert_no_select 'select option[value=Antonio][selected]'
229
223
  end
230
224
 
231
225
  test 'input should allow a non lambda selected option with lambda label method for collection select' do
232
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
233
- :selected => "Carlos", :label_method => lambda { |x| x.upcase }
226
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
227
+ selected: "Carlos", label_method: lambda { |x| x.upcase }
234
228
  assert_select 'select option[value=Carlos][selected=selected]', 'CARLOS'
235
229
  assert_select 'select option[value=Antonio]', 'ANTONIO'
236
230
  assert_no_select 'select option[value=Antonio][selected]'
@@ -238,8 +232,8 @@ class CollectionSelectInputTest < ActionView::TestCase
238
232
 
239
233
  test 'input should not override default selection through attribute value with label method as lambda for collection select' do
240
234
  @user.name = "Carlos"
241
- with_input_for @user, :name, :select, :collection => ["Carlos", "Antonio"],
242
- :label_method => lambda { |x| x.upcase }
235
+ with_input_for @user, :name, :select, collection: ["Carlos", "Antonio"],
236
+ label_method: lambda { |x| x.upcase }
243
237
  assert_select 'select option[value=Carlos][selected=selected]', 'CARLOS'
244
238
  assert_select 'select option[value=Antonio]', 'ANTONIO'
245
239
  assert_no_select 'select option[value=Antonio][selected]'
@@ -13,7 +13,7 @@ class DateTimeInputTest < ActionView::TestCase
13
13
 
14
14
  test 'input should be able to pass options to datetime select' do
15
15
  with_input_for @user, :created_at, :datetime,
16
- :disabled => true, :prompt => { :year => 'ano', :month => 'mês', :day => 'dia' }
16
+ disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' }
17
17
 
18
18
  assert_select 'select.datetime[disabled=disabled]'
19
19
  assert_select 'select.datetime option', 'ano'
@@ -30,8 +30,8 @@ class DateTimeInputTest < ActionView::TestCase
30
30
  end
31
31
 
32
32
  test 'input should be able to pass options to date select' do
33
- with_input_for @user, :born_at, :date, :as => :date,
34
- :disabled => true, :prompt => { :year => 'ano', :month => 'mês', :day => 'dia' }
33
+ with_input_for @user, :born_at, :date, as: :date,
34
+ disabled: true, prompt: { year: 'ano', month: 'mês', day: 'dia' }
35
35
 
36
36
  assert_select 'select.date[disabled=disabled]'
37
37
  assert_select 'select.date option', 'ano'
@@ -40,7 +40,7 @@ class DateTimeInputTest < ActionView::TestCase
40
40
  end
41
41
 
42
42
  test 'input should be able to pass :default to date select' do
43
- with_input_for @user, :born_at, :date, :default => Date.today
43
+ with_input_for @user, :born_at, :date, default: Date.today
44
44
  assert_select "select.date option[value=#{Date.today.year}][selected=selected]"
45
45
  end
46
46
 
@@ -54,8 +54,8 @@ class DateTimeInputTest < ActionView::TestCase
54
54
  end
55
55
 
56
56
  test 'input should be able to pass options to time select' do
57
- with_input_for @user, :delivery_time, :time, :required => true,
58
- :disabled => true, :prompt => { :hour => 'hora', :minute => 'minuto' }
57
+ with_input_for @user, :delivery_time, :time, required: true,
58
+ disabled: true, prompt: { hour: 'hora', minute: 'minuto' }
59
59
 
60
60
  assert_select 'select.time[disabled=disabled]'
61
61
  assert_select 'select.time option', 'hora'
@@ -63,26 +63,26 @@ class DateTimeInputTest < ActionView::TestCase
63
63
  end
64
64
 
65
65
  test 'label should use i18n to get target for date input type' do
66
- store_translations(:en, :date => { :order => [:month, :day, :year] }) do
66
+ store_translations(:en, date: { order: [:month, :day, :year] }) do
67
67
  with_input_for :project, :created_at, :date
68
68
  assert_select 'label[for=project_created_at_2i]'
69
69
  end
70
70
  end
71
71
 
72
72
  test 'label should use i18n to get target for datetime input type' do
73
- store_translations(:en, :date => { :order => [:month, :day, :year] }) do
73
+ store_translations(:en, date: { order: [:month, :day, :year] }) do
74
74
  with_input_for :project, :created_at, :datetime
75
75
  assert_select 'label[for=project_created_at_2i]'
76
76
  end
77
77
  end
78
78
 
79
79
  test 'label should use order to get target when date input type' do
80
- with_input_for :project, :created_at, :date, :order => [:month, :year, :day]
80
+ with_input_for :project, :created_at, :date, order: [:month, :year, :day]
81
81
  assert_select 'label[for=project_created_at_2i]'
82
82
  end
83
83
 
84
84
  test 'label should use order to get target when datetime input type' do
85
- with_input_for :project, :created_at, :datetime, :order => [:month, :year, :day]
85
+ with_input_for :project, :created_at, :datetime, order: [:month, :year, :day]
86
86
  assert_select 'label[for=project_created_at_2i]'
87
87
  end
88
88
 
@@ -92,7 +92,7 @@ class DateTimeInputTest < ActionView::TestCase
92
92
  end
93
93
 
94
94
  test 'date time input should generate required html attribute' do
95
- with_input_for @user, :delivery_time, :time, :required => true
95
+ with_input_for @user, :delivery_time, :time, required: true
96
96
  assert_select 'select.required'
97
97
  assert_select 'select[required]'
98
98
  end
@@ -2,52 +2,52 @@ require 'test_helper'
2
2
 
3
3
  class DisabledTest < ActionView::TestCase
4
4
  test 'string input should be disabled when disabled option is true' do
5
- with_input_for @user, :name, :string, :disabled => true
5
+ with_input_for @user, :name, :string, disabled: true
6
6
  assert_select 'input.string.disabled[disabled]'
7
7
  end
8
8
 
9
9
  test 'text input should be disabled when disabled option is true' do
10
- with_input_for @user, :description, :text, :disabled => true
10
+ with_input_for @user, :description, :text, disabled: true
11
11
  assert_select 'textarea.text.disabled[disabled]'
12
12
  end
13
13
 
14
14
  test 'numeric input should be disabled when disabled option is true' do
15
- with_input_for @user, :age, :integer, :disabled => true
15
+ with_input_for @user, :age, :integer, disabled: true
16
16
  assert_select 'input.integer.disabled[disabled]'
17
17
  end
18
18
 
19
19
  test 'date input should be disabled when disabled option is true' do
20
- with_input_for @user, :born_at, :date, :disabled => true
20
+ with_input_for @user, :born_at, :date, disabled: true
21
21
  assert_select 'select.date.disabled[disabled]'
22
22
  end
23
23
 
24
24
  test 'datetime input should be disabled when disabled option is true' do
25
- with_input_for @user, :created_at, :datetime, :disabled => true
25
+ with_input_for @user, :created_at, :datetime, disabled: true
26
26
  assert_select 'select.datetime.disabled[disabled]'
27
27
  end
28
28
 
29
29
  test 'string input should not be disabled when disabled option is false' do
30
- with_input_for @user, :name, :string, :disabled => false
30
+ with_input_for @user, :name, :string, disabled: false
31
31
  assert_no_select 'input.string.disabled[disabled]'
32
32
  end
33
33
 
34
34
  test 'text input should not be disabled when disabled option is false' do
35
- with_input_for @user, :description, :text, :disabled => false
35
+ with_input_for @user, :description, :text, disabled: false
36
36
  assert_no_select 'textarea.text.disabled[disabled]'
37
37
  end
38
38
 
39
39
  test 'numeric input should not be disabled when disabled option is false' do
40
- with_input_for @user, :age, :integer, :disabled => false
40
+ with_input_for @user, :age, :integer, disabled: false
41
41
  assert_no_select 'input.integer.disabled[disabled]'
42
42
  end
43
43
 
44
44
  test 'date input should not be disabled when disabled option is false' do
45
- with_input_for @user, :born_at, :date, :disabled => false
45
+ with_input_for @user, :born_at, :date, disabled: false
46
46
  assert_no_select 'select.date.disabled[disabled]'
47
47
  end
48
48
 
49
49
  test 'datetime input should not be disabled when disabled option is false' do
50
- with_input_for @user, :created_at, :datetime, :disabled => false
50
+ with_input_for @user, :created_at, :datetime, disabled: false
51
51
  assert_no_select 'select.datetime.disabled[disabled]'
52
52
  end
53
53
 
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class DiscoveryTest < ActionView::TestCase
4
4
  # Setup new inputs and remove them after the test.
5
5
  def discovery(value=false)
6
- swap SimpleForm, :cache_discovery => value do
6
+ swap SimpleForm, cache_discovery: value do
7
7
  begin
8
8
  load "support/discovery_inputs.rb"
9
9
  yield
@@ -29,7 +29,7 @@ class DiscoveryTest < ActionView::TestCase
29
29
 
30
30
  test 'builder should discover new inputs' do
31
31
  discovery do
32
- with_form_for @user, :name, :as => :customized
32
+ with_form_for @user, :name, as: :customized
33
33
  assert_select 'form section input#user_name.string'
34
34
  end
35
35
  end
@@ -38,7 +38,7 @@ class DiscoveryTest < ActionView::TestCase
38
38
  with_form_for @user, :name
39
39
  assert_select 'form input#user_name.string'
40
40
 
41
- swap SimpleForm, :inputs_discovery => false do
41
+ swap SimpleForm, inputs_discovery: false do
42
42
  discovery do
43
43
  with_form_for @user, :name
44
44
  assert_no_select 'form section input#user_name.string'
@@ -62,7 +62,7 @@ class DiscoveryTest < ActionView::TestCase
62
62
 
63
63
  test 'new inputs can override the input_html_options' do
64
64
  discovery do
65
- with_form_for @user, :active, :as => :select
65
+ with_form_for @user, :active, as: :select
66
66
  assert_select 'form select#user_active.select.chosen'
67
67
  end
68
68
  end
@@ -8,7 +8,7 @@ class FileInputTest < ActionView::TestCase
8
8
  end
9
9
 
10
10
  test "input should generate a file field that doesn't accept placeholder" do
11
- store_translations(:en, :simple_form => { :placeholders => { :user => { :name => "text" } } }) do
11
+ store_translations(:en, simple_form: { placeholders: { user: { name: "text" } } }) do
12
12
  with_input_for @user, :name, :file
13
13
  assert_no_select 'input[placeholder]'
14
14
  end