padrino-helpers 0.12.9 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/padrino-helpers.rb +2 -2
- data/lib/padrino-helpers/asset_tag_helpers.rb +18 -26
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +3 -56
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
- data/lib/padrino-helpers/form_helpers.rb +11 -227
- data/lib/padrino-helpers/form_helpers/options.rb +5 -7
- data/lib/padrino-helpers/output_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +1 -2
- data/lib/padrino-helpers/render_helpers.rb +2 -23
- data/lib/padrino-helpers/tag_helpers.rb +1 -14
- data/lib/padrino/rendering.rb +4 -56
- data/lib/padrino/rendering/erb_template.rb +0 -12
- data/lib/padrino/rendering/erubis_template.rb +1 -1
- data/padrino-helpers.gemspec +1 -1
- data/test/fixtures/markup_app/views/form_for.erb +0 -28
- data/test/fixtures/markup_app/views/form_for.haml +0 -22
- data/test/fixtures/markup_app/views/form_for.slim +0 -21
- data/test/fixtures/markup_app/views/form_tag.erb +0 -21
- data/test/fixtures/markup_app/views/form_tag.haml +0 -14
- data/test/fixtures/markup_app/views/form_tag.slim +0 -14
- data/test/helper.rb +17 -6
- data/test/test_asset_tag_helpers.rb +92 -110
- data/test/test_form_builder.rb +450 -691
- data/test/test_form_helpers.rb +457 -770
- data/test/test_format_helpers.rb +37 -17
- data/test/test_helpers.rb +0 -8
- data/test/test_output_helpers.rb +72 -72
- data/test/test_render_helpers.rb +100 -142
- data/test/test_rendering.rb +1 -58
- data/test/test_tag_helpers.rb +39 -41
- metadata +118 -34
- data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +0 -79
@@ -14,114 +14,89 @@ describe "AssetTagHelpers" do
|
|
14
14
|
|
15
15
|
describe 'for #flash_tag method' do
|
16
16
|
it 'should display flash with no given attributes' do
|
17
|
-
|
17
|
+
assert_has_tag('div.notice', :content => "Demo notice") { flash_tag(:notice) }
|
18
18
|
end
|
19
19
|
it 'should display flash with given attributes' do
|
20
20
|
actual_html = flash_tag(:notice, :class => 'notice', :id => 'notice-area')
|
21
|
-
|
21
|
+
assert_has_tag('div.notice#notice-area', :content => "Demo notice") { actual_html }
|
22
22
|
end
|
23
23
|
it 'should display multiple flash tags with given attributes' do
|
24
24
|
flash[:error] = 'wrong'
|
25
25
|
flash[:success] = 'okey'
|
26
26
|
actual_html = flash_tag(:success, :warning, :error, :id => 'area')
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
assert_has_tag('div.success#area', :content => flash[:success]) { actual_html }
|
28
|
+
assert_has_tag('div.error#area', :content => flash[:error]) { actual_html }
|
29
|
+
assert_has_no_tag('div.notice') { actual_html }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'for #link_to method' do
|
34
34
|
it 'should display link element with no given attributes' do
|
35
|
-
|
35
|
+
assert_has_tag('a', :content => "Sign up", :href => '/register') { link_to('Sign up', '/register') }
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should display link element with given attributes' do
|
39
39
|
actual_html = link_to('Sign up', '/register', :class => 'first', :id => 'linky')
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should display link element with anchor attribute' do
|
44
|
-
actual_html = link_to("Anchor", "/anchor", :anchor => :foo)
|
45
|
-
assert_html_has_tag(actual_html, 'a', :content => "Anchor", :href => '/anchor#foo')
|
40
|
+
assert_has_tag('a#linky.first', :content => "Sign up", :href => '/register') { actual_html }
|
46
41
|
end
|
47
42
|
|
48
43
|
it 'should display link element with void url and options' do
|
49
44
|
actual_link = link_to('Sign up', :class => "test")
|
50
|
-
|
45
|
+
assert_has_tag('a', :content => "Sign up", :href => '#', :class => 'test') { actual_link }
|
51
46
|
end
|
52
47
|
|
53
48
|
it 'should display link element with remote option' do
|
54
49
|
actual_link = link_to('Sign up', '/register', :remote => true)
|
55
|
-
|
50
|
+
assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-remote' => 'true') { actual_link }
|
56
51
|
end
|
57
52
|
|
58
53
|
it 'should display link element with method option' do
|
59
54
|
actual_link = link_to('Sign up', '/register', :method => :delete)
|
60
|
-
|
55
|
+
assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-method' => 'delete', :rel => 'nofollow') { actual_link }
|
61
56
|
end
|
62
57
|
|
63
58
|
it 'should display link element with confirm option' do
|
64
59
|
actual_link = link_to('Sign up', '/register', :confirm => "Are you sure?")
|
65
|
-
|
60
|
+
assert_has_tag('a', :content => "Sign up", :href => '/register', 'data-confirm' => 'Are you sure?') { actual_link }
|
66
61
|
end
|
67
62
|
|
68
63
|
it 'should display link element with ruby block' do
|
69
64
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "Sign up" }
|
70
|
-
|
65
|
+
assert_has_tag('a#binky.first', :content => "Sign up", :href => '/register') { actual_link }
|
71
66
|
end
|
72
67
|
|
73
68
|
it 'should escape the link text' do
|
74
69
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "<&>" }
|
75
|
-
|
70
|
+
assert_has_tag('a#binky.first', :href => '/register') { actual_link }
|
76
71
|
assert_match "<&>", actual_link
|
77
72
|
end
|
78
73
|
|
79
|
-
it 'should escape the link href' do
|
80
|
-
actual_link = link_to('Sign up', '/register new%20user')
|
81
|
-
assert_html_has_tag(actual_link, 'a', :href => '/register%20new%20user')
|
82
|
-
end
|
83
|
-
|
84
74
|
it 'should not escape image_tag' do
|
85
75
|
actual_link = link_to(image_tag("/my/fancy/image.png"), :class => 'first', :id => 'binky')
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should render alt text by default' do
|
90
|
-
actual_tag = image_tag("/my/fancy/image.png")
|
91
|
-
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image.png", :alt => "Image")
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'should render humanized alt text' do
|
95
|
-
actual_tag = image_tag("/my/fancy/image_white.png")
|
96
|
-
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image_white.png", :alt => "Image white")
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should remove hash value from src path' do
|
100
|
-
actual_tag = image_tag("/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png")
|
101
|
-
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png", :alt => "Sprite")
|
76
|
+
assert_has_tag('img', :src => "/my/fancy/image.png") { actual_link }
|
102
77
|
end
|
103
78
|
|
104
79
|
it 'should display link block element in haml' do
|
105
|
-
|
106
|
-
|
107
|
-
|
80
|
+
visit '/haml/link_to'
|
81
|
+
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
82
|
+
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
108
83
|
end
|
109
84
|
|
110
85
|
it 'should display link block element in erb' do
|
111
|
-
|
112
|
-
|
113
|
-
|
86
|
+
visit '/erb/link_to'
|
87
|
+
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
88
|
+
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
114
89
|
end
|
115
90
|
|
116
91
|
it 'should display link block element in slim' do
|
117
|
-
|
118
|
-
|
119
|
-
|
92
|
+
visit '/slim/link_to'
|
93
|
+
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
94
|
+
assert_have_selector :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
120
95
|
end
|
121
96
|
|
122
97
|
it 'should not double-escape' do
|
123
98
|
actual_link = link_to('test escape', '?a=1&b=2')
|
124
|
-
|
99
|
+
assert_has_tag('a', :href => '?a=1&b=2') { actual_link }
|
125
100
|
assert_match %r{&}, actual_link
|
126
101
|
refute_match %r{&amp;}, actual_link
|
127
102
|
end
|
@@ -135,17 +110,17 @@ describe "AssetTagHelpers" do
|
|
135
110
|
describe 'for #mail_to method' do
|
136
111
|
it 'should display link element for mail to no caption' do
|
137
112
|
actual_html = mail_to('test@demo.com')
|
138
|
-
|
113
|
+
assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'test@demo.com') { actual_html }
|
139
114
|
end
|
140
115
|
|
141
116
|
it 'should display link element for mail to with caption' do
|
142
117
|
actual_html = mail_to('test@demo.com', "My Email", :class => 'demo')
|
143
|
-
|
118
|
+
assert_has_tag(:a, :href => "mailto:test@demo.com", :content => 'My Email', :class => 'demo') { actual_html }
|
144
119
|
end
|
145
120
|
|
146
121
|
it 'should display link element for mail to with caption and mail options' do
|
147
122
|
actual_html = mail_to('test@demo.com', "My Email", :subject => 'demo test', :class => 'demo', :cc => 'foo@test.com')
|
148
|
-
|
123
|
+
assert_has_tag(:a, :class => 'demo') { actual_html }
|
149
124
|
assert_match %r{mailto\:test\@demo.com\?}, actual_html
|
150
125
|
assert_match %r{cc=foo\@test\.com}, actual_html
|
151
126
|
assert_match %r{subject\=demo\%20test}, actual_html
|
@@ -158,92 +133,97 @@ describe "AssetTagHelpers" do
|
|
158
133
|
end
|
159
134
|
|
160
135
|
it 'should not double-escape ampersands in query' do
|
161
|
-
actual_html = mail_to('to@demo.com', "Email", :
|
162
|
-
|
136
|
+
actual_html = mail_to('to@demo.com', "Email", :subject => 'Hi there', :bcc => 'bcc@test.com')
|
137
|
+
assert_has_tag(:a, :href => 'mailto:to@demo.com?bcc=bcc@test.com&subject=Hi%20there', :content => 'Email') { actual_html }
|
163
138
|
assert_match %r{&}, actual_html
|
164
139
|
refute_match %r{&amp;}, actual_html
|
165
140
|
end
|
166
141
|
|
167
142
|
it 'should display mail link element in haml' do
|
168
|
-
|
169
|
-
|
170
|
-
|
143
|
+
visit '/haml/mail_to'
|
144
|
+
assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
145
|
+
assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
171
146
|
end
|
172
147
|
|
173
148
|
it 'should display mail link element in erb' do
|
174
|
-
|
175
|
-
|
176
|
-
|
149
|
+
visit '/erb/mail_to'
|
150
|
+
assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
151
|
+
assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
177
152
|
end
|
178
153
|
|
179
154
|
it 'should display mail link element in slim' do
|
180
|
-
|
181
|
-
|
182
|
-
|
155
|
+
visit '/slim/mail_to'
|
156
|
+
assert_have_selector 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
157
|
+
assert_have_selector 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
183
158
|
end
|
184
159
|
end
|
185
160
|
|
186
161
|
describe 'for #meta_tag method' do
|
187
162
|
it 'should display meta tag with given content and name' do
|
188
163
|
actual_html = meta_tag("weblog,news", :name => "keywords")
|
189
|
-
|
164
|
+
assert_has_tag("meta", :name => "keywords", "content" => "weblog,news") { actual_html }
|
190
165
|
end
|
191
166
|
|
192
167
|
it 'should display meta tag with given content and http-equiv' do
|
193
168
|
actual_html = meta_tag("text/html; charset=UTF-8", :"http-equiv" => "Content-Type")
|
194
|
-
|
169
|
+
assert_has_tag("meta", :"http-equiv" => "Content-Type", "content" => "text/html; charset=UTF-8") { actual_html }
|
195
170
|
end
|
196
171
|
|
197
172
|
it 'should display meta tag element in haml' do
|
198
|
-
|
199
|
-
|
200
|
-
|
173
|
+
visit '/haml/meta_tag'
|
174
|
+
assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
|
175
|
+
assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
201
176
|
end
|
202
177
|
|
203
178
|
it 'should display meta tag element in erb' do
|
204
|
-
|
205
|
-
|
206
|
-
|
179
|
+
visit '/erb/meta_tag'
|
180
|
+
assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
|
181
|
+
assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
207
182
|
end
|
208
183
|
|
209
184
|
it 'should display meta tag element in slim' do
|
210
|
-
|
211
|
-
|
212
|
-
|
185
|
+
visit '/slim/meta_tag'
|
186
|
+
assert_have_selector 'meta', "content" => "weblog,news", :name => "keywords"
|
187
|
+
assert_have_selector 'meta', "content" => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
213
188
|
end
|
214
189
|
end
|
215
190
|
|
216
191
|
describe 'for #image_tag method' do
|
217
192
|
it 'should display image tag absolute link with no options' do
|
218
|
-
|
193
|
+
time = stop_time_for_test
|
194
|
+
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
219
195
|
end
|
220
196
|
|
221
197
|
it 'should display image tag relative link with specified uri root' do
|
222
198
|
time = stop_time_for_test
|
223
199
|
self.class.stubs(:uri_root).returns("/blog")
|
224
|
-
|
200
|
+
assert_has_tag('img', :src => "/blog/images/relative/pic.gif?#{time.to_i}") { image_tag('relative/pic.gif') }
|
225
201
|
end
|
226
202
|
|
227
203
|
it 'should display image tag relative link with options' do
|
228
204
|
time = stop_time_for_test
|
229
|
-
|
205
|
+
assert_has_tag('img.photo', :src => "/images/relative/pic.gif?#{time.to_i}") {
|
206
|
+
image_tag('relative/pic.gif', :class => 'photo') }
|
230
207
|
end
|
231
208
|
|
232
209
|
it 'should display image tag uri link with options' do
|
233
|
-
|
210
|
+
time = stop_time_for_test
|
211
|
+
assert_has_tag('img.photo', :src => "http://demo.org/pic.gif") { image_tag('http://demo.org/pic.gif', :class => 'photo') }
|
234
212
|
end
|
235
213
|
|
236
214
|
it 'should display image tag relative link with incorrect spacing' do
|
237
215
|
time = stop_time_for_test
|
238
|
-
|
216
|
+
assert_has_tag('img.photo', :src => "/images/%20relative/%20pic.gif%20%20?#{time.to_i}") {
|
217
|
+
image_tag(' relative/ pic.gif ', :class => 'photo')
|
218
|
+
}
|
239
219
|
end
|
240
220
|
|
241
221
|
it 'should not use a timestamp if stamp setting is false' do
|
242
|
-
|
222
|
+
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
243
223
|
end
|
244
224
|
|
245
225
|
it 'should have xhtml convention tag' do
|
246
|
-
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif"
|
226
|
+
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" />'
|
247
227
|
end
|
248
228
|
end
|
249
229
|
|
@@ -252,7 +232,7 @@ describe "AssetTagHelpers" do
|
|
252
232
|
time = stop_time_for_test
|
253
233
|
actual_html = stylesheet_link_tag('style')
|
254
234
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
255
|
-
|
235
|
+
assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}")) { actual_html }
|
256
236
|
assert actual_html.html_safe?
|
257
237
|
end
|
258
238
|
|
@@ -260,14 +240,14 @@ describe "AssetTagHelpers" do
|
|
260
240
|
time = stop_time_for_test
|
261
241
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
262
242
|
actual_html = stylesheet_link_tag('example/demo/style')
|
263
|
-
|
243
|
+
assert_has_tag('link', expected_options.merge(:href => "/stylesheets/example/demo/style.css?#{time.to_i}")) { actual_html }
|
264
244
|
end
|
265
245
|
|
266
246
|
it 'should display stylesheet link item with absolute path' do
|
267
247
|
time = stop_time_for_test
|
268
248
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
269
249
|
actual_html = stylesheet_link_tag('/css/style')
|
270
|
-
|
250
|
+
assert_has_tag('link', expected_options.merge(:href => "/css/style.css")) { actual_html }
|
271
251
|
end
|
272
252
|
|
273
253
|
it 'should display stylesheet link item with uri root' do
|
@@ -275,27 +255,27 @@ describe "AssetTagHelpers" do
|
|
275
255
|
time = stop_time_for_test
|
276
256
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
277
257
|
actual_html = stylesheet_link_tag('style')
|
278
|
-
|
258
|
+
assert_has_tag('link', expected_options.merge(:href => "/blog/stylesheets/style.css?#{time.to_i}")) { actual_html }
|
279
259
|
end
|
280
260
|
|
281
261
|
it 'should display stylesheet link items' do
|
282
262
|
time = stop_time_for_test
|
283
263
|
actual_html = stylesheet_link_tag('style', 'layout.css', 'http://google.com/style.css')
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
264
|
+
assert_has_tag('link', :rel => "stylesheet", :type => "text/css", :count => 3) { actual_html }
|
265
|
+
assert_has_tag('link', :href => "/stylesheets/style.css?#{time.to_i}") { actual_html }
|
266
|
+
assert_has_tag('link', :href => "/stylesheets/layout.css?#{time.to_i}") { actual_html }
|
267
|
+
assert_has_tag('link', :href => "http://google.com/style.css") { actual_html }
|
288
268
|
assert_equal actual_html, stylesheet_link_tag(['style', 'layout.css', 'http://google.com/style.css'])
|
289
269
|
end
|
290
270
|
|
291
271
|
it 'should not use a timestamp if stamp setting is false' do
|
292
272
|
self.class.expects(:asset_stamp).returns(false)
|
293
273
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
294
|
-
|
274
|
+
assert_has_tag('link', expected_options.merge(:href => "/stylesheets/style.css")) { stylesheet_link_tag('style') }
|
295
275
|
end
|
296
276
|
|
297
277
|
it 'should display stylesheet link used custom options' do
|
298
|
-
|
278
|
+
assert_has_tag('link', :rel => 'stylesheet', :media => 'screen') { stylesheet_link_tag('style', :media => 'screen') }
|
299
279
|
end
|
300
280
|
end
|
301
281
|
|
@@ -303,7 +283,7 @@ describe "AssetTagHelpers" do
|
|
303
283
|
it 'should display javascript item' do
|
304
284
|
time = stop_time_for_test
|
305
285
|
actual_html = javascript_include_tag('application')
|
306
|
-
|
286
|
+
assert_has_tag('script', :src => "/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
307
287
|
assert actual_html.html_safe?
|
308
288
|
end
|
309
289
|
|
@@ -312,58 +292,60 @@ describe "AssetTagHelpers" do
|
|
312
292
|
self.class.stubs(:js_asset_folder).returns('js')
|
313
293
|
assert_equal 'js', asset_folder_name(:js)
|
314
294
|
actual_html = javascript_include_tag('application')
|
315
|
-
|
295
|
+
assert_has_tag('script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
316
296
|
end
|
317
297
|
|
318
298
|
it 'should display javascript item for long relative path' do
|
319
299
|
time = stop_time_for_test
|
320
300
|
actual_html = javascript_include_tag('example/demo/application')
|
321
|
-
|
301
|
+
assert_has_tag('script', :src => "/javascripts/example/demo/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
322
302
|
end
|
323
303
|
|
324
304
|
it 'should display javascript item for path containing js' do
|
325
305
|
time = stop_time_for_test
|
326
306
|
actual_html = javascript_include_tag 'test/jquery.json'
|
327
|
-
|
307
|
+
assert_has_tag('script', :src => "/javascripts/test/jquery.json?#{time.to_i}", :type => "text/javascript") { actual_html }
|
328
308
|
end
|
329
309
|
|
330
310
|
it 'should display javascript item for path containing period' do
|
331
311
|
time = stop_time_for_test
|
332
312
|
actual_html = javascript_include_tag 'test/jquery.min'
|
333
|
-
|
313
|
+
assert_has_tag('script', :src => "/javascripts/test/jquery.min.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
334
314
|
end
|
335
315
|
|
336
316
|
it 'should display javascript item with absolute path' do
|
317
|
+
time = stop_time_for_test
|
337
318
|
actual_html = javascript_include_tag('/js/application')
|
338
|
-
|
319
|
+
assert_has_tag('script', :src => "/js/application.js", :type => "text/javascript") { actual_html }
|
339
320
|
end
|
340
321
|
|
341
322
|
it 'should display javascript item with uri root' do
|
342
323
|
self.class.stubs(:uri_root).returns("/blog")
|
343
324
|
time = stop_time_for_test
|
344
325
|
actual_html = javascript_include_tag('application')
|
345
|
-
|
326
|
+
assert_has_tag('script', :src => "/blog/javascripts/application.js?#{time.to_i}", :type => "text/javascript") { actual_html }
|
346
327
|
end
|
347
328
|
|
348
329
|
it 'should not append extension to absolute paths' do
|
330
|
+
time = stop_time_for_test
|
349
331
|
actual_html = javascript_include_tag('https://maps.googleapis.com/maps/api/js?key=value&sensor=false')
|
350
|
-
|
332
|
+
assert_has_tag('script', :src => "https://maps.googleapis.com/maps/api/js?key=value&sensor=false") { actual_html }
|
351
333
|
end
|
352
334
|
|
353
335
|
it 'should display javascript items' do
|
354
336
|
time = stop_time_for_test
|
355
337
|
actual_html = javascript_include_tag('application', 'base.js', 'http://google.com/lib.js')
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
338
|
+
assert_has_tag('script', :type => "text/javascript", :count => 3) { actual_html }
|
339
|
+
assert_has_tag('script', :src => "/javascripts/application.js?#{time.to_i}") { actual_html }
|
340
|
+
assert_has_tag('script', :src => "/javascripts/base.js?#{time.to_i}") { actual_html }
|
341
|
+
assert_has_tag('script', :src => "http://google.com/lib.js") { actual_html }
|
360
342
|
assert_equal actual_html, javascript_include_tag(['application', 'base.js', 'http://google.com/lib.js'])
|
361
343
|
end
|
362
344
|
|
363
345
|
it 'should not use a timestamp if stamp setting is false' do
|
364
346
|
self.class.expects(:asset_stamp).returns(false)
|
365
347
|
actual_html = javascript_include_tag('application')
|
366
|
-
|
348
|
+
assert_has_tag('script', :src => "/javascripts/application.js", :type => "text/javascript") { actual_html }
|
367
349
|
end
|
368
350
|
end
|
369
351
|
|
@@ -371,33 +353,33 @@ describe "AssetTagHelpers" do
|
|
371
353
|
it 'should display favicon' do
|
372
354
|
time = stop_time_for_test
|
373
355
|
actual_html = favicon_tag('icons/favicon.png')
|
374
|
-
|
356
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/png', :href => "/images/icons/favicon.png?#{time.to_i}") { actual_html }
|
375
357
|
end
|
376
358
|
|
377
359
|
it 'should match type with file ext' do
|
378
360
|
time = stop_time_for_test
|
379
361
|
actual_html = favicon_tag('favicon.ico')
|
380
|
-
|
362
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.ico?#{time.to_i}") { actual_html }
|
381
363
|
end
|
382
364
|
|
383
365
|
it 'should allow option overrides' do
|
384
366
|
time = stop_time_for_test
|
385
367
|
actual_html = favicon_tag('favicon.png', :type => 'image/ico')
|
386
|
-
|
368
|
+
assert_has_tag('link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.png?#{time.to_i}") { actual_html }
|
387
369
|
end
|
388
370
|
end
|
389
371
|
|
390
372
|
describe 'for #feed_tag method' do
|
391
373
|
it 'should generate correctly link tag for rss' do
|
392
|
-
|
374
|
+
assert_has_tag('link', :type => 'application/rss+xml', :rel => 'alternate', :href => "/blog/post.rss", :title => 'rss') { feed_tag :rss, "/blog/post.rss" }
|
393
375
|
end
|
394
376
|
|
395
377
|
it 'should generate correctly link tag for atom' do
|
396
|
-
|
378
|
+
assert_has_tag('link', :type => 'application/atom+xml', :rel => 'alternate', :href => "/blog/post.atom", :title => 'atom') { feed_tag :atom, "/blog/post.atom" }
|
397
379
|
end
|
398
380
|
|
399
381
|
it 'should override options' do
|
400
|
-
|
382
|
+
assert_has_tag('link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title') { feed_tag :rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title" }
|
401
383
|
end
|
402
384
|
end
|
403
385
|
|