simple_form 3.1.0.rc2 → 3.1.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +27 -10
  4. data/lib/generators/simple_form/install_generator.rb +2 -2
  5. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +3 -2
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +8 -1
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +85 -4
  8. data/lib/simple_form.rb +13 -2
  9. data/lib/simple_form/action_view_extensions/builder.rb +1 -0
  10. data/lib/simple_form/action_view_extensions/form_helper.rb +5 -1
  11. data/lib/simple_form/components/errors.rb +3 -5
  12. data/lib/simple_form/form_builder.rb +5 -4
  13. data/lib/simple_form/inputs/boolean_input.rb +1 -1
  14. data/lib/simple_form/inputs/collection_input.rb +2 -4
  15. data/lib/simple_form/tags.rb +2 -4
  16. data/lib/simple_form/version.rb +1 -1
  17. data/test/action_view_extensions/builder_test.rb +31 -31
  18. data/test/action_view_extensions/form_helper_test.rb +20 -1
  19. data/test/components/label_test.rb +1 -1
  20. data/test/form_builder/association_test.rb +37 -37
  21. data/test/form_builder/button_test.rb +5 -5
  22. data/test/form_builder/error_test.rb +70 -11
  23. data/test/form_builder/general_test.rb +24 -4
  24. data/test/form_builder/hint_test.rb +3 -3
  25. data/test/form_builder/input_field_test.rb +43 -3
  26. data/test/form_builder/label_test.rb +1 -1
  27. data/test/form_builder/wrapper_test.rb +18 -3
  28. data/test/generators/simple_form_generator_test.rb +2 -2
  29. data/test/inputs/boolean_input_test.rb +9 -1
  30. data/test/inputs/collection_check_boxes_input_test.rb +22 -0
  31. data/test/inputs/collection_radio_buttons_input_test.rb +25 -3
  32. data/test/inputs/collection_select_input_test.rb +17 -17
  33. data/test/inputs/datetime_input_test.rb +1 -1
  34. data/test/inputs/grouped_collection_select_input_test.rb +8 -8
  35. data/test/inputs/numeric_input_test.rb +19 -19
  36. data/test/inputs/priority_input_test.rb +6 -6
  37. data/test/inputs/string_input_test.rb +10 -10
  38. data/test/inputs/text_input_test.rb +3 -3
  39. data/test/support/misc_helpers.rb +6 -0
  40. data/test/support/models.rb +11 -1
  41. data/test/test_helper.rb +5 -1
  42. metadata +4 -4
@@ -50,7 +50,7 @@ class HintTest < ActionView::TestCase
50
50
 
51
51
  test 'builder escapes hint text' do
52
52
  with_hint_for @user, :name, hint: '<script>alert(1337)</script>'
53
- assert_select 'span.hint', "&lt;script&gt;alert(1337)&lt;/script&gt;"
53
+ assert_no_select 'span.hint script'
54
54
  end
55
55
 
56
56
  # Without attribute name
@@ -137,8 +137,8 @@ class HintTest < ActionView::TestCase
137
137
 
138
138
  test 'hint with custom wrappers works' do
139
139
  swap_wrapper do
140
- with_hint_for @user, :name, hint: "can't be blank"
141
- assert_select 'div.omg_hint', "can&#39;t be blank"
140
+ with_hint_for @user, :name, hint: "cannot be blank"
141
+ assert_select 'div.omg_hint', "cannot be blank"
142
142
  end
143
143
  end
144
144
  end
@@ -76,7 +76,7 @@ class InputFieldTest < ActionView::TestCase
76
76
  f.input_field :name
77
77
  end
78
78
 
79
- assert_select 'input.string[placeholder=Name goes here]'
79
+ assert_select 'input.string[placeholder="Name goes here"]'
80
80
  end
81
81
  end
82
82
 
@@ -85,7 +85,7 @@ class InputFieldTest < ActionView::TestCase
85
85
  f.input_field :age, as: :integer
86
86
  end
87
87
 
88
- assert_select 'input[min=18]'
88
+ assert_select 'input[min="18"]'
89
89
  end
