padrino-helpers 0.13.3.2 → 0.13.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/test/helper.rb +2 -15
- data/test/test_asset_tag_helpers.rb +89 -94
- data/test/test_form_builder.rb +506 -503
- data/test/test_form_helpers.rb +516 -516
- data/test/test_output_helpers.rb +72 -72
- data/test/test_render_helpers.rb +94 -94
- data/test/test_rendering.rb +2 -2
- data/test/test_tag_helpers.rb +39 -39
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d68a01385de986830de4f80c5d3fbe5bff78a3
|
4
|
+
data.tar.gz: 85b1ba0dbf9d4989d912fc1acfe6e04ea91ebc58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ceec9f9f045bacfd711a51983c45c69be56db194249c1227756ea5b4394ca7a51cbc38b8f185e883b54677b97fa51f7ada0669ec7f3aadabbe4f9fa28844f36
|
7
|
+
data.tar.gz: 07db632d89473ee8e9fc836b92d507adf69776b88ae9e4a893a415d19a639565547119425805b2468693c811539a1bc28ee3a348dce1f2537619af56b770e806
|
data/README.rdoc
CHANGED
@@ -53,7 +53,7 @@ to the template through the use of <tt>concat_content</tt>. Note have been built
|
|
53
53
|
templates using the same syntax.
|
54
54
|
|
55
55
|
For more information on using output helpers, check out the guide for
|
56
|
-
{Padrino Helpers}[http://
|
56
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/output-helpers/].
|
57
57
|
|
58
58
|
=== Tag Helpers
|
59
59
|
|
@@ -74,7 +74,7 @@ The input_tag is used to build tags that are related to accepting input from the
|
|
74
74
|
Note that all of these accept html options and result in returning a string containing html tags.
|
75
75
|
|
76
76
|
For more information on using tag helpers, check out the guide for
|
77
|
-
{Padrino Helpers}[http://
|
77
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/tag-helpers/].
|
78
78
|
|
79
79
|
=== Asset Helpers
|
80
80
|
|
@@ -95,7 +95,7 @@ simple view template:
|
|
95
95
|
%p= image_tag 'padrino.png', :width => '35', :class => 'logo'
|
96
96
|
|
97
97
|
For more information on using asset helpers, check out the guide for
|
98
|
-
{Padrino Helpers}[http://
|
98
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/asset-helpers/].
|
99
99
|
|
100
100
|
=== Form Helpers
|
101
101
|
|
@@ -120,7 +120,7 @@ example of constructing a non-object form would be:
|
|
120
120
|
= submit_tag "Remove"
|
121
121
|
|
122
122
|
For more information on using form helpers, check out the guide for
|
123
|
-
{Padrino Helpers}[http://
|
123
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/form-helpers/].
|
124
124
|
|
125
125
|
=== FormBuilders
|
126
126
|
|
@@ -153,7 +153,7 @@ A form_for using these basic fields might look like:
|
|
153
153
|
%p
|
154
154
|
= f.submit "Create", :class => 'button'
|
155
155
|
|
156
|
-
Forms can also accept nested attributes using `fields_for` within the form builder in recent releases. Check out the guide for {Padrino Helpers}[http://
|
156
|
+
Forms can also accept nested attributes using `fields_for` within the form builder in recent releases. Check out the guide for {Padrino Helpers}[http://padrinorb.com/guides/application-helpers/form-builders/] to learn more about nested forms.
|
157
157
|
|
158
158
|
There is also an additional StandardFormBuilder which builds on the abstract fields that can be used within a form_for.
|
159
159
|
|
@@ -179,7 +179,7 @@ and would generate this html (with each input contained in a paragraph and conta
|
|
179
179
|
You can also easily build your own FormBuilder which allows for customized fields and behavior.
|
180
180
|
|
181
181
|
For more information on using the Padrino form builders, check out the guide for
|
182
|
-
{Padrino Helpers}[http://
|
182
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/standard-form-builder/].
|
183
183
|
|
184
184
|
=== Format Helpers
|
185
185
|
|
@@ -207,7 +207,7 @@ Format helpers also includes a number of useful text manipulation functions such
|
|
207
207
|
These helpers can be invoked from any route or view within your application.
|
208
208
|
|
209
209
|
For more information on using the format helpers, check out the guide for
|
210
|
-
{Padrino Helpers}[http://
|
210
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/format-helpers/].
|
211
211
|
|
212
212
|
=== Render Helpers
|
213
213
|
|
@@ -232,7 +232,7 @@ Finally, we have the all-important partials support for rendering mini-templates
|
|
232
232
|
partial 'photo/_item', :collection => @photos
|
233
233
|
|
234
234
|
For more information on using the render and partial helpers, check out the guide for
|
235
|
-
{Padrino Helpers}[http://
|
235
|
+
{Padrino Helpers}[http://padrinorb.com/guides/application-helpers/render-helpers/].
|
236
236
|
|
237
237
|
== Copyright
|
238
238
|
|
data/test/helper.rb
CHANGED
@@ -4,7 +4,6 @@ require 'minitest/autorun'
|
|
4
4
|
require 'minitest/pride'
|
5
5
|
require 'mocha/setup'
|
6
6
|
require 'rack/test'
|
7
|
-
require 'webrat'
|
8
7
|
require 'builder'
|
9
8
|
require 'padrino-helpers'
|
10
9
|
require 'padrino/rendering'
|
@@ -13,18 +12,14 @@ require 'tilt/builder'
|
|
13
12
|
|
14
13
|
require 'ext/minitest-spec'
|
15
14
|
require 'ext/rack-test-methods'
|
15
|
+
require 'padrino/test-methods'
|
16
16
|
|
17
17
|
class MiniTest::Spec
|
18
18
|
include Padrino::Helpers::OutputHelpers
|
19
19
|
include Padrino::Helpers::TagHelpers
|
20
20
|
include Padrino::Helpers::AssetTagHelpers
|
21
21
|
include Rack::Test::Methods
|
22
|
-
include
|
23
|
-
include Webrat::Matchers
|
24
|
-
|
25
|
-
Webrat.configure do |config|
|
26
|
-
config.mode = :rack
|
27
|
-
end
|
22
|
+
include Padrino::TestMethods
|
28
23
|
|
29
24
|
def stop_time_for_test
|
30
25
|
time = Time.now
|
@@ -80,11 +75,3 @@ class MiniTest::Spec
|
|
80
75
|
Rack::Lint.new(@app)
|
81
76
|
end
|
82
77
|
end
|
83
|
-
|
84
|
-
module Webrat
|
85
|
-
module Logging
|
86
|
-
def logger # @private
|
87
|
-
@logger = nil
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -14,107 +14,109 @@ 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_html_has_tag(flash_tag(:notice), 'div.notice', :content => "Demo 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_html_has_tag(actual_html, 'div.notice#notice-area', :content => "Demo notice")
|
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_html_has_tag(actual_html, 'div.success#area', :content => flash[:success])
|
28
|
+
assert_html_has_tag(actual_html, 'div.error#area', :content => flash[:error])
|
29
|
+
assert_html_has_no_tag(actual_html, 'div.warning')
|
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_html_has_tag(link_to('Sign up', '/register'), 'a', :content => "Sign up", :href => '/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
|
-
|
40
|
+
assert_html_has_tag(actual_html, 'a#linky.first', :content => "Sign up", :href => '/register')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should display link element with void url and options' do
|
44
44
|
actual_link = link_to('Sign up', :class => "test")
|
45
|
-
|
45
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '#', :class => 'test')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should display link element with remote option' do
|
49
49
|
actual_link = link_to('Sign up', '/register', :remote => true)
|
50
|
-
|
50
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-remote' => 'true')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should display link element with method option' do
|
54
54
|
actual_link = link_to('Sign up', '/register', :method => :delete)
|
55
|
-
|
55
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-method' => 'delete', :rel => 'nofollow')
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should display link element with confirm option' do
|
59
59
|
actual_link = link_to('Sign up', '/register', :confirm => "Are you sure?")
|
60
|
-
|
60
|
+
assert_html_has_tag(actual_link, 'a', :content => "Sign up", :href => '/register', 'data-confirm' => 'Are you sure?')
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should display link element with ruby block' do
|
64
64
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "Sign up" }
|
65
|
-
|
65
|
+
assert_html_has_tag(actual_link, 'a#binky.first', :content => "Sign up", :href => '/register')
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should escape the link text' do
|
69
69
|
actual_link = link_to('/register', :class => 'first', :id => 'binky') { "<&>" }
|
70
|
-
|
70
|
+
assert_html_has_tag(actual_link, 'a#binky.first', :href => '/register')
|
71
71
|
assert_match "<&>", actual_link
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should escape the link href' do
|
75
75
|
actual_link = link_to('Sign up', '/register new%20user')
|
76
|
-
|
76
|
+
assert_html_has_tag(actual_link, 'a', :href => '/register%20new%20user')
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should not escape image_tag' do
|
80
80
|
actual_link = link_to(image_tag("/my/fancy/image.png"), :class => 'first', :id => 'binky')
|
81
|
-
|
81
|
+
assert_html_has_tag(actual_link, 'img', :src => "/my/fancy/image.png")
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should render alt text by default' do
|
85
85
|
actual_tag = image_tag("/my/fancy/image.png")
|
86
|
-
|
86
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image.png", :alt => "Image")
|
87
|
+
end
|
87
88
|
|
89
|
+
it 'should render humanized alt text' do
|
88
90
|
actual_tag = image_tag("/my/fancy/image_white.png")
|
89
|
-
|
91
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/image_white.png", :alt => "Image white")
|
90
92
|
end
|
91
93
|
|
92
94
|
it 'should remove hash value from src path' do
|
93
95
|
actual_tag = image_tag("/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png")
|
94
|
-
|
96
|
+
assert_html_has_tag(actual_tag, 'img', :src => "/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png", :alt => "Sprite")
|
95
97
|
end
|
96
98
|
|
97
99
|
it 'should display link block element in haml' do
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
get "/haml/link_to"
|
101
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
102
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
101
103
|
end
|
102
104
|
|
103
105
|
it 'should display link block element in erb' do
|
104
|
-
|
105
|
-
|
106
|
-
|
106
|
+
get "/erb/link_to"
|
107
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
108
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
107
109
|
end
|
108
110
|
|
109
111
|
it 'should display link block element in slim' do
|
110
|
-
|
111
|
-
|
112
|
-
|
112
|
+
get "/slim/link_to"
|
113
|
+
assert_response_has_tag :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
114
|
+
assert_response_has_tag :a, :content => "Test 2 With Block", :href => '/test2', :class => 'test', :id => 'test2'
|
113
115
|
end
|
114
116
|
|
115
117
|
it 'should not double-escape' do
|
116
118
|
actual_link = link_to('test escape', '?a=1&b=2')
|
117
|
-
|
119
|
+
assert_html_has_tag(actual_link, 'a', :href => '?a=1&b=2')
|
118
120
|
assert_match %r{&}, actual_link
|
119
121
|
refute_match %r{&amp;}, actual_link
|
120
122
|
end
|
@@ -128,17 +130,17 @@ describe "AssetTagHelpers" do
|
|
128
130
|
describe 'for #mail_to method' do
|
129
131
|
it 'should display link element for mail to no caption' do
|
130
132
|
actual_html = mail_to('test@demo.com')
|
131
|
-
|
133
|
+
assert_html_has_tag(actual_html, :a, :href => "mailto:test@demo.com", :content => 'test@demo.com')
|
132
134
|
end
|
133
135
|
|
134
136
|
it 'should display link element for mail to with caption' do
|
135
137
|
actual_html = mail_to('test@demo.com', "My Email", :class => 'demo')
|
136
|
-
|
138
|
+
assert_html_has_tag(actual_html, :a, :href => "mailto:test@demo.com", :content => 'My Email', :class => 'demo')
|
137
139
|
end
|
138
140
|
|
139
141
|
it 'should display link element for mail to with caption and mail options' do
|
140
142
|
actual_html = mail_to('test@demo.com', "My Email", :subject => 'demo test', :class => 'demo', :cc => 'foo@test.com')
|
141
|
-
|
143
|
+
assert_html_has_tag(actual_html, :a, :class => 'demo')
|
142
144
|
assert_match %r{mailto\:test\@demo.com\?}, actual_html
|
143
145
|
assert_match %r{cc=foo\@test\.com}, actual_html
|
144
146
|
assert_match %r{subject\=demo\%20test}, actual_html
|
@@ -152,92 +154,87 @@ describe "AssetTagHelpers" do
|
|
152
154
|
|
153
155
|
it 'should not double-escape ampersands in query' do
|
154
156
|
actual_html = mail_to('to@demo.com', "Email", :bcc => 'bcc@test.com', :subject => 'Hi there')
|
155
|
-
|
157
|
+
assert_html_has_tag(actual_html, :a, :href => 'mailto:to@demo.com?bcc=bcc@test.com&subject=Hi%20there', :content => 'Email')
|
156
158
|
assert_match %r{&}, actual_html
|
157
159
|
refute_match %r{&amp;}, actual_html
|
158
160
|
end
|
159
161
|
|
160
162
|
it 'should display mail link element in haml' do
|
161
|
-
|
162
|
-
|
163
|
-
|
163
|
+
get "/haml/mail_to"
|
164
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
165
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
164
166
|
end
|
165
167
|
|
166
168
|
it 'should display mail link element in erb' do
|
167
|
-
|
168
|
-
|
169
|
-
|
169
|
+
get "/erb/mail_to"
|
170
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
171
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
170
172
|
end
|
171
173
|
|
172
174
|
it 'should display mail link element in slim' do
|
173
|
-
|
174
|
-
|
175
|
-
|
175
|
+
get "/slim/mail_to"
|
176
|
+
assert_response_has_tag 'p.simple a', :href => 'mailto:test@demo.com', :content => 'test@demo.com'
|
177
|
+
assert_response_has_tag 'p.captioned a', :href => 'mailto:test@demo.com', :content => 'Click my Email'
|
176
178
|
end
|
177
179
|
end
|
178
180
|
|
179
181
|
describe 'for #meta_tag method' do
|
180
182
|
it 'should display meta tag with given content and name' do
|
181
183
|
actual_html = meta_tag("weblog,news", :name => "keywords")
|
182
|
-
|
184
|
+
assert_html_has_tag(actual_html, "meta", :name => "keywords", :content => "weblog,news")
|
183
185
|
end
|
184
186
|
|
185
187
|
it 'should display meta tag with given content and http-equiv' do
|
186
188
|
actual_html = meta_tag("text/html; charset=UTF-8", :"http-equiv" => "Content-Type")
|
187
|
-
|
189
|
+
assert_html_has_tag(actual_html, "meta", :"http-equiv" => "Content-Type", :content => "text/html; charset=UTF-8")
|
188
190
|
end
|
189
191
|
|
190
192
|
it 'should display meta tag element in haml' do
|
191
|
-
|
192
|
-
|
193
|
-
|
193
|
+
get "/haml/meta_tag"
|
194
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
195
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
194
196
|
end
|
195
197
|
|
196
198
|
it 'should display meta tag element in erb' do
|
197
|
-
|
198
|
-
|
199
|
-
|
199
|
+
get "/erb/meta_tag"
|
200
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
201
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
200
202
|
end
|
201
203
|
|
202
204
|
it 'should display meta tag element in slim' do
|
203
|
-
|
204
|
-
|
205
|
-
|
205
|
+
get "/slim/meta_tag"
|
206
|
+
assert_response_has_tag 'meta', :content => "weblog,news", :name => "keywords"
|
207
|
+
assert_response_has_tag 'meta', :content => "text/html; charset=UTF-8", :"http-equiv" => "Content-Type"
|
206
208
|
end
|
207
209
|
end
|
208
210
|
|
209
211
|
describe 'for #image_tag method' do
|
210
212
|
it 'should display image tag absolute link with no options' do
|
211
|
-
|
212
|
-
assert_has_tag('img', :src => "/absolute/pic.gif") { image_tag('/absolute/pic.gif') }
|
213
|
+
assert_html_has_tag(image_tag('/absolute/pic.gif'), 'img', :src => "/absolute/pic.gif")
|
213
214
|
end
|
214
215
|
|
215
216
|
it 'should display image tag relative link with specified uri root' do
|
216
217
|
time = stop_time_for_test
|
217
218
|
self.class.stubs(:uri_root).returns("/blog")
|
218
|
-
|
219
|
+
assert_html_has_tag(image_tag('relative/pic.gif'), 'img', :src => "/blog/images/relative/pic.gif?#{time.to_i}")
|
219
220
|
end
|
220
221
|
|
221
222
|
it 'should display image tag relative link with options' do
|
222
223
|
time = stop_time_for_test
|
223
|
-
|
224
|
-
image_tag('relative/pic.gif', :class => 'photo') }
|
224
|
+
assert_html_has_tag(image_tag('relative/pic.gif', :class => 'photo'), 'img.photo', :src => "/images/relative/pic.gif?#{time.to_i}")
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'should display image tag uri link with options' do
|
228
|
-
|
229
|
-
assert_has_tag('img.photo', :src => "http://demo.org/pic.gif") { image_tag('http://demo.org/pic.gif', :class => 'photo') }
|
228
|
+
assert_html_has_tag(image_tag('http://demo.org/pic.gif', :class => 'photo'), 'img.photo', :src => "http://demo.org/pic.gif")
|
230
229
|
end
|
231
230
|
|
232
231
|
it 'should display image tag relative link with incorrect spacing' do
|
233
232
|
time = stop_time_for_test
|
234
|
-
|
235
|
-
image_tag(' relative/ pic.gif ', :class => 'photo')
|
236
|
-
}
|
233
|
+
assert_html_has_tag(image_tag(' relative/ pic.gif ', :class => 'photo'), 'img.photo', :src => "/images/%20relative/%20pic.gif%20%20?#{time.to_i}")
|
237
234
|
end
|
238
235
|
|
239
236
|
it 'should not use a timestamp if stamp setting is false' do
|
240
|
-
|
237
|
+
assert_html_has_tag(image_tag('/absolute/pic.gif'), 'img', :src => "/absolute/pic.gif")
|
241
238
|
end
|
242
239
|
|
243
240
|
it 'should have xhtml convention tag' do
|
@@ -250,7 +247,7 @@ describe "AssetTagHelpers" do
|
|
250
247
|
time = stop_time_for_test
|
251
248
|
actual_html = stylesheet_link_tag('style')
|
252
249
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
253
|
-
|
250
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/stylesheets/style.css?#{time.to_i}"))
|
254
251
|
assert actual_html.html_safe?
|
255
252
|
end
|
256
253
|
|
@@ -258,14 +255,14 @@ describe "AssetTagHelpers" do
|
|
258
255
|
time = stop_time_for_test
|
259
256
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
260
257
|
actual_html = stylesheet_link_tag('example/demo/style')
|
261
|
-
|
258
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/stylesheets/example/demo/style.css?#{time.to_i}"))
|
262
259
|
end
|
263
260
|
|
264
261
|
it 'should display stylesheet link item with absolute path' do
|
265
262
|
time = stop_time_for_test
|
266
263
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
267
264
|
actual_html = stylesheet_link_tag('/css/style')
|
268
|
-
|
265
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/css/style.css"))
|
269
266
|
end
|
270
267
|
|
271
268
|
it 'should display stylesheet link item with uri root' do
|
@@ -273,27 +270,27 @@ describe "AssetTagHelpers" do
|
|
273
270
|
time = stop_time_for_test
|
274
271
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
275
272
|
actual_html = stylesheet_link_tag('style')
|
276
|
-
|
273
|
+
assert_html_has_tag(actual_html, 'link', expected_options.merge(:href => "/blog/stylesheets/style.css?#{time.to_i}"))
|
277
274
|
end
|
278
275
|
|
279
276
|
it 'should display stylesheet link items' do
|
280
277
|
time = stop_time_for_test
|
281
278
|
actual_html = stylesheet_link_tag('style', 'layout.css', 'http://google.com/style.css')
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
279
|
+
assert_html_has_tag(actual_html, 'link', :rel => "stylesheet", :type => "text/css", :count => 3)
|
280
|
+
assert_html_has_tag(actual_html, 'link', :href => "/stylesheets/style.css?#{time.to_i}")
|
281
|
+
assert_html_has_tag(actual_html, 'link', :href => "/stylesheets/layout.css?#{time.to_i}")
|
282
|
+
assert_html_has_tag(actual_html, 'link', :href => "http://google.com/style.css")
|
286
283
|
assert_equal actual_html, stylesheet_link_tag(['style', 'layout.css', 'http://google.com/style.css'])
|
287
284
|
end
|
288
285
|
|
289
286
|
it 'should not use a timestamp if stamp setting is false' do
|
290
287
|
self.class.expects(:asset_stamp).returns(false)
|
291
288
|
expected_options = { :rel => "stylesheet", :type => "text/css" }
|
292
|
-
|
289
|
+
assert_html_has_tag(stylesheet_link_tag('style'), 'link', expected_options.merge(:href => "/stylesheets/style.css"))
|
293
290
|
end
|
294
291
|
|
295
292
|
it 'should display stylesheet link used custom options' do
|
296
|
-
|
293
|
+
assert_html_has_tag(stylesheet_link_tag('style', :media => 'screen'), 'link', :rel => 'stylesheet', :media => 'screen')
|
297
294
|
end
|
298
295
|
end
|
299
296
|
|
@@ -301,7 +298,7 @@ describe "AssetTagHelpers" do
|
|
301
298
|
it 'should display javascript item' do
|
302
299
|
time = stop_time_for_test
|
303
300
|
actual_html = javascript_include_tag('application')
|
304
|
-
|
301
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js?#{time.to_i}", :type => "text/javascript")
|
305
302
|
assert actual_html.html_safe?
|
306
303
|
end
|
307
304
|
|
@@ -310,60 +307,58 @@ describe "AssetTagHelpers" do
|
|
310
307
|
self.class.stubs(:js_asset_folder).returns('js')
|
311
308
|
assert_equal 'js', asset_folder_name(:js)
|
312
309
|
actual_html = javascript_include_tag('application')
|
313
|
-
|
310
|
+
assert_html_has_tag(actual_html, 'script', :src => "/js/application.js?#{time.to_i}", :type => "text/javascript")
|
314
311
|
end
|
315
312
|
|
316
313
|
it 'should display javascript item for long relative path' do
|
317
314
|
time = stop_time_for_test
|
318
315
|
actual_html = javascript_include_tag('example/demo/application')
|
319
|
-
|
316
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/example/demo/application.js?#{time.to_i}", :type => "text/javascript")
|
320
317
|
end
|
321
318
|
|
322
319
|
it 'should display javascript item for path containing js' do
|
323
320
|
time = stop_time_for_test
|
324
321
|
actual_html = javascript_include_tag 'test/jquery.json'
|
325
|
-
|
322
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/test/jquery.json?#{time.to_i}", :type => "text/javascript")
|
326
323
|
end
|
327
324
|
|
328
325
|
it 'should display javascript item for path containing period' do
|
329
326
|
time = stop_time_for_test
|
330
327
|
actual_html = javascript_include_tag 'test/jquery.min'
|
331
|
-
|
328
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/test/jquery.min.js?#{time.to_i}", :type => "text/javascript")
|
332
329
|
end
|
333
330
|
|
334
331
|
it 'should display javascript item with absolute path' do
|
335
|
-
time = stop_time_for_test
|
336
332
|
actual_html = javascript_include_tag('/js/application')
|
337
|
-
|
333
|
+
assert_html_has_tag(actual_html, 'script', :src => "/js/application.js", :type => "text/javascript")
|
338
334
|
end
|
339
335
|
|
340
336
|
it 'should display javascript item with uri root' do
|
341
337
|
self.class.stubs(:uri_root).returns("/blog")
|
342
338
|
time = stop_time_for_test
|
343
339
|
actual_html = javascript_include_tag('application')
|
344
|
-
|
340
|
+
assert_html_has_tag(actual_html, 'script', :src => "/blog/javascripts/application.js?#{time.to_i}", :type => "text/javascript")
|
345
341
|
end
|
346
342
|
|
347
343
|
it 'should not append extension to absolute paths' do
|
348
|
-
time = stop_time_for_test
|
349
344
|
actual_html = javascript_include_tag('https://maps.googleapis.com/maps/api/js?key=value&sensor=false')
|
350
|
-
|
345
|
+
assert_html_has_tag(actual_html, 'script', :src => "https://maps.googleapis.com/maps/api/js?key=value&sensor=false")
|
351
346
|
end
|
352
347
|
|
353
348
|
it 'should display javascript items' do
|
354
349
|
time = stop_time_for_test
|
355
350
|
actual_html = javascript_include_tag('application', 'base.js', 'http://google.com/lib.js')
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
351
|
+
assert_html_has_tag(actual_html, 'script', :type => "text/javascript", :count => 3)
|
352
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js?#{time.to_i}")
|
353
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/base.js?#{time.to_i}")
|
354
|
+
assert_html_has_tag(actual_html, 'script', :src => "http://google.com/lib.js")
|
360
355
|
assert_equal actual_html, javascript_include_tag(['application', 'base.js', 'http://google.com/lib.js'])
|
361
356
|
end
|
362
357
|
|
363
358
|
it 'should not use a timestamp if stamp setting is false' do
|
364
359
|
self.class.expects(:asset_stamp).returns(false)
|
365
360
|
actual_html = javascript_include_tag('application')
|
366
|
-
|
361
|
+
assert_html_has_tag(actual_html, 'script', :src => "/javascripts/application.js", :type => "text/javascript")
|
367
362
|
end
|
368
363
|
end
|
369
364
|
|
@@ -371,33 +366,33 @@ describe "AssetTagHelpers" do
|
|
371
366
|
it 'should display favicon' do
|
372
367
|
time = stop_time_for_test
|
373
368
|
actual_html = favicon_tag('icons/favicon.png')
|
374
|
-
|
369
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/png', :href => "/images/icons/favicon.png?#{time.to_i}")
|
375
370
|
end
|
376
371
|
|
377
372
|
it 'should match type with file ext' do
|
378
373
|
time = stop_time_for_test
|
379
374
|
actual_html = favicon_tag('favicon.ico')
|
380
|
-
|
375
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.ico?#{time.to_i}")
|
381
376
|
end
|
382
377
|
|
383
378
|
it 'should allow option overrides' do
|
384
379
|
time = stop_time_for_test
|
385
380
|
actual_html = favicon_tag('favicon.png', :type => 'image/ico')
|
386
|
-
|
381
|
+
assert_html_has_tag(actual_html, 'link', :rel => 'icon', :type => 'image/ico', :href => "/images/favicon.png?#{time.to_i}")
|
387
382
|
end
|
388
383
|
end
|
389
384
|
|
390
385
|
describe 'for #feed_tag method' do
|
391
386
|
it 'should generate correctly link tag for rss' do
|
392
|
-
|
387
|
+
assert_html_has_tag(feed_tag(:rss, "/blog/post.rss"), 'link', :type => 'application/rss+xml', :rel => 'alternate', :href => "/blog/post.rss", :title => 'rss')
|
393
388
|
end
|
394
389
|
|
395
390
|
it 'should generate correctly link tag for atom' do
|
396
|
-
|
391
|
+
assert_html_has_tag(feed_tag(:atom, "/blog/post.atom"), 'link', :type => 'application/atom+xml', :rel => 'alternate', :href => "/blog/post.atom", :title => 'atom')
|
397
392
|
end
|
398
393
|
|
399
394
|
it 'should override options' do
|
400
|
-
|
395
|
+
assert_html_has_tag(feed_tag(:rss, "/blog/post.rss", :type => "my-type", :rel => "my-rel", :title => "my-title"), 'link', :type => 'my-type', :rel => 'my-rel', :href => "/blog/post.rss", :title => 'my-title')
|
401
396
|
end
|
402
397
|
end
|
403
398
|
|