Skip to content

Commit fd8f0b2

Browse files
committed
stylesheet_link_tag('/stylesheets/application') and similar helpers doesn't throw Sprockets::FileOutsidePaths exception anymore
1 parent c495bfc commit fd8f0b2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

actionpack/lib/sprockets/helpers/rails_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def asset_for(source, ext)
123123
return nil if is_uri?(source)
124124
source = rewrite_extension(source, nil, ext)
125125
asset_environment[source]
126+
rescue Sprockets::FileOutsidePaths
127+
nil
126128
end
127129

128130
def digest_for(logical_path)

actionpack/test/template/sprockets_helper_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def config
219219

220220
@config.assets.compile = true
221221
@config.assets.debug = true
222+
assert_match %r{<script src="/javascripts/application.js" type="text/javascript"></script>},
223+
javascript_include_tag('/javascripts/application')
222224
assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
223225
javascript_include_tag(:application)
224226
end
@@ -264,6 +266,9 @@ def config
264266

265267
@config.assets.compile = true
266268
@config.assets.debug = true
269+
assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />},
270+
stylesheet_link_tag('/stylesheets/application')
271+
267272
assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
268273
stylesheet_link_tag(:application)
269274

0 commit comments

Comments
 (0)