90
90
 
91
91
  test 'builder input_field does not use pattern component by default' do
@@ -125,7 +125,7 @@ class InputFieldTest < ActionView::TestCase
125
125
  f.input_field :name, as: :string
126
126
  end
127
127
 
128
- assert_select 'input.string[maxlength=25]'
128
+ assert_select 'input.string[maxlength="25"]'
129
129
  end
130
130
 
131
131
  test 'builder collection input_field generates input tag with a clean HTML' do
@@ -146,4 +146,44 @@ class InputFieldTest < ActionView::TestCase
146
146
 
147
147
  assert_no_select 'input.boolean[boolean_style]'
148
148
  end
149
+
150
+ test 'build input_field without pattern component use the pattern string' do
151
+ swap_wrapper :default, self.custom_wrapper_with_html5_components do
152
+ with_concat_form_for(@user) do |f|
153
+ f.input_field :name, pattern: '\w+'
154
+ end
155
+
156
+ assert_select 'input[pattern="\w+"]'
157
+ end
158
+ end
159
+
160
+ test 'build input_field without placeholder component use the placeholder string' do
161
+ swap_wrapper :default, self.custom_wrapper_with_html5_components do
162
+ with_concat_form_for(@user) do |f|
163
+ f.input_field :name, placeholder: 'Placeholder'
164
+ end
165
+
166
+ assert_select 'input[placeholder="Placeholder"]'
167
+ end
168
+ end
169
+
170
+ test 'build input_field without maxlength component use the maxlength string' do
171
+ swap_wrapper :default, self.custom_wrapper_with_html5_components do
172
+ with_concat_form_for(@user) do |f|
173
+ f.input_field :name, maxlength: 5
174
+ end
175
+
176
+ assert_select 'input[maxlength="5"]'
177
+ end
178
+ end
179
+
180
+ test 'build input_field without readonly component use the readonly string' do
181
+ swap_wrapper :default, self.custom_wrapper_with_html5_components do
182
+ with_concat_form_for(@user) do |f|
183
+ f.input_field :name, readonly: true
184
+ end
185
+
186
+ assert_select 'input[readonly="readonly"]'
187
+ end
188
+ end
149
189
  end
@@ -31,7 +31,7 @@ class LabelTest < ActionView::TestCase
31
31
 
32
32
  test 'builder escapes label text' do
33
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;"
34
+ assert_no_select 'label.string script'
35
35
  end
36
36
 
37
37
  test 'builder does not escape label text if it is safe' do
@@ -139,7 +139,7 @@ class WrapperTest < ActionView::TestCase
139
139
  test 'custom wrappers can have full error message on attributes' do
140
140
  swap_wrapper :default, self.custom_wrapper_with_full_error do
141
141
  with_form_for @user, :name
142
- assert_select 'span.error', "Name can't be blank"
142
+ assert_select 'span.error', "Name cannot be blank"
143
143
  end
144
144
  end
145
145
 
@@ -227,6 +227,21 @@ class WrapperTest < ActionView::TestCase
227
227
  assert_select "section.custom_wrapper div.another_wrapper input.string"
228
228
  end
229
229
 
230
+ test 'simple_fields_form reuses custom wrapper mapping per form basis' do
231
+ @user.company = Company.new(1, 'Empresa')
232
+
233
+ swap_wrapper :another do
234
+ with_concat_form_for @user, wrapper_mappings: { string: :another } do |f|
235
+ concat(f.simple_fields_for(:company) do |company_form|
236
+ concat(company_form.input(:name))
237
+ end)
238
+ end
239
+ end
240
+
241
+ assert_select "section.custom_wrapper div.another_wrapper label"
242
+ assert_select "section.custom_wrapper div.another_wrapper input.string"
243
+ end
244
+
230
245
  test 'input accepts attributes in the DSL' do
231
246
  swap_wrapper :default, self.custom_wrapper_with_input_class do
232
247
  with_concat_form_for @user do |f|
@@ -270,8 +285,8 @@ class WrapperTest < ActionView::TestCase
270
285
 
