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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +27 -10
- data/lib/generators/simple_form/install_generator.rb +2 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +3 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +8 -1
- data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +85 -4
- data/lib/simple_form.rb +13 -2
- data/lib/simple_form/action_view_extensions/builder.rb +1 -0
- data/lib/simple_form/action_view_extensions/form_helper.rb +5 -1
- data/lib/simple_form/components/errors.rb +3 -5
- data/lib/simple_form/form_builder.rb +5 -4
- data/lib/simple_form/inputs/boolean_input.rb +1 -1
- data/lib/simple_form/inputs/collection_input.rb +2 -4
- data/lib/simple_form/tags.rb +2 -4
- data/lib/simple_form/version.rb +1 -1
- data/test/action_view_extensions/builder_test.rb +31 -31
- data/test/action_view_extensions/form_helper_test.rb +20 -1
- data/test/components/label_test.rb +1 -1
- data/test/form_builder/association_test.rb +37 -37
- data/test/form_builder/button_test.rb +5 -5
- data/test/form_builder/error_test.rb +70 -11
- data/test/form_builder/general_test.rb +24 -4
- data/test/form_builder/hint_test.rb +3 -3
- data/test/form_builder/input_field_test.rb +43 -3
- data/test/form_builder/label_test.rb +1 -1
- data/test/form_builder/wrapper_test.rb +18 -3
- data/test/generators/simple_form_generator_test.rb +2 -2
- data/test/inputs/boolean_input_test.rb +9 -1
- data/test/inputs/collection_check_boxes_input_test.rb +22 -0
- data/test/inputs/collection_radio_buttons_input_test.rb +25 -3
- data/test/inputs/collection_select_input_test.rb +17 -17
- data/test/inputs/datetime_input_test.rb +1 -1
- data/test/inputs/grouped_collection_select_input_test.rb +8 -8
- data/test/inputs/numeric_input_test.rb +19 -19
- data/test/inputs/priority_input_test.rb +6 -6
- data/test/inputs/string_input_test.rb +10 -10
- data/test/inputs/text_input_test.rb +3 -3
- data/test/support/misc_helpers.rb +6 -0
- data/test/support/models.rb +11 -1
- data/test/test_helper.rb +5 -1
- metadata +4 -4
@@ -13,6 +13,25 @@ class FormHelperTest < ActionView::TestCase
|
|
13
13
|
assert_select 'form.simple_form'
|
14
14
|
end
|
15
15
|
|
16
|
+
test 'SimpleForm allows overriding default form class' do
|
17
|
+
swap SimpleForm, default_form_class: "my_custom_class" do
|
18
|
+
with_concat_form_for :user, html: { class: "override_class" }
|
19
|
+
assert_no_select 'form.my_custom_class'
|
20
|
+
assert_select 'form.override_class'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Remove this test when SimpleForm.form_class is removed in 4.x
|
25
|
+
test 'SimpleForm allows overriding default form class, but not form class' do
|
26
|
+
ActiveSupport::Deprecation.silence do
|
27
|
+
swap SimpleForm, form_class: "fixed_class", default_form_class: "my_custom_class" do
|
28
|
+
with_concat_form_for :user, html: { class: "override_class" }
|
29
|
+
assert_no_select 'form.my_custom_class'
|
30
|
+
assert_select 'form.fixed_class.override_class'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
16
35
|
test 'SimpleForm uses default browser validations by default' do
|
17
36
|
with_concat_form_for(:user)
|
18
37
|
assert_no_select 'form[novalidate]'
|
@@ -87,7 +106,7 @@ class FormHelperTest < ActionView::TestCase
|
|
87
106
|
test 'passes options to SimpleForm' do
|
88
107
|
with_concat_form_for(:user, url: '/account', html: { id: 'my_form' })
|
89
108
|
assert_select 'form#my_form'
|
90
|
-
assert_select 'form[action
|
109
|
+
assert_select 'form[action="/account"]'
|
91
110
|
end
|
92
111
|
|
93
112
|
test 'form_for yields an instance of FormBuilder' do
|
@@ -244,7 +244,7 @@ class IsolatedLabelTest < ActionView::TestCase
|
|
244
244
|
test 'label uses i18n to find required text' do
|
245
245
|
store_translations(:en, simple_form: { required: { text: 'campo requerido' } }) do
|
246
246
|
with_label_for @user, :name, :string
|
247
|
-
assert_select 'form label abbr[title=campo requerido]', '*'
|
247
|
+
assert_select 'form label abbr[title="campo requerido"]', '*'
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
@@ -46,9 +46,9 @@ class AssociationTest < ActionView::TestCase
|
|
46
46
|
|
47
47
|
with_association_for @user, :tags
|
48
48
|
assert_select 'form select.select#user_tag_ids'
|
49
|
-
assert_select 'form select option[value=1]', 'Tag 1'
|
50
|
-
assert_select 'form select option[value=2]', 'Tag 2'
|
51
|
-
assert_select 'form select option[value=3]', 'Tag 3'
|
49
|
+
assert_select 'form select option[value="1"]', 'Tag 1'
|
50
|
+
assert_select 'form select option[value="2"]', 'Tag 2'
|
51
|
+
assert_select 'form select option[value="3"]', 'Tag 3'
|
52
52
|
|
53
53
|
value.verify
|
54
54
|
end
|
@@ -59,9 +59,9 @@ class AssociationTest < ActionView::TestCase
|
|
59
59
|
|
60
60
|
with_association_for @user, :tags, preload: false
|
61
61
|
assert_select 'form select.select#user_tag_ids'
|
62
|
-
assert_select 'form select option[value=1]', 'Tag 1'
|
63
|
-
assert_select 'form select option[value=2]', 'Tag 2'
|
64
|
-
assert_select 'form select option[value=3]', 'Tag 3'
|
62
|
+
assert_select 'form select option[value="1"]', 'Tag 1'
|
63
|
+
assert_select 'form select option[value="2"]', 'Tag 2'
|
64
|
+
assert_select 'form select option[value="3"]', 'Tag 3'
|
65
65
|
|
66
66
|
assert_raises MockExpectationError do
|
67
67
|
value.verify
|
@@ -74,9 +74,9 @@ class AssociationTest < ActionView::TestCase
|
|
74
74
|
|
75
75
|
with_association_for @user, :company
|
76
76
|
assert_select 'form select.select#user_company_id'
|
77
|
-
assert_select 'form select option[value=1]', 'Company 1'
|
78
|
-
assert_select 'form select option[value=2]', 'Company 2'
|
79
|
-
assert_select 'form select option[value=3]', 'Company 3'
|
77
|
+
assert_select 'form select option[value="1"]', 'Company 1'
|
78
|
+
assert_select 'form select option[value="2"]', 'Company 2'
|
79
|
+
assert_select 'form select option[value="3"]', 'Company 3'
|
80
80
|
|
81
81
|
assert_raises MockExpectationError do
|
82
82
|
value.verify
|
@@ -87,15 +87,15 @@ class AssociationTest < ActionView::TestCase
|
|
87
87
|
test 'builder creates a select for belongs_to associations' do
|
88
88
|
with_association_for @user, :company
|
89
89
|
assert_select 'form select.select#user_company_id'
|
90
|
-
assert_select 'form select option[value=1]', 'Company 1'
|
91
|
-
assert_select 'form select option[value=2]', 'Company 2'
|
92
|
-
assert_select 'form select option[value=3]', 'Company 3'
|
90
|
+
assert_select 'form select option[value="1"]', 'Company 1'
|
91
|
+
assert_select 'form select option[value="2"]', 'Company 2'
|
92
|
+
assert_select 'form select option[value="3"]', 'Company 3'
|
93
93
|
end
|
94
94
|
|
95
95
|
test 'builder creates blank select if collection is nil' do
|
96
96
|
with_association_for @user, :company, collection: nil
|
97
97
|
assert_select 'form select.select#user_company_id'
|
98
|
-
assert_no_select 'form select option[value=1]', 'Company 1'
|
98
|
+
assert_no_select 'form select option[value="1"]', 'Company 1'
|
99
99
|
end
|
100
100
|
|
101
101
|
test 'builder allows collection radio for belongs_to associations' do
|
@@ -108,17 +108,17 @@ class AssociationTest < ActionView::TestCase
|
|
108
108
|
test 'builder allows collection to have a proc as a condition' do
|
109
109
|
with_association_for @user, :extra_special_company
|
110
110
|
assert_select 'form select.select#user_extra_special_company_id'
|
111
|
-
assert_select 'form select option[value=1]'
|
112
|
-
assert_no_select 'form select option[value=2]'
|
113
|
-
assert_no_select 'form select option[value=3]'
|
111
|
+
assert_select 'form select option[value="1"]'
|
112
|
+
assert_no_select 'form select option[value="2"]'
|
113
|
+
assert_no_select 'form select option[value="3"]'
|
114
114
|
end
|
115
115
|
|
116
116
|
test 'builder allows collection to have a scope' do
|
117
117
|
with_association_for @user, :special_pictures
|
118
118
|
assert_select 'form select.select#user_special_picture_ids'
|
119
|
-
assert_select 'form select option[value=3]', '3'
|
120
|
-
assert_no_select 'form select option[value=1]'
|
121
|
-
assert_no_select 'form select option[value=2]'
|
119
|
+
assert_select 'form select option[value="3"]', '3'
|
120
|
+
assert_no_select 'form select option[value="1"]'
|
121
|
+
assert_no_select 'form select option[value="2"]'
|
122
122
|
end
|
123
123
|
|
124
124
|
test 'builder marks the record which already belongs to the user' do
|
@@ -133,17 +133,17 @@ class AssociationTest < ActionView::TestCase
|
|
133
133
|
test 'builder uses reflection conditions to find collection' do
|
134
134
|
with_association_for @user, :special_company
|
135
135
|
assert_select 'form select.select#user_special_company_id'
|
136
|
-
assert_select 'form select option[value=1]'
|
137
|
-
assert_no_select 'form select option[value=2]'
|
138
|
-
assert_no_select 'form select option[value=3]'
|
136
|
+
assert_select 'form select option[value="1"]'
|
137
|
+
assert_no_select 'form select option[value="2"]'
|
138
|
+
assert_no_select 'form select option[value="3"]'
|
139
139
|
end
|
140
140
|
|
141
141
|
test 'builder allows overriding collection to association input' do
|
142
142
|
with_association_for @user, :company, include_blank: false,
|
143
143
|
collection: [Company.new(999, 'Teste')]
|
144
144
|
assert_select 'form select.select#user_company_id'
|
145
|
-
assert_no_select 'form select option[value=1]'
|
146
|
-
assert_select 'form select option[value=999]', 'Teste'
|
145
|
+
assert_no_select 'form select option[value="1"]'
|
146
|
+
assert_select 'form select option[value="999"]', 'Teste'
|
147
147
|
assert_select 'form select option', count: 1
|
148
148
|
end
|
149
149
|
|
@@ -158,31 +158,31 @@ class AssociationTest < ActionView::TestCase
|
|
158
158
|
with_association_for @user, :pictures
|
159
159
|
assert_select 'form select.select#user_picture_ids'
|
160
160
|
assert_select 'form select[multiple=multiple]'
|
161
|
-
assert_select 'form select option[value=1]', 'Picture 1'
|
162
|
-
assert_select 'form select option[value=2]', 'Picture 2'
|
163
|
-
assert_select 'form select option[value=3]', 'Picture 3'
|
161
|
+
assert_select 'form select option[value="1"]', 'Picture 1'
|
162
|
+
assert_select 'form select option[value="2"]', 'Picture 2'
|
163
|
+
assert_select 'form select option[value="3"]', 'Picture 3'
|
164
164
|
end
|
165
165
|
|
166
166
|
test 'builder creates a select with multiple options for collection associations' do
|
167
167
|
with_association_for @user, :tags
|
168
168
|
assert_select 'form select.select#user_tag_ids'
|
169
169
|
assert_select 'form select[multiple=multiple]'
|
170
|
-
assert_select 'form select option[value=1]', 'Tag 1'
|
171
|
-
assert_select 'form select option[value=2]', 'Tag 2'
|
172
|
-
assert_select 'form select option[value=3]', 'Tag 3'
|
170
|
+
assert_select 'form select option[value="1"]', 'Tag 1'
|
171
|
+
assert_select 'form select option[value="2"]', 'Tag 2'
|
172
|
+
assert_select 'form select option[value="3"]', 'Tag 3'
|
173
173
|
end
|
174
174
|
|
175
175
|
test 'builder allows size to be overwritten for collection associations' do
|
176
176
|
with_association_for @user, :tags, input_html: { size: 10 }
|
177
|
-
assert_select 'form select[multiple=multiple][size=10]'
|
177
|
+
assert_select 'form select[multiple=multiple][size="10"]'
|
178
178
|
end
|
179
179
|
|
180
180
|
test 'builder marks all selected records which already belongs to user' do
|
181
181
|
@user.tag_ids = [1, 2]
|
182
182
|
with_association_for @user, :tags
|
183
|
-
assert_select 'form select option[value=1][selected=selected]'
|
184
|
-
assert_select 'form select option[value=2][selected=selected]'
|
185
|
-
assert_no_select 'form select option[value=3][selected=selected]'
|
183
|
+
assert_select 'form select option[value="1"][selected=selected]'
|
184
|
+
assert_select 'form select option[value="2"][selected=selected]'
|
185
|
+
assert_no_select 'form select option[value="3"][selected=selected]'
|
186
186
|
end
|
187
187
|
|
188
188
|
test 'builder allows a collection of check boxes for collection associations' do
|
@@ -196,9 +196,9 @@ class AssociationTest < ActionView::TestCase
|
|
196
196
|
test 'builder marks all selected records for collection boxes' do
|
197
197
|
@user.tag_ids = [1, 2]
|
198
198
|
with_association_for @user, :tags, as: :check_boxes
|
199
|
-
assert_select 'form input[type=checkbox][value=1][checked=checked]'
|
200
|
-
assert_select 'form input[type=checkbox][value=2][checked=checked]'
|
201
|
-
assert_no_select 'form input[type=checkbox][value=3][checked=checked]'
|
199
|
+
assert_select 'form input[type=checkbox][value="1"][checked=checked]'
|
200
|
+
assert_select 'form input[type=checkbox][value="2"][checked=checked]'
|
201
|
+
assert_no_select 'form input[type=checkbox][value="3"][checked=checked]'
|
202
202
|
end
|
203
203
|
|
204
204
|
test 'builder with collection support giving collection and item wrapper tags' do
|
@@ -10,31 +10,31 @@ class ButtonTest < ActionView::TestCase
|
|
10
10
|
|
11
11
|
test 'builder creates buttons' do
|
12
12
|
with_button_for :post, :submit
|
13
|
-
assert_select 'form input.button[type=submit][value=Save Post]'
|
13
|
+
assert_select 'form input.button[type=submit][value="Save Post"]'
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'builder creates buttons with options' do
|
17
17
|
with_button_for :post, :submit, class: 'my_button'
|
18
|
-
assert_select 'form input.button.my_button[type=submit][value=Save Post]'
|
18
|
+
assert_select 'form input.button.my_button[type=submit][value="Save Post"]'
|
19
19
|
end
|
20
20
|
|
21
21
|
test 'builder does not modify the options hash' do
|
22
22
|
options = { class: 'my_button' }
|
23
23
|
with_button_for :post, :submit, options
|
24
|
-
assert_select 'form input.button.my_button[type=submit][value=Save Post]'
|
24
|
+
assert_select 'form input.button.my_button[type=submit][value="Save Post"]'
|
25
25
|
assert_equal({ class: 'my_button' }, options)
|
26
26
|
end
|
27
27
|
|
28
28
|
test 'builder creates buttons for records' do
|
29
29
|
@user.new_record!
|
30
30
|
with_button_for @user, :submit
|
31
|
-
assert_select 'form input.button[type=submit][value=Create User]'
|
31
|
+
assert_select 'form input.button[type=submit][value="Create User"]'
|
32
32
|
end
|
33
33
|
|
34
34
|
test "builder uses the default class from the configuration" do
|
35
35
|
swap SimpleForm, button_class: 'btn' do
|
36
36
|
with_button_for :post, :submit
|
37
|
-
assert_select 'form input.btn[type=submit][value=Save Post]'
|
37
|
+
assert_select 'form input.btn[type=submit][value="Save Post"]'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -32,7 +32,7 @@ class ErrorTest < ActionView::TestCase
|
|
32
32
|
|
33
33
|
test 'error generates messages for attribute with single error' do
|
34
34
|
with_error_for @user, :name
|
35
|
-
assert_select 'span.error', "
|
35
|
+
assert_select 'span.error', "cannot be blank"
|
36
36
|
end
|
37
37
|
|
38
38
|
test 'error generates messages for attribute with one error when using first' do
|
@@ -82,12 +82,22 @@ class ErrorTest < ActionView::TestCase
|
|
82
82
|
|
83
83
|
test 'error escapes error prefix text' do
|
84
84
|
with_error_for @user, :name, error_prefix: '<b>Name</b>'
|
85
|
-
|
85
|
+
assert_no_select 'span.error b'
|
86
86
|
end
|
87
87
|
|
88
|
+
test 'error escapes error text' do
|
89
|
+
@user.errors.add(:action, 'must not contain <b>markup</b>')
|
90
|
+
|
91
|
+
with_error_for @user, :action
|
92
|
+
|
93
|
+
assert_select 'span.error'
|
94
|
+
assert_no_select 'span.error b', 'markup'
|
95
|
+
end
|
96
|
+
|
97
|
+
|
88
98
|
test 'error generates an error message with raw HTML tags' do
|
89
99
|
with_error_for @user, :name, error_prefix: '<b>Name</b>'.html_safe
|
90
|
-
assert_select 'span.error', "Name
|
100
|
+
assert_select 'span.error', "Name cannot be blank"
|
91
101
|
assert_select 'span.error b', "Name"
|
92
102
|
end
|
93
103
|
|
@@ -95,7 +105,7 @@ class ErrorTest < ActionView::TestCase
|
|
95
105
|
|
96
106
|
test 'full error generates a full error tag for the attribute' do
|
97
107
|
with_full_error_for @user, :name
|
98
|
-
assert_select 'span.error', "Super User Name!
|
108
|
+
assert_select 'span.error', "Super User Name! cannot be blank"
|
99
109
|
end
|
100
110
|
|
101
111
|
test 'full error generates a full error tag with a clean HTML' do
|
@@ -105,22 +115,31 @@ class ErrorTest < ActionView::TestCase
|
|
105
115
|
|
106
116
|
test 'full error allows passing options to full error tag' do
|
107
117
|
with_full_error_for @user, :name, id: 'name_error', error_prefix: "Your name"
|
108
|
-
assert_select 'span.error#name_error', "Your name
|
118
|
+
assert_select 'span.error#name_error', "Your name cannot be blank"
|
109
119
|
end
|
110
120
|
|
111
121
|
test 'full error does not modify the options hash' do
|
112
122
|
options = { id: 'name_error' }
|
113
123
|
with_full_error_for @user, :name, options
|
114
|
-
assert_select 'span.error#name_error', "Super User Name!
|
124
|
+
assert_select 'span.error#name_error', "Super User Name! cannot be blank"
|
115
125
|
assert_equal({ id: 'name_error' }, options)
|
116
126
|
end
|
117
127
|
|
128
|
+
test 'full error escapes error text' do
|
129
|
+
@user.errors.add(:action, 'must not contain <b>markup</b>')
|
130
|
+
|
131
|
+
with_full_error_for @user, :action
|
132
|
+
|
133
|
+
assert_select 'span.error'
|
134
|
+
assert_no_select 'span.error b', 'markup'
|
135
|
+
end
|
136
|
+
|
118
137
|
# CUSTOM WRAPPERS
|
119
138
|
|
120
139
|
test 'error with custom wrappers works' do
|
121
140
|
swap_wrapper do
|
122
141
|
with_error_for @user, :name
|
123
|
-
assert_select 'span.omg_error', "
|
142
|
+
assert_select 'span.omg_error', "cannot be blank"
|
124
143
|
end
|
125
144
|
end
|
126
145
|
|
@@ -133,6 +152,14 @@ class ErrorTest < ActionView::TestCase
|
|
133
152
|
end
|
134
153
|
end
|
135
154
|
|
155
|
+
test 'full error finds errors on association with reflection' do
|
156
|
+
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
157
|
+
with_form_for @user, :company_id, as: :select,
|
158
|
+
reflection: Association.new(Company, :company, {})
|
159
|
+
assert_select 'span.error', 'Company must be valid'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
136
163
|
test 'full error can be disabled' do
|
137
164
|
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
138
165
|
with_form_for @user, :company_id, as: :select, full_error: false
|
@@ -150,7 +177,7 @@ class ErrorTest < ActionView::TestCase
|
|
150
177
|
# CUSTOM ERRORS
|
151
178
|
|
152
179
|
test 'input with custom error works' do
|
153
|
-
error_text = "Super User Name!
|
180
|
+
error_text = "Super User Name! cannot be blank"
|
154
181
|
with_form_for @user, :name, error: error_text
|
155
182
|
|
156
183
|
assert_select 'span.error', error_text
|
@@ -159,24 +186,56 @@ class ErrorTest < ActionView::TestCase
|
|
159
186
|
test 'input with error option as true does not use custom error' do
|
160
187
|
with_form_for @user, :name, error: true
|
161
188
|
|
162
|
-
assert_select 'span.error', "
|
189
|
+
assert_select 'span.error', "cannot be blank"
|
163
190
|
end
|
164
191
|
|
165
192
|
test 'input with custom error does not generate the error if there is no error on the attribute' do
|
166
|
-
with_form_for @user, :active, error: "Super User Active!
|
193
|
+
with_form_for @user, :active, error: "Super User Active! cannot be blank"
|
167
194
|
|
168
195
|
assert_no_select 'span.error'
|
169
196
|
end
|
170
197
|
|
171
198
|
test 'input with custom error works when using full_error component' do
|
172
199
|
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
173
|
-
error_text = "Super User Name!
|
200
|
+
error_text = "Super User Name! cannot be blank"
|
174
201
|
with_form_for @user, :name, error: error_text
|
175
202
|
|
176
203
|
assert_select 'span.error', error_text
|
177
204
|
end
|
178
205
|
end
|
179
206
|
|
207
|
+
test 'input with custom error escapes the error text' do
|
208
|
+
with_form_for @user, :name, error: 'error must not contain <b>markup</b>'
|
209
|
+
|
210
|
+
assert_select 'span.error'
|
211
|
+
assert_no_select 'span.error b', 'markup'
|
212
|
+
end
|
213
|
+
|
214
|
+
test 'input with custom error does not escape the error text if it is safe' do
|
215
|
+
with_form_for @user, :name, error: 'error must contain <b>markup</b>'.html_safe
|
216
|
+
|
217
|
+
assert_select 'span.error'
|
218
|
+
assert_select 'span.error b', 'markup'
|
219
|
+
end
|
220
|
+
|
221
|
+
test 'input with custom error escapes the error text using full_error component' do
|
222
|
+
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
223
|
+
with_form_for @user, :name, error: 'error must not contain <b>markup</b>'
|
224
|
+
|
225
|
+
assert_select 'span.error'
|
226
|
+
assert_no_select 'span.error b', 'markup'
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
test 'input with custom error does not escape the error text if it is safe using full_error component' do
|
231
|
+
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
232
|
+
with_form_for @user, :name, error: 'error must contain <b>markup</b>'.html_safe
|
233
|
+
|
234
|
+
assert_select 'span.error'
|
235
|
+
assert_select 'span.error b', 'markup'
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
180
239
|
test 'input with custom error when using full_error component does not generate the error if there is no error on the attribute' do
|
181
240
|
swap_wrapper :default, self.custom_wrapper_with_full_error do
|
182
241
|
with_form_for @user, :active, error: "Super User Active! can't be blank"
|
@@ -217,10 +217,30 @@ class FormBuilderTest < ActionView::TestCase
|
|
217
217
|
end
|
218
218
|
|
219
219
|
# COMMON OPTIONS
|
220
|
+
# Remove this test when SimpleForm.form_class is removed in 4.x
|
220
221
|
test 'builder adds chosen form class' do
|
221
|
-
|
222
|
+
ActiveSupport::Deprecation.silence do
|
223
|
+
swap SimpleForm, form_class: :my_custom_class do
|
224
|
+
with_form_for @user, :name
|
225
|
+
assert_select 'form.my_custom_class'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Remove this test when SimpleForm.form_class is removed in 4.x
|
231
|
+
test 'builder adds chosen form class and default form class' do
|
232
|
+
ActiveSupport::Deprecation.silence do
|
233
|
+
swap SimpleForm, form_class: "my_custom_class", default_form_class: "my_default_class" do
|
234
|
+
with_form_for @user, :name
|
235
|
+
assert_select 'form.my_custom_class.my_default_class'
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
test 'builder adds default form class' do
|
241
|
+
swap SimpleForm, default_form_class: "default_class" do
|
222
242
|
with_form_for @user, :name
|
223
|
-
assert_select 'form.
|
243
|
+
assert_select 'form.default_class'
|
224
244
|
end
|
225
245
|
end
|
226
246
|
|
@@ -307,7 +327,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
307
327
|
|
308
328
|
test 'builder generates errors for attribute with errors' do
|
309
329
|
with_form_for @user, :name
|
310
|
-
assert_select 'span.error', "
|
330
|
+
assert_select 'span.error', "cannot be blank"
|
311
331
|
end
|
312
332
|
|
313
333
|
test 'builder is able to disable showing errors for an input' do
|
@@ -317,7 +337,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
317
337
|
|
318
338
|
test 'builder passes options to errors' do
|
319
339
|
with_form_for @user, :name, error_html: { id: "cool" }
|
320
|
-
assert_select 'span.error#cool', "
|
340
|
+
assert_select 'span.error#cool', "cannot be blank"
|
321
341
|
end
|
322
342
|
|
323
343
|
test 'placeholder does not be generated when set to false' do
|