padrino-helpers 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-helpers.rb +4 -1
- data/lib/padrino-helpers/asset_tag_helpers.rb +17 -14
- data/lib/padrino-helpers/breadcrumb_helpers.rb +6 -6
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +119 -163
- data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +92 -0
- data/lib/padrino-helpers/form_helpers.rb +66 -347
- data/lib/padrino-helpers/form_helpers/errors.rb +138 -0
- data/lib/padrino-helpers/form_helpers/options.rb +97 -0
- data/lib/padrino-helpers/form_helpers/security.rb +70 -0
- data/lib/padrino-helpers/output_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
- data/lib/padrino-helpers/render_helpers.rb +10 -9
- data/lib/padrino-helpers/tag_helpers.rb +2 -1
- data/lib/padrino/rendering.rb +378 -0
- data/lib/padrino/rendering/extensions/erubis.rb +74 -0
- data/lib/padrino/rendering/extensions/haml.rb +29 -0
- data/lib/padrino/rendering/extensions/slim.rb +21 -0
- data/padrino-helpers.gemspec +2 -1
- data/test/fixtures/apps/.components +6 -0
- data/test/fixtures/apps/.gitignore +7 -0
- data/test/fixtures/apps/render.rb +25 -0
- data/test/fixtures/apps/views/article/comment/show.slim +1 -0
- data/test/fixtures/apps/views/blog/post.erb +1 -0
- data/test/fixtures/apps/views/layouts/specific.erb +1 -0
- data/test/fixtures/apps/views/test/post.erb +1 -0
- data/test/fixtures/layouts/layout.erb +1 -0
- data/test/fixtures/markup_app/app.rb +0 -1
- data/test/fixtures/render_app/app.rb +25 -1
- data/test/fixtures/render_app/views/_unsafe.html.builder +2 -0
- data/test/fixtures/render_app/views/_unsafe_object.html.builder +2 -0
- data/test/fixtures/render_app/views/ruby_block_capture_erb.erb +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_haml.haml +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_slim.slim +1 -0
- data/test/helper.rb +65 -1
- data/test/test_asset_tag_helpers.rb +83 -79
- data/test/test_breadcrumb_helpers.rb +20 -20
- data/test/test_form_builder.rb +196 -196
- data/test/test_form_helpers.rb +163 -163
- data/test/test_format_helpers.rb +65 -65
- data/test/test_locale.rb +1 -1
- data/test/test_number_helpers.rb +10 -11
- data/test/test_output_helpers.rb +28 -28
- data/test/test_render_helpers.rb +89 -35
- data/test/test_rendering.rb +683 -0
- data/test/test_rendering_extensions.rb +14 -0
- data/test/test_tag_helpers.rb +23 -23
- metadata +57 -5
data/test/test_form_helpers.rb
CHANGED
@@ -12,92 +12,92 @@ describe "FormHelpers" do
|
|
12
12
|
def protect_from_csrf; false; end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
should
|
15
|
+
describe 'for #form_tag method' do
|
16
|
+
it 'should display correct forms in ruby' do
|
17
17
|
actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test', :method => "post") { "Demo" }
|
18
18
|
assert_has_tag(:form, :"accept-charset" => "UTF-8", :class => "test") { actual_html }
|
19
19
|
assert_has_tag('form input', :type => 'hidden', :name => '_method', :count => 0) { actual_html }
|
20
20
|
end
|
21
21
|
|
22
|
-
should
|
22
|
+
it 'should display correct text inputs within form_tag' do
|
23
23
|
actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test') { text_field_tag(:username) }
|
24
24
|
assert_has_tag('form input', :type => 'text', :name => "username") { actual_html }
|
25
25
|
end
|
26
26
|
|
27
|
-
should
|
27
|
+
it 'should display correct form with remote' do
|
28
28
|
actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :remote => true) { "Demo" }
|
29
29
|
assert_has_tag(:form, :class => "put-form", :"accept-charset" => "UTF-8", :"data-remote" => 'true') { actual_html }
|
30
30
|
assert_has_no_tag(:form, "data-method" => 'post') { actual_html }
|
31
31
|
end
|
32
32
|
|
33
|
-
should
|
33
|
+
it 'should display correct form with remote and method is put' do
|
34
34
|
actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :method => 'put', :remote => true) { "Demo" }
|
35
35
|
assert_has_tag(:form, "data-remote" => 'true', :"accept-charset" => "UTF-8") { actual_html }
|
36
36
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
37
37
|
end
|
38
38
|
|
39
|
-
should
|
39
|
+
it 'should display correct form with method :put' do
|
40
40
|
actual_html = form_tag('/update', :"accept-charset" => "UTF-8", :class => 'put-form', :method => "put") { "Demo" }
|
41
41
|
assert_has_tag(:form, :class => "put-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
|
42
42
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
43
43
|
end
|
44
44
|
|
45
|
-
should
|
45
|
+
it 'should display correct form with method :delete and charset' do
|
46
46
|
actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :class => 'delete-form', :method => "delete") { "Demo" }
|
47
47
|
assert_has_tag(:form, :class => "delete-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
|
48
48
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
|
49
49
|
end
|
50
50
|
|
51
|
-
should
|
51
|
+
it 'should display correct form with charset' do
|
52
52
|
actual_html = form_tag('/charset', :"accept-charset" => "UTF-8", :class => 'charset-form') { "Demo" }
|
53
53
|
assert_has_tag(:form, :class => "charset-form", :"accept-charset" => "UTF-8", :method => 'post') { actual_html }
|
54
54
|
end
|
55
55
|
|
56
|
-
should
|
56
|
+
it 'should display correct form with multipart encoding' do
|
57
57
|
actual_html = form_tag('/remove', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
|
58
58
|
assert_has_tag(:form, :enctype => "multipart/form-data") { actual_html }
|
59
59
|
end
|
60
60
|
|
61
|
-
should
|
61
|
+
it 'should have an authenticity_token for method :post, :put or :delete' do
|
62
62
|
%w(post put delete).each do |method|
|
63
63
|
actual_html = form_tag('/modify', :method => method) { "Demo" }
|
64
64
|
assert_has_tag(:input, :name => 'authenticity_token') { actual_html }
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
should
|
68
|
+
it 'should not have an authenticity_token if method: :get' do
|
69
69
|
actual_html = form_tag('/get', :method => :get) { "Demo" }
|
70
70
|
assert_has_no_tag(:input, :name => 'authenticity_token') { actual_html }
|
71
71
|
end
|
72
72
|
|
73
|
-
should
|
73
|
+
it 'should have an authenticity_token by default' do
|
74
74
|
actual_html = form_tag('/superadmindelete') { "Demo" }
|
75
75
|
assert_has_tag(:input, :name => 'authenticity_token') { actual_html }
|
76
76
|
end
|
77
77
|
|
78
|
-
should
|
78
|
+
it 'should create csrf meta tags with token and param - #csrf_meta_tags' do
|
79
79
|
actual_html = csrf_meta_tags
|
80
80
|
assert_has_tag(:meta, :name => 'csrf-param') { actual_html }
|
81
81
|
assert_has_tag(:meta, :name => 'csrf-token') { actual_html }
|
82
82
|
end
|
83
83
|
|
84
|
-
should
|
84
|
+
it 'should have an authenticity_token by default' do
|
85
85
|
actual_html = form_tag('/superadmindelete') { "Demo" }
|
86
86
|
assert_has_tag(:input, :name => 'authenticity_token') { actual_html }
|
87
87
|
end
|
88
88
|
|
89
|
-
should
|
89
|
+
it 'should not have an authenticity_token if passing protect_from_csrf: false' do
|
90
90
|
actual_html = form_tag('/superadmindelete', :protect_from_csrf => false) { "Demo" }
|
91
91
|
assert_has_no_tag(:input, :name => 'authenticity_token') { actual_html }
|
92
92
|
end
|
93
93
|
|
94
|
-
should
|
94
|
+
it 'should not have an authenticity_token if protect_from_csrf is false on app settings' do
|
95
95
|
self.expects(:settings).returns(UnprotectedApp.new)
|
96
96
|
actual_html = form_tag('/superadmindelete') { "Demo" }
|
97
97
|
assert_has_no_tag(:input, :name => 'authenticity_token') { actual_html }
|
98
98
|
end
|
99
99
|
|
100
|
-
should
|
100
|
+
it 'should display correct forms in erb' do
|
101
101
|
visit '/erb/form_tag'
|
102
102
|
assert_have_selector 'form.simple-form', :action => '/simple'
|
103
103
|
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
|
@@ -105,7 +105,7 @@ describe "FormHelpers" do
|
|
105
105
|
assert_have_no_selector 'form.no-protection input', :name => 'authenticity_token'
|
106
106
|
end
|
107
107
|
|
108
|
-
should
|
108
|
+
it 'should display correct forms in haml' do
|
109
109
|
visit '/haml/form_tag'
|
110
110
|
assert_have_selector 'form.simple-form', :action => '/simple'
|
111
111
|
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
|
@@ -113,7 +113,7 @@ describe "FormHelpers" do
|
|
113
113
|
assert_have_no_selector 'form.no-protection input', :name => 'authenticity_token'
|
114
114
|
end
|
115
115
|
|
116
|
-
should
|
116
|
+
it 'should display correct forms in slim' do
|
117
117
|
visit '/slim/form_tag'
|
118
118
|
assert_have_selector 'form.simple-form', :action => '/simple'
|
119
119
|
assert_have_selector 'form.advanced-form', :action => '/advanced', :id => 'advanced', :method => 'get'
|
@@ -122,14 +122,14 @@ describe "FormHelpers" do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
should
|
125
|
+
describe 'for #field_set_tag method' do
|
126
|
+
it 'should display correct field_sets in ruby' do
|
127
127
|
actual_html = field_set_tag("Basic", :class => 'basic') { "Demo" }
|
128
128
|
assert_has_tag(:fieldset, :class => 'basic') { actual_html }
|
129
129
|
assert_has_tag('fieldset legend', :content => "Basic") { actual_html }
|
130
130
|
end
|
131
131
|
|
132
|
-
should
|
132
|
+
it 'should display correct field_sets in erb' do
|
133
133
|
visit '/erb/form_tag'
|
134
134
|
assert_have_selector 'form.simple-form fieldset', :count => 1
|
135
135
|
assert_have_no_selector 'form.simple-form fieldset legend'
|
@@ -137,7 +137,7 @@ describe "FormHelpers" do
|
|
137
137
|
assert_have_selector 'form.advanced-form fieldset legend', :content => "Advanced"
|
138
138
|
end
|
139
139
|
|
140
|
-
should
|
140
|
+
it 'should display correct field_sets in haml' do
|
141
141
|
visit '/haml/form_tag'
|
142
142
|
assert_have_selector 'form.simple-form fieldset', :count => 1
|
143
143
|
assert_have_no_selector 'form.simple-form fieldset legend'
|
@@ -145,7 +145,7 @@ describe "FormHelpers" do
|
|
145
145
|
assert_have_selector 'form.advanced-form fieldset legend', :content => "Advanced"
|
146
146
|
end
|
147
147
|
|
148
|
-
should
|
148
|
+
it 'should display correct field_sets in slim' do
|
149
149
|
visit '/slim/form_tag'
|
150
150
|
assert_have_selector 'form.simple-form fieldset', :count => 1
|
151
151
|
assert_have_no_selector 'form.simple-form fieldset legend'
|
@@ -154,8 +154,8 @@ describe "FormHelpers" do
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
|
158
|
-
should
|
157
|
+
describe 'for #error_messages_for method' do
|
158
|
+
it 'should display correct error messages list in ruby' do
|
159
159
|
user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
|
160
160
|
actual_html = error_messages_for(user)
|
161
161
|
assert_has_tag('div.field-errors') { actual_html }
|
@@ -165,7 +165,7 @@ describe "FormHelpers" do
|
|
165
165
|
assert_has_tag('div.field-errors ul li', :count => 2) { actual_html }
|
166
166
|
end
|
167
167
|
|
168
|
-
should
|
168
|
+
it 'should display correct error messages list in erb' do
|
169
169
|
visit '/erb/form_tag'
|
170
170
|
assert_have_no_selector 'form.simple-form .field-errors'
|
171
171
|
assert_have_selector 'form.advanced-form .field-errors'
|
@@ -179,7 +179,7 @@ describe "FormHelpers" do
|
|
179
179
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
|
180
180
|
end
|
181
181
|
|
182
|
-
should
|
182
|
+
it 'should display correct error messages list in haml' do
|
183
183
|
visit '/haml/form_tag'
|
184
184
|
assert_have_no_selector 'form.simple-form .field-errors'
|
185
185
|
assert_have_selector 'form.advanced-form .field-errors'
|
@@ -193,7 +193,7 @@ describe "FormHelpers" do
|
|
193
193
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
|
194
194
|
end
|
195
195
|
|
196
|
-
should
|
196
|
+
it 'should display correct error messages list in slim' do
|
197
197
|
visit '/slim/form_tag'
|
198
198
|
assert_have_no_selector 'form.simple-form .field-errors'
|
199
199
|
assert_have_selector 'form.advanced-form .field-errors'
|
@@ -208,51 +208,51 @@ describe "FormHelpers" do
|
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
-
|
212
|
-
should
|
211
|
+
describe 'for #error_message_on method' do
|
212
|
+
it 'should display correct error message on specified model name in ruby' do
|
213
213
|
@user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
|
214
214
|
actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
|
215
215
|
assert_has_tag('span.error', :content => "foo 1 bar") { actual_html }
|
216
216
|
end
|
217
217
|
|
218
|
-
should
|
218
|
+
it 'should display correct error message on specified object in ruby' do
|
219
219
|
@bob = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
|
220
220
|
actual_html = error_message_on(@bob, :a, :prepend => "foo", :append => "bar")
|
221
221
|
assert_has_tag('span.error', :content => "foo 1 bar") { actual_html }
|
222
222
|
end
|
223
223
|
|
224
|
-
should
|
224
|
+
it 'should display no message when error is not present' do
|
225
225
|
@user = mock_model("User", :errors => { :a => "1", :b => "2" }, :blank? => false)
|
226
226
|
actual_html = error_message_on(:user, :fake, :prepend => "foo", :append => "bar")
|
227
227
|
assert actual_html.blank?
|
228
228
|
end
|
229
229
|
|
230
|
-
should
|
230
|
+
it 'should display no message when error is not present in an Array' do
|
231
231
|
@user = mock_model("User", :errors => { :a => [], :b => "2" }, :blank? => false)
|
232
232
|
actual_html = error_message_on(:user, :a, :prepend => "foo", :append => "bar")
|
233
233
|
assert actual_html.blank?
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
-
|
238
|
-
should
|
237
|
+
describe 'for #label_tag method' do
|
238
|
+
it 'should display label tag in ruby' do
|
239
239
|
actual_html = label_tag(:username, :class => 'long-label', :caption => "Nickname")
|
240
240
|
assert_has_tag(:label, :for => 'username', :class => 'long-label', :content => "Nickname") { actual_html }
|
241
241
|
end
|
242
242
|
|
243
|
-
should
|
243
|
+
it 'should display label tag in ruby with required' do
|
244
244
|
actual_html = label_tag(:username, :caption => "Nickname", :required => true)
|
245
245
|
assert_has_tag(:label, :for => 'username', :content => 'Nickname') { actual_html }
|
246
246
|
assert_has_tag('label[for=username] span.required', :content => "*") { actual_html }
|
247
247
|
end
|
248
248
|
|
249
|
-
should
|
249
|
+
it 'should display label tag in ruby with a block' do
|
250
250
|
actual_html = label_tag(:admin, :class => 'long-label') { input_tag :checkbox }
|
251
251
|
assert_has_tag(:label, :for => 'admin', :class => 'long-label', :content => "Admin") { actual_html }
|
252
252
|
assert_has_tag('label input[type=checkbox]') { actual_html }
|
253
253
|
end
|
254
254
|
|
255
|
-
should
|
255
|
+
it 'should display label tag in erb for simple form' do
|
256
256
|
visit '/erb/form_tag'
|
257
257
|
assert_have_selector 'form.simple-form label', :count => 9
|
258
258
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
@@ -260,7 +260,7 @@ describe "FormHelpers" do
|
|
260
260
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
261
261
|
end
|
262
262
|
|
263
|
-
should
|
263
|
+
it 'should display label tag in erb for advanced form' do
|
264
264
|
visit '/erb/form_tag'
|
265
265
|
assert_have_selector 'form.advanced-form label', :count => 11
|
266
266
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
@@ -270,7 +270,7 @@ describe "FormHelpers" do
|
|
270
270
|
assert_have_selector 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
|
271
271
|
end
|
272
272
|
|
273
|
-
should
|
273
|
+
it 'should display label tag in haml for simple form' do
|
274
274
|
visit '/haml/form_tag'
|
275
275
|
assert_have_selector 'form.simple-form label', :count => 9
|
276
276
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
@@ -278,7 +278,7 @@ describe "FormHelpers" do
|
|
278
278
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
279
279
|
end
|
280
280
|
|
281
|
-
should
|
281
|
+
it 'should display label tag in haml for advanced form' do
|
282
282
|
visit '/haml/form_tag'
|
283
283
|
assert_have_selector 'form.advanced-form label', :count => 11
|
284
284
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
@@ -288,7 +288,7 @@ describe "FormHelpers" do
|
|
288
288
|
assert_have_selector 'form.advanced-form label.gender', :content => "Gender" , :for => 'gender'
|
289
289
|
end
|
290
290
|
|
291
|
-
should
|
291
|
+
it 'should display label tag in slim for simple form' do
|
292
292
|
visit '/slim/form_tag'
|
293
293
|
assert_have_selector 'form.simple-form label', :count => 9
|
294
294
|
assert_have_selector 'form.simple-form label', :content => "Username", :for => 'username'
|
@@ -296,7 +296,7 @@ describe "FormHelpers" do
|
|
296
296
|
assert_have_selector 'form.simple-form label', :content => "Gender", :for => 'gender'
|
297
297
|
end
|
298
298
|
|
299
|
-
should
|
299
|
+
it 'should display label tag in slim for advanced form' do
|
300
300
|
visit '/slim/form_tag'
|
301
301
|
assert_have_selector 'form.advanced-form label', :count => 11
|
302
302
|
assert_have_selector 'form.advanced-form label.first', :content => "Nickname", :for => 'username'
|
@@ -307,303 +307,303 @@ describe "FormHelpers" do
|
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
-
|
311
|
-
should
|
310
|
+
describe 'for #hidden_field_tag method' do
|
311
|
+
it 'should display hidden field in ruby' do
|
312
312
|
actual_html = hidden_field_tag(:session_key, :id => 'session_id', :value => '56768')
|
313
313
|
assert_has_tag(:input, :type => 'hidden', :id => "session_id", :name => 'session_key', :value => '56768') { actual_html }
|
314
314
|
end
|
315
315
|
|
316
|
-
should
|
316
|
+
it 'should display hidden field in erb' do
|
317
317
|
visit '/erb/form_tag'
|
318
318
|
assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
319
319
|
assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
320
320
|
end
|
321
321
|
|
322
|
-
should
|
322
|
+
it 'should display hidden field in haml' do
|
323
323
|
visit '/haml/form_tag'
|
324
324
|
assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
325
325
|
assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
326
326
|
end
|
327
327
|
|
328
|
-
should
|
328
|
+
it 'should display hidden field in slim' do
|
329
329
|
visit '/slim/form_tag'
|
330
330
|
assert_have_selector 'form.simple-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
331
331
|
assert_have_selector 'form.advanced-form input[type=hidden]', :count => 1, :name => 'session_id', :value => "__secret__"
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
|
-
|
336
|
-
should
|
335
|
+
describe 'for #text_field_tag method' do
|
336
|
+
it 'should display text field in ruby' do
|
337
337
|
actual_html = text_field_tag(:username, :class => 'long')
|
338
338
|
assert_has_tag(:input, :type => 'text', :class => "long", :name => 'username') { actual_html }
|
339
339
|
end
|
340
340
|
|
341
|
-
should
|
341
|
+
it 'should display text field in erb' do
|
342
342
|
visit '/erb/form_tag'
|
343
343
|
assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
|
344
344
|
assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
|
345
345
|
end
|
346
346
|
|
347
|
-
should
|
347
|
+
it 'should display text field in haml' do
|
348
348
|
visit '/haml/form_tag'
|
349
349
|
assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
|
350
350
|
assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
|
351
351
|
end
|
352
352
|
|
353
|
-
should
|
353
|
+
it 'should display text field in slim' do
|
354
354
|
visit '/slim/form_tag'
|
355
355
|
assert_have_selector 'form.simple-form input[type=text]', :count => 1, :name => 'username'
|
356
356
|
assert_have_selector 'form.advanced-form fieldset input[type=text]', :count => 1, :name => 'username', :id => 'the_username'
|
357
357
|
end
|
358
358
|
end
|
359
359
|
|
360
|
-
|
361
|
-
should
|
360
|
+
describe 'for #number_field_tag method' do
|
361
|
+
it 'should display number field in ruby' do
|
362
362
|
actual_html = number_field_tag(:age, :class => 'numeric')
|
363
363
|
assert_has_tag(:input, :type => 'number', :class => 'numeric', :name => 'age') { actual_html }
|
364
364
|
end
|
365
365
|
|
366
|
-
should
|
366
|
+
it 'should display number field in erb' do
|
367
367
|
visit '/erb/form_tag'
|
368
368
|
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
369
369
|
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
370
370
|
end
|
371
371
|
|
372
|
-
should
|
372
|
+
it 'should display number field in haml' do
|
373
373
|
visit '/haml/form_tag'
|
374
374
|
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
375
375
|
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
376
376
|
end
|
377
377
|
|
378
|
-
should
|
378
|
+
it 'should display number field in slim' do
|
379
379
|
visit '/slim/form_tag'
|
380
380
|
assert_have_selector 'form.simple-form input[type=number]', :count => 1, :name => 'age'
|
381
381
|
assert_have_selector 'form.advanced-form fieldset input[type=number]', :count => 1, :name => 'age', :class => 'numeric'
|
382
382
|
end
|
383
383
|
end
|
384
384
|
|
385
|
-
|
386
|
-
should
|
385
|
+
describe 'for #telephone_field_tag method' do
|
386
|
+
it 'should display number field in ruby' do
|
387
387
|
actual_html = telephone_field_tag(:telephone, :class => 'numeric')
|
388
388
|
assert_has_tag(:input, :type => 'tel', :class => 'numeric', :name => 'telephone') { actual_html }
|
389
389
|
end
|
390
390
|
|
391
|
-
should
|
391
|
+
it 'should display telephone field in erb' do
|
392
392
|
visit '/erb/form_tag'
|
393
393
|
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
394
394
|
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
395
395
|
end
|
396
396
|
|
397
|
-
should
|
397
|
+
it 'should display telephone field in haml' do
|
398
398
|
visit '/haml/form_tag'
|
399
399
|
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
400
400
|
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
401
401
|
end
|
402
402
|
|
403
|
-
should
|
403
|
+
it 'should display telephone field in slim' do
|
404
404
|
visit '/slim/form_tag'
|
405
405
|
assert_have_selector 'form.simple-form input[type=tel]', :count => 1, :name => 'telephone'
|
406
406
|
assert_have_selector 'form.advanced-form fieldset input[type=tel]', :count => 1, :name => 'telephone', :class => 'numeric'
|
407
407
|
end
|
408
408
|
end
|
409
409
|
|
410
|
-
|
411
|
-
should
|
410
|
+
describe 'for #search_field_tag method' do
|
411
|
+
it 'should display search field in ruby' do
|
412
412
|
actual_html = search_field_tag(:search, :class => 'string')
|
413
413
|
assert_has_tag(:input, :type => 'search', :class => 'string', :name => 'search') { actual_html }
|
414
414
|
end
|
415
415
|
|
416
|
-
should
|
416
|
+
it 'should display search field in erb' do
|
417
417
|
visit '/erb/form_tag'
|
418
418
|
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
419
419
|
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
420
420
|
end
|
421
421
|
|
422
|
-
should
|
422
|
+
it 'should display search field in haml' do
|
423
423
|
visit '/haml/form_tag'
|
424
424
|
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
425
425
|
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
426
426
|
end
|
427
427
|
|
428
|
-
should
|
428
|
+
it 'should display search field in slim' do
|
429
429
|
visit '/slim/form_tag'
|
430
430
|
assert_have_selector 'form.simple-form input[type=search]', :count => 1, :name => 'search'
|
431
431
|
assert_have_selector 'form.advanced-form fieldset input[type=search]', :count => 1, :name => 'search', :class => 'string'
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
435
|
-
|
436
|
-
should
|
435
|
+
describe 'for #email_field_tag method' do
|
436
|
+
it 'should display email field in ruby' do
|
437
437
|
actual_html = email_field_tag(:email, :class => 'string')
|
438
438
|
assert_has_tag(:input, :type => 'email', :class => 'string', :name => 'email') { actual_html }
|
439
439
|
end
|
440
440
|
|
441
|
-
should
|
441
|
+
it 'should display email field in erb' do
|
442
442
|
visit '/erb/form_tag'
|
443
443
|
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
444
444
|
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
445
445
|
end
|
446
446
|
|
447
|
-
should
|
447
|
+
it 'should display email field in haml' do
|
448
448
|
visit '/haml/form_tag'
|
449
449
|
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
450
450
|
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
451
451
|
end
|
452
452
|
|
453
|
-
should
|
453
|
+
it 'should display email field in slim' do
|
454
454
|
visit '/slim/form_tag'
|
455
455
|
assert_have_selector 'form.simple-form input[type=email]', :count => 1, :name => 'email'
|
456
456
|
assert_have_selector 'form.advanced-form fieldset input[type=email]', :count => 1, :name => 'email', :class => 'string'
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
460
|
-
|
461
|
-
should
|
460
|
+
describe 'for #url_field_tag method' do
|
461
|
+
it 'should display url field in ruby' do
|
462
462
|
actual_html = url_field_tag(:webpage, :class => 'string')
|
463
463
|
assert_has_tag(:input, :type => 'url', :class => 'string', :name => 'webpage') { actual_html }
|
464
464
|
end
|
465
465
|
|
466
|
-
should
|
466
|
+
it 'should display url field in erb' do
|
467
467
|
visit '/erb/form_tag'
|
468
468
|
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
469
469
|
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
470
470
|
end
|
471
471
|
|
472
|
-
should
|
472
|
+
it 'should display url field in haml' do
|
473
473
|
visit '/haml/form_tag'
|
474
474
|
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
475
475
|
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
476
476
|
end
|
477
477
|
|
478
|
-
should
|
478
|
+
it 'should display url field in slim' do
|
479
479
|
visit '/slim/form_tag'
|
480
480
|
assert_have_selector 'form.simple-form input[type=url]', :count => 1, :name => 'webpage'
|
481
481
|
assert_have_selector 'form.advanced-form fieldset input[type=url]', :count => 1, :name => 'webpage', :class => 'string'
|
482
482
|
end
|
483
483
|
end
|
484
484
|
|
485
|
-
|
486
|
-
should
|
485
|
+
describe 'for #text_area_tag method' do
|
486
|
+
it 'should display text area in ruby' do
|
487
487
|
actual_html = text_area_tag(:about, :class => 'long')
|
488
488
|
assert_has_tag(:textarea, :class => "long", :name => 'about') { actual_html }
|
489
489
|
end
|
490
490
|
|
491
|
-
should
|
491
|
+
it 'should display text area in ruby with specified content' do
|
492
492
|
actual_html = text_area_tag(:about, :value => "a test", :rows => 5, :cols => 6)
|
493
493
|
assert_has_tag(:textarea, :content => "a test", :name => 'about', :rows => "5", :cols => "6") { actual_html }
|
494
494
|
end
|
495
495
|
|
496
|
-
should
|
496
|
+
it 'should display text area in erb' do
|
497
497
|
visit '/erb/form_tag'
|
498
498
|
assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
|
499
499
|
end
|
500
500
|
|
501
|
-
should
|
501
|
+
it 'should display text area in haml' do
|
502
502
|
visit '/haml/form_tag'
|
503
503
|
assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
|
504
504
|
end
|
505
505
|
|
506
|
-
should
|
506
|
+
it 'should display text area in slim' do
|
507
507
|
visit '/slim/form_tag'
|
508
508
|
assert_have_selector 'form.advanced-form textarea', :count => 1, :name => 'about', :class => 'large'
|
509
509
|
end
|
510
510
|
end
|
511
511
|
|
512
|
-
|
513
|
-
should
|
512
|
+
describe 'for #password_field_tag method' do
|
513
|
+
it 'should display password field in ruby' do
|
514
514
|
actual_html = password_field_tag(:password, :class => 'long')
|
515
515
|
assert_has_tag(:input, :type => 'password', :class => "long", :name => 'password') { actual_html }
|
516
516
|
end
|
517
517
|
|
518
|
-
should
|
518
|
+
it 'should display password field in erb' do
|
519
519
|
visit '/erb/form_tag'
|
520
520
|
assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
|
521
521
|
assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
|
522
522
|
end
|
523
523
|
|
524
|
-
should
|
524
|
+
it 'should display password field in haml' do
|
525
525
|
visit '/haml/form_tag'
|
526
526
|
assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
|
527
527
|
assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
|
528
528
|
end
|
529
529
|
|
530
|
-
should
|
530
|
+
it 'should display password field in slim' do
|
531
531
|
visit '/slim/form_tag'
|
532
532
|
assert_have_selector 'form.simple-form input[type=password]', :count => 1, :name => 'password'
|
533
533
|
assert_have_selector 'form.advanced-form input[type=password]', :count => 1, :name => 'password'
|
534
534
|
end
|
535
535
|
end
|
536
536
|
|
537
|
-
|
538
|
-
should
|
537
|
+
describe 'for #file_field_tag method' do
|
538
|
+
it 'should display file field in ruby' do
|
539
539
|
actual_html = file_field_tag(:photo, :class => 'photo')
|
540
540
|
assert_has_tag(:input, :type => 'file', :class => "photo", :name => 'photo') { actual_html }
|
541
541
|
end
|
542
542
|
|
543
|
-
should
|
543
|
+
it 'should have an array name with multiple option' do
|
544
544
|
actual_html = file_field_tag(:photos, :multiple => true)
|
545
545
|
assert_has_tag(:input, :name => 'photos[]') { actual_html }
|
546
546
|
end
|
547
547
|
|
548
|
-
should
|
548
|
+
it 'should display file field in erb' do
|
549
549
|
visit '/erb/form_tag'
|
550
550
|
assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
|
551
551
|
end
|
552
552
|
|
553
|
-
should
|
553
|
+
it 'should display file field in haml' do
|
554
554
|
visit '/haml/form_tag'
|
555
555
|
assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
|
556
556
|
end
|
557
557
|
|
558
|
-
should
|
558
|
+
it 'should display file field in slim' do
|
559
559
|
visit '/slim/form_tag'
|
560
560
|
assert_have_selector 'form.advanced-form input[type=file]', :count => 1, :name => 'photo', :class => 'upload'
|
561
561
|
end
|
562
562
|
end
|
563
563
|
|
564
|
-
|
565
|
-
should
|
564
|
+
describe "for #check_box_tag method" do
|
565
|
+
it 'should display check_box tag in ruby' do
|
566
566
|
actual_html = check_box_tag("clear_session")
|
567
567
|
assert_has_tag(:input, :type => 'checkbox', :value => '1', :name => 'clear_session') { actual_html }
|
568
568
|
assert_has_no_tag(:input, :type => 'hidden') { actual_html }
|
569
569
|
end
|
570
570
|
|
571
|
-
should
|
571
|
+
it 'should display check_box tag in ruby with extended attributes' do
|
572
572
|
actual_html = check_box_tag("clear_session", :disabled => true, :checked => true)
|
573
573
|
assert_has_tag(:input, :type => 'checkbox', :disabled => 'disabled', :checked => 'checked') { actual_html }
|
574
574
|
end
|
575
575
|
|
576
|
-
should
|
576
|
+
it 'should display check_box tag in erb' do
|
577
577
|
visit '/erb/form_tag'
|
578
578
|
assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
|
579
579
|
assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
|
580
580
|
end
|
581
581
|
|
582
|
-
should
|
582
|
+
it 'should display check_box tag in haml' do
|
583
583
|
visit '/haml/form_tag'
|
584
584
|
assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
|
585
585
|
assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
|
586
586
|
end
|
587
587
|
|
588
|
-
should
|
588
|
+
it 'should display check_box tag in slim' do
|
589
589
|
visit '/slim/form_tag'
|
590
590
|
assert_have_selector 'form.simple-form input[type=checkbox]', :count => 1
|
591
591
|
assert_have_selector 'form.advanced-form input[type=checkbox]', :value => "1", :checked => 'checked'
|
592
592
|
end
|
593
593
|
end
|
594
594
|
|
595
|
-
|
596
|
-
should
|
595
|
+
describe "for #radio_button_tag method" do
|
596
|
+
it 'should display radio_button tag in ruby' do
|
597
597
|
actual_html = radio_button_tag("gender", :value => 'male')
|
598
598
|
assert_has_tag(:input, :type => 'radio', :value => 'male', :name => 'gender') { actual_html }
|
599
599
|
end
|
600
600
|
|
601
|
-
should
|
601
|
+
it 'should display radio_button tag in ruby with extended attributes' do
|
602
602
|
actual_html = radio_button_tag("gender", :disabled => true, :checked => true)
|
603
603
|
assert_has_tag(:input, :type => 'radio', :disabled => 'disabled', :checked => 'checked') { actual_html }
|
604
604
|
end
|
605
605
|
|
606
|
-
should
|
606
|
+
it 'should display radio_button tag in erb' do
|
607
607
|
visit '/erb/form_tag'
|
608
608
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
|
609
609
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
|
@@ -611,7 +611,7 @@ describe "FormHelpers" do
|
|
611
611
|
assert_have_selector 'form.advanced-form input[type=radio]', :value => "female"
|
612
612
|
end
|
613
613
|
|
614
|
-
should
|
614
|
+
it 'should display radio_button tag in haml' do
|
615
615
|
visit '/haml/form_tag'
|
616
616
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
|
617
617
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
|
@@ -619,7 +619,7 @@ describe "FormHelpers" do
|
|
619
619
|
assert_have_selector 'form.advanced-form input[type=radio]', :value => "female"
|
620
620
|
end
|
621
621
|
|
622
|
-
should
|
622
|
+
it 'should display radio_button tag in slim' do
|
623
623
|
visit '/slim/form_tag'
|
624
624
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'male'
|
625
625
|
assert_have_selector 'form.simple-form input[type=radio]', :count => 1, :value => 'female'
|
@@ -628,8 +628,8 @@ describe "FormHelpers" do
|
|
628
628
|
end
|
629
629
|
end
|
630
630
|
|
631
|
-
|
632
|
-
should
|
631
|
+
describe "for #select_tag method" do
|
632
|
+
it 'should display select tag in ruby' do
|
633
633
|
actual_html = select_tag(:favorite_color, :options => ['green', 'blue', 'black'], :include_blank => true)
|
634
634
|
assert_has_tag(:select, :name => 'favorite_color') { actual_html }
|
635
635
|
assert_has_tag('select option:first-child', :content => '') { actual_html }
|
@@ -638,12 +638,12 @@ describe "FormHelpers" do
|
|
638
638
|
assert_has_tag('select option', :content => 'black', :value => 'black') { actual_html }
|
639
639
|
end
|
640
640
|
|
641
|
-
should
|
641
|
+
it 'should display select tag in ruby with extended attributes' do
|
642
642
|
actual_html = select_tag(:favorite_color, :disabled => true, :options => ['only', 'option'])
|
643
643
|
assert_has_tag(:select, :disabled => 'disabled') { actual_html }
|
644
644
|
end
|
645
645
|
|
646
|
-
should
|
646
|
+
it 'should take a range as a collection for options' do
|
647
647
|
actual_html = select_tag(:favorite_color, :options => (1..3))
|
648
648
|
assert_has_tag(:select) { actual_html }
|
649
649
|
assert_has_tag('select option', :content => '1', :value => '1') { actual_html }
|
@@ -651,13 +651,13 @@ describe "FormHelpers" do
|
|
651
651
|
assert_has_tag('select option', :content => '3', :value => '3') { actual_html }
|
652
652
|
end
|
653
653
|
|
654
|
-
should
|
654
|
+
it 'should include blank for grouped options' do
|
655
655
|
opts = { "Red" => ["Rose","Fire"], "Blue" => ["Sky","Sea"] }
|
656
656
|
actual_html = select_tag( 'color', :grouped_options => opts, :include_blank => true )
|
657
657
|
assert_has_tag('select option:first-child', :value => "", :content => "") { actual_html }
|
658
658
|
end
|
659
659
|
|
660
|
-
should
|
660
|
+
it 'should display select tag with grouped options for a nested array' do
|
661
661
|
opts = [
|
662
662
|
["Friends",["Yoda",["Obiwan",2]]],
|
663
663
|
["Enemies", ["Palpatine",['Darth Vader',3]]]
|
@@ -672,7 +672,7 @@ describe "FormHelpers" do
|
|
672
672
|
assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html }
|
673
673
|
end
|
674
674
|
|
675
|
-
should
|
675
|
+
it 'should display select tag with grouped options for a nested array and accept disabled groups' do
|
676
676
|
opts = [
|
677
677
|
["Friends",["Yoda",["Obiwan",2]]],
|
678
678
|
["Enemies", ["Palpatine",['Darth Vader',3]], {:disabled => true}]
|
@@ -684,7 +684,7 @@ describe "FormHelpers" do
|
|
684
684
|
assert_has_tag(:optgroup, :label => "Enemies", :disabled => 'disabled') { actual_html }
|
685
685
|
end
|
686
686
|
|
687
|
-
should
|
687
|
+
it 'should display select tag with grouped options for a nested array and accept disabled groups and/or with disabled options' do
|
688
688
|
opts = [
|
689
689
|
["Friends",["Yoda",["Obiwan",2, {:disabled => true}]]],
|
690
690
|
["Enemies", [["Palpatine", "Palpatine", {:disabled => true}],['Darth Vader',3]], {:disabled => true}]
|
@@ -698,7 +698,7 @@ describe "FormHelpers" do
|
|
698
698
|
assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled') { actual_html }
|
699
699
|
end
|
700
700
|
|
701
|
-
should
|
701
|
+
it 'should display select tag with grouped options for a hash' do
|
702
702
|
opts = {
|
703
703
|
"Friends" => ["Yoda",["Obiwan",2]],
|
704
704
|
"Enemies" => ["Palpatine",['Darth Vader',3]]
|
@@ -713,7 +713,7 @@ describe "FormHelpers" do
|
|
713
713
|
assert_has_tag(:option, :value => "3", :content => "Darth Vader") { actual_html }
|
714
714
|
end
|
715
715
|
|
716
|
-
should
|
716
|
+
it 'should display select tag with grouped options for a hash and accept disabled groups and/or with disabled options' do
|
717
717
|
opts = {
|
718
718
|
"Friends" => ["Yoda",["Obiwan",2,{:disabled => true}]],
|
719
719
|
"Enemies" => [["Palpatine","Palpatine",{:disabled => true}],["Darth Vader",3], {:disabled => true}]
|
@@ -727,7 +727,7 @@ describe "FormHelpers" do
|
|
727
727
|
assert_has_tag(:option, :value => "Palpatine", :content => "Palpatine", :disabled => 'disabled') { actual_html }
|
728
728
|
end
|
729
729
|
|
730
|
-
should
|
730
|
+
it 'should display select tag with grouped options for a rails-style attribute hash' do
|
731
731
|
opts = {
|
732
732
|
"Friends" => ["Yoda",["Obiwan",2,{:magister=>'no'}],{:lame=>'yes'}],
|
733
733
|
"Enemies" => [["Palpatine","Palpatine",{:scary=>'yes',:old=>'yes'}],["Darth Vader",3,{:disabled=>true}]]
|
@@ -740,12 +740,12 @@ describe "FormHelpers" do
|
|
740
740
|
assert_has_tag(:option, :content => "Yoda", :selected => 'selected') { actual_html }
|
741
741
|
end
|
742
742
|
|
743
|
-
should
|
743
|
+
it 'should display select tag in ruby with multiple attribute' do
|
744
744
|
actual_html = select_tag(:favorite_color, :multiple => true, :options => ['only', 'option'])
|
745
745
|
assert_has_tag(:select, :multiple => 'multiple', :name => 'favorite_color[]') { actual_html }
|
746
746
|
end
|
747
747
|
|
748
|
-
should
|
748
|
+
it 'should display options with values and single selected' do
|
749
749
|
options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
|
750
750
|
actual_html = select_tag(:favorite_color, :options => options, :selected => 'green1')
|
751
751
|
assert_has_tag(:select, :name => 'favorite_color') { actual_html }
|
@@ -755,7 +755,7 @@ describe "FormHelpers" do
|
|
755
755
|
assert_has_tag('select option', :content => 'Black', :value => 'black1') { actual_html }
|
756
756
|
end
|
757
757
|
|
758
|
-
should
|
758
|
+
it 'should display options with values and accept disabled options' do
|
759
759
|
options = [['Green', 'green1', {:disabled => true}], ['Blue', 'blue1'], ['Black', "black1"]]
|
760
760
|
actual_html = select_tag(:favorite_color, :options => options)
|
761
761
|
assert_has_tag(:select, :name => 'favorite_color') { actual_html }
|
@@ -765,7 +765,7 @@ describe "FormHelpers" do
|
|
765
765
|
assert_has_tag('select option', :content => 'Black', :value => 'black1') { actual_html }
|
766
766
|
end
|
767
767
|
|
768
|
-
should
|
768
|
+
it 'should display option with values and multiple selected' do
|
769
769
|
options = [['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
|
770
770
|
actual_html = select_tag(:favorite_color, :options => options, :selected => ['green1', 'Black'])
|
771
771
|
assert_has_tag(:select, :name => 'favorite_color') { actual_html }
|
@@ -775,7 +775,7 @@ describe "FormHelpers" do
|
|
775
775
|
assert_has_tag('select option', :content => 'Black', :value => 'black1', :selected => 'selected') { actual_html }
|
776
776
|
end
|
777
777
|
|
778
|
-
should
|
778
|
+
it 'should display options selected only for exact match' do
|
779
779
|
options = [['One', '1'], ['1', '10'], ['Two', "-1"]]
|
780
780
|
actual_html = select_tag(:range, :options => options, :selected => '-1')
|
781
781
|
assert_has_tag(:select, :name => 'range') { actual_html }
|
@@ -783,7 +783,7 @@ describe "FormHelpers" do
|
|
783
783
|
assert_has_tag('select option', :content => 'Two', :value => '-1', :selected => 'selected') { actual_html }
|
784
784
|
end
|
785
785
|
|
786
|
-
should
|
786
|
+
it 'should display select tag in erb' do
|
787
787
|
visit '/erb/form_tag'
|
788
788
|
assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
|
789
789
|
assert_have_selector('select option', :content => 'green', :value => 'green')
|
@@ -805,7 +805,7 @@ describe "FormHelpers" do
|
|
805
805
|
assert_have_selector('select optgroup option', :content => 'Darth Vader', :value => '3')
|
806
806
|
end
|
807
807
|
|
808
|
-
should
|
808
|
+
it 'should display select tag in haml' do
|
809
809
|
visit '/haml/form_tag'
|
810
810
|
assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
|
811
811
|
assert_have_selector('select option', :content => 'green', :value => 'green')
|
@@ -827,7 +827,7 @@ describe "FormHelpers" do
|
|
827
827
|
assert_have_selector('select optgroup option', :content => 'Darth Vader', :value => '3')
|
828
828
|
end
|
829
829
|
|
830
|
-
should
|
830
|
+
it 'should display select tag in slim' do
|
831
831
|
visit '/slim/form_tag'
|
832
832
|
assert_have_selector 'form.simple-form select', :count => 1, :name => 'color'
|
833
833
|
assert_have_selector('select option', :content => 'green', :value => 'green')
|
@@ -850,44 +850,44 @@ describe "FormHelpers" do
|
|
850
850
|
end
|
851
851
|
end
|
852
852
|
|
853
|
-
|
854
|
-
should
|
853
|
+
describe 'for #submit_tag method' do
|
854
|
+
it 'should display submit tag in ruby' do
|
855
855
|
actual_html = submit_tag("Update", :class => 'success')
|
856
856
|
assert_has_tag(:input, :type => 'submit', :class => "success", :value => 'Update') { actual_html }
|
857
857
|
end
|
858
858
|
|
859
|
-
should
|
859
|
+
it 'should display submit tag in erb' do
|
860
860
|
visit '/erb/form_tag'
|
861
861
|
assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
|
862
862
|
assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
|
863
863
|
end
|
864
864
|
|
865
|
-
should
|
865
|
+
it 'should display submit tag in haml' do
|
866
866
|
visit '/haml/form_tag'
|
867
867
|
assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
|
868
868
|
assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
|
869
869
|
end
|
870
870
|
|
871
|
-
should
|
871
|
+
it 'should display submit tag in slim' do
|
872
872
|
visit '/slim/form_tag'
|
873
873
|
assert_have_selector 'form.simple-form input[type=submit]', :count => 1, :value => "Submit"
|
874
874
|
assert_have_selector 'form.advanced-form input[type=submit]', :count => 1, :value => "Login"
|
875
875
|
end
|
876
876
|
|
877
|
-
|
878
|
-
should
|
877
|
+
describe 'for omitted args' do
|
878
|
+
it 'should display submit tag with default caption' do
|
879
879
|
actual_html = submit_tag()
|
880
880
|
assert_has_tag(:input, :type => 'submit', :value => 'Submit') { actual_html }
|
881
881
|
end
|
882
882
|
end
|
883
883
|
|
884
|
-
|
885
|
-
should
|
884
|
+
describe 'for omitted caption arg' do
|
885
|
+
it 'should display submit tag with default caption' do
|
886
886
|
actual_html = submit_tag(:class => 'success')
|
887
887
|
assert_has_tag(:input, :type => 'submit', :class => 'success', :value => 'Submit') { actual_html }
|
888
888
|
end
|
889
889
|
|
890
|
-
should
|
890
|
+
it 'should display submit tag without caption value when nil' do
|
891
891
|
actual_html = submit_tag(nil, :class => 'success')
|
892
892
|
assert_has_tag(:input, :type => 'submit', :class => 'success') { actual_html }
|
893
893
|
assert_has_no_tag(:input, :type => 'submit', :class => 'success', :value => 'Submit') { actual_html }
|
@@ -895,85 +895,85 @@ describe "FormHelpers" do
|
|
895
895
|
end
|
896
896
|
end
|
897
897
|
|
898
|
-
|
899
|
-
should
|
898
|
+
describe 'for #button_tag method' do
|
899
|
+
it 'should display submit tag in ruby' do
|
900
900
|
actual_html = button_tag("Cancel", :class => 'clear')
|
901
901
|
assert_has_tag(:input, :type => 'button', :class => "clear", :value => 'Cancel') { actual_html }
|
902
902
|
end
|
903
903
|
|
904
|
-
should
|
904
|
+
it 'should display submit tag in erb' do
|
905
905
|
visit '/erb/form_tag'
|
906
906
|
assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
|
907
907
|
end
|
908
908
|
|
909
|
-
should
|
909
|
+
it 'should display submit tag in haml' do
|
910
910
|
visit '/haml/form_tag'
|
911
911
|
assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
|
912
912
|
end
|
913
913
|
|
914
|
-
should
|
914
|
+
it 'should display submit tag in slim' do
|
915
915
|
visit '/slim/form_tag'
|
916
916
|
assert_have_selector 'form.advanced-form input[type=button]', :count => 1, :value => "Cancel"
|
917
917
|
end
|
918
918
|
end
|
919
919
|
|
920
|
-
|
921
|
-
|
920
|
+
describe 'for #image_submit_tag method' do
|
921
|
+
before do
|
922
922
|
@stamp = stop_time_for_test.to_i
|
923
923
|
end
|
924
924
|
|
925
|
-
should
|
925
|
+
it 'should display image submit tag in ruby with relative path' do
|
926
926
|
actual_html = image_submit_tag('buttons/ok.png', :class => 'success')
|
927
927
|
assert_has_tag(:input, :type => 'image', :class => "success", :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
928
928
|
end
|
929
929
|
|
930
|
-
should
|
930
|
+
it 'should display image submit tag in ruby with absolute path' do
|
931
931
|
actual_html = image_submit_tag('/system/ok.png', :class => 'success')
|
932
932
|
assert_has_tag(:input, :type => 'image', :class => "success", :src => "/system/ok.png") { actual_html }
|
933
933
|
end
|
934
934
|
|
935
|
-
should
|
935
|
+
it 'should display image submit tag in erb' do
|
936
936
|
visit '/erb/form_tag'
|
937
937
|
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
|
938
938
|
end
|
939
939
|
|
940
|
-
should
|
940
|
+
it 'should display image submit tag in haml' do
|
941
941
|
visit '/haml/form_tag'
|
942
942
|
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
|
943
943
|
end
|
944
944
|
|
945
|
-
should
|
945
|
+
it 'should display image submit tag in slim' do
|
946
946
|
visit '/slim/form_tag'
|
947
947
|
assert_have_selector 'form.advanced-form input[type=image]', :count => 1, :src => "/images/buttons/submit.png?#{@stamp}"
|
948
948
|
end
|
949
949
|
end
|
950
950
|
|
951
|
-
|
952
|
-
should
|
951
|
+
describe 'for #button_to method' do
|
952
|
+
it 'should have a form and set the method properly' do
|
953
953
|
actual_html = button_to('Delete', '/users/1', :method => :delete)
|
954
954
|
assert_has_tag('form', :action => '/users/1') { actual_html }
|
955
955
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
|
956
956
|
assert_has_tag('form input', :type => 'hidden', :name => "authenticity_token") { actual_html }
|
957
957
|
end
|
958
958
|
|
959
|
-
should
|
959
|
+
it 'should add a submit button by default if no content is specified' do
|
960
960
|
actual_html = button_to('My Delete Button', '/users/1', :method => :delete)
|
961
961
|
assert_has_tag('form input', :type => 'submit', :value => 'My Delete Button') { actual_html }
|
962
962
|
end
|
963
963
|
|
964
|
-
should
|
964
|
+
it 'should set specific content inside the form if a block was sent' do
|
965
965
|
actual_html = button_to('My Delete Button', '/users/1', :method => :delete) do
|
966
966
|
content_tag :button, "My button's content", :type => :submit, :title => "My button"
|
967
967
|
end
|
968
968
|
assert_has_tag('form button', :type => 'submit', :content => "My button's content", :title => "My button") { actual_html }
|
969
969
|
end
|
970
970
|
|
971
|
-
should
|
971
|
+
it 'should pass options on submit button when submit_options are given' do
|
972
972
|
actual_html = button_to("Fancy button", '/users/1', :submit_options => { :class => :fancy })
|
973
973
|
assert_has_tag('form input', :type => 'submit', :value => 'Fancy button', :class => 'fancy') { actual_html }
|
974
974
|
end
|
975
975
|
|
976
|
-
should
|
976
|
+
it 'should display correct button_to in erb' do
|
977
977
|
visit '/erb/button_to'
|
978
978
|
assert_have_selector('form', :action => '/foo')
|
979
979
|
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
|
@@ -981,7 +981,7 @@ describe "FormHelpers" do
|
|
981
981
|
assert_have_selector('#test-point ~ form > input[type=submit]', :value => 'Bar button')
|
982
982
|
end
|
983
983
|
|
984
|
-
should
|
984
|
+
it 'should display correct button_to in haml' do
|
985
985
|
visit '/haml/button_to'
|
986
986
|
assert_have_selector('form', :action => '/foo')
|
987
987
|
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
|
@@ -989,7 +989,7 @@ describe "FormHelpers" do
|
|
989
989
|
assert_have_selector('#test-point ~ form > input[type=submit]', :value => 'Bar button')
|
990
990
|
end
|
991
991
|
|
992
|
-
should
|
992
|
+
it 'should display correct button_to in slim' do
|
993
993
|
visit '/slim/button_to'
|
994
994
|
assert_have_selector('form', :action => '/foo')
|
995
995
|
assert_have_selector('form label', :for => 'username', :content => 'Username: ')
|
@@ -998,30 +998,30 @@ describe "FormHelpers" do
|
|
998
998
|
end
|
999
999
|
end
|
1000
1000
|
|
1001
|
-
|
1002
|
-
should
|
1001
|
+
describe 'for #range_field_tag' do
|
1002
|
+
it 'should create an input tag with min and max options' do
|
1003
1003
|
actual_html = range_field_tag('ranger', :min => 20, :max => 50)
|
1004
1004
|
assert_has_tag('input', :type => 'range', :name => 'ranger', :min => '20', :max => '50') { actual_html }
|
1005
1005
|
end
|
1006
1006
|
|
1007
|
-
should
|
1007
|
+
it 'should create an input tag with range' do
|
1008
1008
|
actual_html = range_field_tag('ranger', :range => 1..20)
|
1009
1009
|
assert_has_tag('input', :min => '1', :max => '20') { actual_html }
|
1010
1010
|
end
|
1011
1011
|
|
1012
|
-
should
|
1012
|
+
it 'should display correct range_field_tag in erb' do
|
1013
1013
|
visit '/erb/form_tag'
|
1014
1014
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
|
1015
1015
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
|
1016
1016
|
end
|
1017
1017
|
|
1018
|
-
should
|
1018
|
+
it 'should display correct range_field_tag in haml' do
|
1019
1019
|
visit '/haml/form_tag'
|
1020
1020
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
|
1021
1021
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
|
1022
1022
|
end
|
1023
1023
|
|
1024
|
-
should
|
1024
|
+
it 'should display correct range_field_tag in slim' do
|
1025
1025
|
visit '/slim/form_tag'
|
1026
1026
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_min_max', :min => '1', :max => '50', :count => 1
|
1027
1027
|
assert_have_selector 'input', :type => 'range', :name => 'ranger_with_range', :min => '1', :max => '5', :count => 1
|