271
286
  test 'inline wrapper displays when there is content' do
272
287
  swap_wrapper :default, self.custom_wrapper_with_wrapped_optional_component do
273
- with_form_for @user, :name, hint: "can't be blank"
274
- assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "can&#39;t be blank"
288
+ with_form_for @user, :name, hint: "cannot be blank"
289
+ assert_select 'section.custom_wrapper div.no_output_wrapper p.omg_hint', "cannot be blank"
275
290
  assert_select 'p.omg_hint'
276
291
  end
277
292
  end
@@ -29,8 +29,8 @@ class SimpleFormGeneratorTest < Rails::Generators::TestCase
29
29
  run_generator %w(--foundation)
30
30
  assert_file 'config/initializers/simple_form.rb',
31
31
  /config\.default_wrapper = :default/, /config\.boolean_style = :nested/
32
- assert_file 'config/initializers/simple_form_foundation.rb', /config\.wrappers :foundation/,
33
- /config\.default_wrapper = :foundation/
32
+ assert_file 'config/initializers/simple_form_foundation.rb', /config\.wrappers :vertical_form/,
33
+ /config\.default_wrapper = :vertical_form/, /config\.item_wrapper_tag = :div/
34
34
  end
35
35
 
36
36
  %W(erb haml slim).each do |engine|
@@ -57,7 +57,7 @@ class BooleanInputTest < ActionView::TestCase
57
57
  test 'input boolean with nested escapes :inline_label with HTML' do
58
58
  swap SimpleForm, boolean_style: :nested do
59
59
  with_input_for @user, :active, :boolean, inline_label: '<b>I am so inline.</b>'
60
- assert_select 'label.checkbox', text: ' &lt;b&gt;I am so inline.&lt;/b&gt;'
60
+ assert_no_select 'label.checkbox b'
61
61
  end
62
62
  end
63
63
 
@@ -197,4 +197,12 @@ class BooleanInputTest < ActionView::TestCase
197
197
  end
198
198
  end
199
199
  end
200
+
201
+ test 'input boolean works with wrapper config defining a class for the input' do
202
+ swap_wrapper :default, self.custom_wrapper_with_input_class do
203
+ with_input_for @user, :active, :boolean
204
+
205
+ assert_select 'input.boolean.inline-class'
206
+ end
207
+ end
200
208
  end
@@ -278,4 +278,26 @@ class CollectionCheckBoxesInputTest < ActionView::TestCase
278
278
  assert_select 'span.custom'
279
279
  end
280
280
  end
281
+
282
+ test 'input check boxes with nested style and namespace uses the right for attribute' do
283
+ swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
284
+ with_concat_form_for @user, namespace: :foo do |f|
285
+ concat f.input :gender, as: :check_boxes, collection: [:male, :female]
286
+ end
287
+
288
+ assert_select 'label[for=foo_user_gender_male]'
289
+ assert_select 'label[for=foo_user_gender_female]'
290
+ end
291
+ end
292
+
293
+ test 'input check boxes with nested style and index uses the right for attribute' do
294
+ swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
295
+ with_concat_form_for @user, index: 1 do |f|
296
+ concat f.input :gender, as: :check_boxes, collection: [:male, :female]
297
+ end
298
+
299
+ assert_select 'label[for=user_1_gender_male]'
300
+ assert_select 'label[for=user_1_gender_female]'
301
+ end
302
+ end
281
303
  end
@@ -100,8 +100,8 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
100
100
  with_input_for @user, :gender, :radio_buttons, collection: [:male, :female]
101
101
  assert_select 'input[type=radio][value=male]'
102
102
  assert_select 'input[type=radio][value=female]'
103
- assert_select 'label[for=user_gender_male]', 'Male'
104
- assert_select 'label[for=user_gender_female]', 'Female'
103
+ assert_select 'label[for=user_gender_male] strong', 'Male'
104
+ assert_select 'label[for=user_gender_female] strong', 'Female'
105
105
  end
106
106
  end
107
107
  end
@@ -393,7 +393,7 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
393
393
  end
