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.
- data/CHANGELOG.md +6 -54
- data/README.md +129 -111
- data/lib/generators/simple_form/install_generator.rb +4 -4
- data/lib/generators/simple_form/templates/README +2 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +8 -11
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +16 -16
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +3 -3
- data/lib/simple_form.rb +31 -47
- data/lib/simple_form/action_view_extensions/builder.rb +0 -319
- data/lib/simple_form/action_view_extensions/builder.rb.orig +247 -0
- data/lib/simple_form/action_view_extensions/form_helper.rb +1 -1
- data/lib/simple_form/components.rb +1 -1
- data/lib/simple_form/components/errors.rb +1 -7
- data/lib/simple_form/components/hints.rb +2 -7
- data/lib/simple_form/components/html5.rb +1 -1
- data/lib/simple_form/components/labels.rb +4 -4
- data/lib/simple_form/components/maxlength.rb +1 -8
- data/lib/simple_form/error_notification.rb +2 -2
- data/lib/simple_form/form_builder.rb +144 -46
- data/lib/simple_form/form_builder.rb.orig +486 -0
- data/lib/simple_form/helpers.rb +1 -1
- data/lib/simple_form/inputs/base.rb +3 -10
- data/lib/simple_form/inputs/block_input.rb +1 -1
- data/lib/simple_form/inputs/boolean_input.rb +6 -6
- data/lib/simple_form/inputs/collection_input.rb +7 -7
- data/lib/simple_form/inputs/numeric_input.rb +0 -6
- data/lib/simple_form/inputs/password_input.rb +0 -1
- data/lib/simple_form/inputs/string_input.rb +0 -1
- data/lib/simple_form/railtie.rb +7 -0
- data/lib/simple_form/tags.rb +61 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/version.rb.orig +7 -0
- data/lib/simple_form/wrappers.rb +1 -1
- data/lib/simple_form/wrappers/builder.rb +5 -29
- data/lib/simple_form/wrappers/many.rb +1 -1
- data/lib/simple_form/wrappers/root.rb +1 -1
- data/test/action_view_extensions/builder_test.rb +67 -87
- data/test/action_view_extensions/form_helper_test.rb +16 -16
- data/test/components/label_test.rb +46 -46
- data/test/form_builder/association_test.rb +23 -23
- data/test/form_builder/button_test.rb +4 -4
- data/test/form_builder/error_notification_test.rb +8 -8
- data/test/form_builder/error_test.rb +18 -65
- data/test/form_builder/general_test.rb +45 -65
- data/test/form_builder/hint_test.rb +23 -29
- data/test/form_builder/input_field_test.rb +12 -12
- data/test/form_builder/label_test.rb +6 -16
- data/test/form_builder/wrapper_test.rb +21 -21
- data/test/inputs/boolean_input_test.rb +23 -35
- data/test/inputs/collection_check_boxes_input_test.rb +55 -55
- data/test/inputs/collection_radio_buttons_input_test.rb +70 -79
- data/test/inputs/collection_select_input_test.rb +45 -51
- data/test/inputs/datetime_input_test.rb +11 -11
- data/test/inputs/disabled_test.rb +10 -10
- data/test/inputs/discovery_test.rb +4 -4
- data/test/inputs/file_input_test.rb +1 -1
- data/test/inputs/general_test.rb +12 -12
- data/test/inputs/grouped_collection_select_input_test.rb +20 -20
- data/test/inputs/hidden_input_test.rb +1 -1
- data/test/inputs/numeric_input_test.rb +3 -3
- data/test/inputs/priority_input_test.rb +3 -3
- data/test/inputs/readonly_test.rb +12 -12
- data/test/inputs/required_test.rb +5 -5
- data/test/inputs/string_input_test.rb +10 -25
- data/test/inputs/text_input_test.rb +1 -1
- data/test/support/misc_helpers.rb +24 -24
- data/test/support/mock_controller.rb +6 -6
- data/test/support/models.rb +37 -46
- data/test/test_helper.rb +20 -20
- metadata +49 -24
- checksums.yaml +0 -7
- 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, :
|
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, :
|
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, :
|
33
|
-
:
|
32
|
+
store_translations(:en, simple_form: { options: { defaults: {
|
33
|
+
gender: { male: 'Male', female: 'Female'}
|
34
34
|
} } } ) do
|
35
|
-
with_input_for @user, :gender, :select, :
|
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, :
|
44
|
-
:
|
43
|
+
store_translations(:en, simple_form: { options: { user: {
|
44
|
+
gender: { male: 'Male', female: 'Female'}
|
45
45
|
} } } ) do
|
46
|
-
with_input_for @user, :gender, :select, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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(:
|
116
|
-
with_input_for @user, :description, :select, :
|
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, :
|
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, :
|
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
|
-
:
|
140
|
-
:
|
141
|
-
:
|
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
|
-
:
|
149
|
-
:
|
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
|
-
:
|
157
|
-
:
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
201
|
-
:
|
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, :
|
209
|
-
:
|
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, :
|
217
|
-
:
|
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, :
|
225
|
-
:
|
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, :
|
233
|
-
:
|
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, :
|
242
|
-
:
|
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
|
-
:
|
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, :
|
34
|
-
:
|
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, :
|
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, :
|
58
|
-
:
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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, :
|
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
|