394
394
  end
395
395
 
396
- test 'input check boxes custom wrapper class is included when include input wrapper class is falsey' do
396
+ test 'input radio custom wrapper class is included when include input wrapper class is falsey' do
397
397
  swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
398
398
  with_input_for @user, :gender, :radio_buttons, collection: [:male, :female], item_wrapper_class: 'custom'
399
399
 
@@ -401,4 +401,26 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
401
401
  assert_select 'span.custom'
402
402
  end
403
403
  end
404
+
405
+ test 'input radio with nested style and namespace uses the right for attribute' do
406
+ swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
407
+ with_concat_form_for @user, namespace: :foo do |f|
408
+ concat f.input :gender, as: :radio_buttons, collection: [:male, :female]
409
+ end
410
+
411
+ assert_select 'label[for=foo_user_gender_male]'
412
+ assert_select 'label[for=foo_user_gender_female]'
413
+ end
414
+ end
415
+
416
+ test 'input radio with nested style and index uses the right for attribute' do
417
+ swap SimpleForm, include_default_input_wrapper_class: false, boolean_style: :nested do
418
+ with_concat_form_for @user, index: 1 do |f|
419
+ concat f.input :gender, as: :radio_buttons, collection: [:male, :female]
420
+ end
421
+
422
+ assert_select 'label[for=user_1_gender_male]'
423
+ assert_select 'label[for=user_1_gender_female]'
424
+ end
425
+ end
404
426
  end
@@ -99,7 +99,7 @@ class CollectionSelectInputTest < ActionView::TestCase
99
99
 
100
100
  test 'input automatically sets include blank' do
101
101
  with_input_for @user, :age, :select, collection: 18..30
102
- assert_select 'select option[value=]', ''
102
+ assert_select 'select option[value=""]', ''
103
103
  end
104
104
 
105
105
  test 'input translates include blank when set to :translate' do
@@ -107,7 +107,7 @@ class CollectionSelectInputTest < ActionView::TestCase
107
107
  age: 'Rather not say'
108
108
  } } }) do
109
109
  with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate
110
- assert_select 'select option[value=]', 'Rather not say'
110
+ assert_select 'select option[value=""]', 'Rather not say'
111
111
  end
112
112
  end
113
113
 
@@ -116,7 +116,7 @@ class CollectionSelectInputTest < ActionView::TestCase
116
116
  age: 'Rather not say',
117
117
  } } }) do
118
118
  with_input_for @user, :age, :select, collection: 18..30, include_blank: :translate
119
- assert_select 'select option[value=]', 'Rather not say'
119
+ assert_select 'select option[value=""]', 'Rather not say'
120
120
  end
121
121
  end
122
122
 
@@ -125,7 +125,7 @@ class CollectionSelectInputTest < ActionView::TestCase
125
125
  age: 'Rather not say'
126
126
  } } }) do
127
127
  with_input_for @user, :age, :select, collection: 18..30, include_blank: 'Young at heart'
128
- assert_select 'select option[value=]', 'Young at heart'
128
+ assert_select 'select option[value=""]', 'Young at heart'
129
129
  end
130
130
  end
131
131
 
@@ -134,7 +134,7 @@ class CollectionSelectInputTest < ActionView::TestCase
134
134
  age: 'Rather not say'
135
135
  } } }) do
136
136
  with_input_for @user, :age, :select, collection: 18..30
137
- assert_select 'select option[value=]', ''
137
+ assert_select 'select option[value=""]', ''
138
138
  end
139
139
  end
140
140
 
@@ -143,7 +143,7 @@ class CollectionSelectInputTest < ActionView::TestCase
143
143
  age: 'Rather not say'
144
144
  } } }) do
145
145
  with_input_for @user, :age, :select, collection: 18..30, include_blank: true
146
- assert_select 'select option[value=]', ''
146
+ assert_select 'select option[value=""]', ''
147
147
  end
148
148
  end
149
149
 
@@ -152,23 +152,23 @@ class CollectionSelectInputTest < ActionView::TestCase
152
152
  age: 'Rather not say'
153
153
  } } }) do
154
154
  with_input_for @user, :age, :select, collection: 18..30, include_blank: false
155
- assert_no_select 'select option[value=]'
155
+ assert_no_select 'select option[value=""]'
156
156
  end
157
157
  end
158
158
 
159
159
  test 'input does not set include blank if otherwise is told' do
160
160
  with_input_for @user, :age, :select, collection: 18..30, include_blank: false
161
- assert_no_select 'select option[value=]'
161
+ assert_no_select 'select option[value=""]'
162
162
  end
163
163
 
164
164
  test 'input does not set include blank if prompt is given' do
165
165
  with_input_for @user, :age, :select, collection: 18..30, prompt: "Please select foo"
166
- assert_no_select 'select option[value=]', ''
166
+ assert_no_select 'select option[value=""]', ''
167
167
  end
168
168
 
169
169
  test 'input does not set include blank if multiple is given' do
170
170
  with_input_for @user, :age, :select, collection: 18..30, input_html: { multiple: true }
171
- assert_no_select 'select option[value=]', ''
171
+ assert_no_select 'select option[value=""]', ''
172
172
  end
173
173
 
174
174
  test 'input translates prompt when set to :translate' do
@@ -176,7 +176,7 @@ class CollectionSelectInputTest < ActionView::TestCase
176
176
  age: 'Select age:'
177
177
  } } }) do
178
178
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
179
- assert_select 'select option[value=]', 'Select age:'
179
+ assert_select 'select option[value=""]', 'Select age:'
180
180
  end
181
181
  end
182
182
 
@@ -185,7 +185,7 @@ class CollectionSelectInputTest < ActionView::TestCase
185
185
  age: 'Select age:',
186
186
  } } }) do
187
187
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
188
- assert_select 'select option[value=]', 'Select age:'
188
+ assert_select 'select option[value=""]', 'Select age:'
189
189
  end
190
190
  end
191
191
 
@@ -194,7 +194,7 @@ class CollectionSelectInputTest < ActionView::TestCase
194
194
  age: 'Select age:'
195
195
  } } }) do
196
196
  with_input_for @user, :age, :select, collection: 18..30, prompt: 'Do it:'
197
- assert_select 'select option[value=]', 'Do it:'
197
+ assert_select 'select option[value=""]', 'Do it:'
198
198
  end
199
199
  end
200
200
 
@@ -203,7 +203,7 @@ class CollectionSelectInputTest < ActionView::TestCase
203
203
  age: 'Select age:'
204
204
  } } }) do
205
205
  with_input_for @user, :age, :select, collection: 18..30, prompt: false
206
- assert_no_select 'select option[value=]'
206
+ assert_no_select 'select option[value=""]'
207
207
  end
208
208
  end
209
209
 
@@ -212,15 +212,15 @@ class CollectionSelectInputTest < ActionView::TestCase
212
212
  prompt: 'Select value:'
213
213
  } }) do
214
214
  with_input_for @user, :age, :select, collection: 18..30, prompt: :translate
215
- assert_select 'select option[value=]', "Select value:"
215
+ assert_select 'select option[value=""]', "Select value:"
216
216
  end
217
217
  end
218
218
 
219
219
  test 'input detects label and value on collections' do
220
220
  users = [User.build(id: 1, name: "Jose"), User.build(id: 2, name: "Carlos")]
221
221
  with_input_for @user, :description, :select, collection: users
222
- assert_select 'select option[value=1]', 'Jose'
223
- assert_select 'select option[value=2]', 'Carlos'
222
+ assert_select 'select option[value="1"]', 'Jose'
223
+ assert_select 'select option[value="2"]', 'Carlos'
224
224
  end
225
225
 
226
226
  test 'input disables the anothers components when the option is a object' do
@@ -102,7 +102,7 @@ class DateTimeInputWithoutHtml5Test < ActionView::TestCase
102
102
 
103
103
  test 'input is able to pass :default to date select' do
104
104
  with_input_for @user, :born_at, :date, default: Date.today, html5: false
105
- assert_select "select.date option[value=#{Date.today.year}][selected=selected]"
105
+ assert_select "select.date option[value='#{Date.today.year}'][selected=selected]"
106
106
  end
107
107
 
108
108
  test 'input generates a date input for date attributes if HTML5 compatibility is explicitly enabled' do
@@ -109,8 +109,8 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase
109
109
 
110
110
  assert_select 'select.grouped_select#user_tag_ids' do
111
111
  assert_select 'optgroup[label=Second]' do
112
- assert_select 'option[value=7]', 'Bond'
113
- assert_select 'option[value=47]', 'Hitman'
112
+ assert_select 'option[value="7"]', 'Bond'
113
+ assert_select 'option[value="47"]', 'Hitman'
114
114
  end
115
115
  end
116
116
  end
@@ -155,14 +155,14 @@ class GroupedCollectionSelectInputTest < ActionView::TestCase
155
155
  collection: tag_groups, group_method: :tags
156
156
 
157
157
  assert_select 'select.grouped_select#user_tag_ids' do
158
- assert_select 'optgroup[label=Group of Tags]' do
159
- assert_select 'option[value=1]', 'Tag 1'
160
- assert_select 'option[value=2]', 'Tag 2'
158
+ assert_select 'optgroup[label="Group of Tags"]' do
159
+ assert_select 'option[value="1"]', 'Tag 1'
160
+ assert_select 'option[value="2"]', 'Tag 2'
161
161
  end
162
162
 
163
- assert_select 'optgroup[label=Other group]' do
164
- assert_select 'option[value=3]', 'Tag 3'
165
- assert_select 'option[value=4]', 'Tag 4'
163
+ assert_select 'optgroup[label="Other group"]' do
164
+ assert_select 'option[value="3"]', 'Tag 3'
165
+ assert_select 'option[value="4"]', 'Tag 4'
166
166
  end
167
167
  end
168
168
  end
@@ -32,7 +32,7 @@ class NumericInputTest < ActionView::TestCase
32
32
  assert_no_select 'input[min]'
33
33
 
34
34
  with_input_for @other_validating_user, :age, :integer
35
- assert_select 'input[min=18]'
35
+ assert_select 'input[min="18"]'
36
36
  end
37
37
 
38
38
  test 'input infers min value from integer attributes with greater than validation using symbol' do
@@ -40,15 +40,15 @@ class NumericInputTest < ActionView::TestCase
40
40
  assert_no_select 'input[min]'
41
41
 
42
42
  with_input_for @validating_user, :amount, :integer
43
- assert_select 'input[min=11]'
43
+ assert_select 'input[min="11"]'
44
44
  end
45
45
 
46
46
  test 'input infers min value from integer attributes with greater than or equal to validation using symbol' do
47
47
  with_input_for @validating_user, :attempts, :float
48
- assert_select 'input[min=1]'
48
+ assert_select 'input[min="1"]'
49
49
 
50
50
  with_input_for @validating_user, :attempts, :integer
51
- assert_select 'input[min=1]'
51
+ assert_select 'input[min="1"]'
52
52
  end
53
53
 
54
54
  test 'input infers min value from integer attributes with greater than validation using proc' do
@@ -56,15 +56,15 @@ class NumericInputTest < ActionView::TestCase
56
56
  assert_no_select 'input[min]'
57
57
 
58
58
  with_input_for @other_validating_user, :amount, :integer
59
- assert_select 'input[min=20]'
59
+ assert_select 'input[min="20"]'
60
60
  end
61
61
 
62
62
  test 'input infers min value from integer attributes with greater than or equal to validation using proc' do
63
63
  with_input_for @other_validating_user, :attempts, :float
64
- assert_select 'input[min=19]'
64
+ assert_select 'input[min="19"]'
65
65
 
66
66
  with_input_for @other_validating_user, :attempts, :integer
67
- assert_select 'input[min=19]'
67
+ assert_select 'input[min="19"]'
68
68
  end
69
69
 
70
70
  test 'input infers max value from attributes with less than validation' do
@@ -72,7 +72,7 @@ class NumericInputTest < ActionView::TestCase
72
72
  assert_no_select 'input[max]'
73
73
 
74
74
  with_input_for @other_validating_user, :age, :integer
75
- assert_select 'input[max=99]'
75
+ assert_select 'input[max="99"]'
76
76
  end
77
77
 
78
78
  test 'input infers max value from attributes with less than validation using symbol' do
@@ -80,15 +80,15 @@ class NumericInputTest < ActionView::TestCase
80
80
  assert_no_select 'input[max]'
81
81
 
82
82
  with_input_for @validating_user, :amount, :integer
83
- assert_select 'input[max=99]'
83
+ assert_select 'input[max="99"]'
84
84
  end
85
85
 
86
86
  test 'input infers max value from attributes with less than or equal to validation using symbol' do
87
87
  with_input_for @validating_user, :attempts, :float
88
- assert_select 'input[max=100]'
88
+ assert_select 'input[max="100"]'
89
89
 
90
90
  with_input_for @validating_user, :attempts, :integer
91
- assert_select 'input[max=100]'
91
+ assert_select 'input[max="100"]'
92
92
  end
93
93
 
94
94
  test 'input infers max value from attributes with less than validation using proc' do
@@ -96,15 +96,15 @@ class NumericInputTest < ActionView::TestCase
96
96
  assert_no_select 'input[max]'
97
97
 
98
98
  with_input_for @other_validating_user, :amount, :integer
99
- assert_select 'input[max=118]'
99
+ assert_select 'input[max="118"]'
100
100
  end
101
101
 
102
102
  test 'input infers max value from attributes with less than or equal to validation using proc' do
103
103
  with_input_for @other_validating_user, :attempts, :float
104
- assert_select 'input[max=119]'
104
+ assert_select 'input[max="119"]'
105
105
 
106
106
  with_input_for @other_validating_user, :attempts, :integer
107
- assert_select 'input[max=119]'
107
+ assert_select 'input[max="119"]'
108
108
  end
109
109
 
110
110
  test 'input has step value of any except for integer attribute' do
@@ -112,7 +112,7 @@ class NumericInputTest < ActionView::TestCase
112
112
  assert_select 'input[step="any"]'
113
113
 
114
114
  with_input_for @validating_user, :age, :integer
115
- assert_select 'input[step=1]'
115
+ assert_select 'input[step="1"]'
116
116
  end
117
117
 
118
118
  test 'numeric input does not generate placeholder by default' do
@@ -122,7 +122,7 @@ class NumericInputTest < ActionView::TestCase
122
122
 
123
123
  test 'numeric input accepts the placeholder option' do
124
124
  with_input_for @user, :age, :integer, placeholder: 'Put in your age'
125
- assert_select 'input.integer[placeholder=Put in your age]'
125
+ assert_select 'input.integer[placeholder="Put in your age"]'
126
126
  end
127
127
 
128
128
  test 'numeric input uses i18n to translate placeholder text' do
@@ -130,7 +130,7 @@ class NumericInputTest < ActionView::TestCase
130
130
  age: 'Age goes here'
131
131
  } } }) do
132
132
  with_input_for @user, :age, :integer
133
- assert_select 'input.integer[placeholder=Age goes here]'
133
+ assert_select 'input.integer[placeholder="Age goes here"]'
134
134
  end
135
135
  end
136
136
 
@@ -156,12 +156,12 @@ class NumericInputTest < ActionView::TestCase
156
156
  [:integer, :float, :decimal].each do |type|
157
157
  test "#{type} input infers min value from attributes with greater than or equal validation" do
158
158
  with_input_for @validating_user, :age, type
159
- assert_select 'input[min=18]'
159
+ assert_select 'input[min="18"]'
160
160
  end
161
161
 
162
162
  test "#{type} input infers the max value from attributes with less than or equal to validation" do
163
163
  with_input_for @validating_user, :age, type
164
- assert_select 'input[max=99]'
164
+ assert_select 'input[max="99"]'
165
165
  end
166
166
  end
167
167