Seperate asset directories
This commit is contained in:
parent
651d371a24
commit
77d8f7a4b7
@ -48,7 +48,9 @@ def compute_sprockets_path(source, dir, default_ext)
|
||||
end
|
||||
|
||||
# Fingerprint url
|
||||
source = assets.path(source, config.perform_caching)
|
||||
if source =~ /^\/#{dir}\/(.+)/
|
||||
source = assets.path($1, config.perform_caching, dir)
|
||||
end
|
||||
|
||||
host = compute_asset_host(source)
|
||||
|
||||
|
@ -20,7 +20,10 @@ def host_with_port() 'localhost' end
|
||||
@controller.request = @request
|
||||
|
||||
@assets = Sprockets::Environment.new
|
||||
@assets.paths << FIXTURES.join("sprockets/app/assets")
|
||||
@assets.paths << FIXTURES.join("sprockets/app/javascripts")
|
||||
@assets.paths << FIXTURES.join("sprockets/app/stylesheets")
|
||||
|
||||
config.perform_caching = true
|
||||
end
|
||||
|
||||
def url_for(*args)
|
||||
@ -28,12 +31,12 @@ def url_for(*args)
|
||||
end
|
||||
|
||||
test "javascript path" do
|
||||
assert_equal "/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
sprockets_javascript_path(:application)
|
||||
|
||||
assert_equal "/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
assert_equal "/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
sprockets_javascript_path("xmlhr")
|
||||
assert_equal "/javascripts/dir/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
assert_equal "/assets/dir/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js",
|
||||
sprockets_javascript_path("dir/xmlhr.js")
|
||||
|
||||
assert_equal "/dir/xmlhr.js",
|
||||
@ -46,24 +49,24 @@ def url_for(*args)
|
||||
end
|
||||
|
||||
test "javascript include tag" do
|
||||
assert_equal '<script src="/javascripts/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
assert_equal '<script src="/assets/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
sprockets_javascript_include_tag(:application)
|
||||
|
||||
assert_equal '<script src="/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
sprockets_javascript_include_tag("xmlhr")
|
||||
assert_equal '<script src="/javascripts/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
|
||||
sprockets_javascript_include_tag("xmlhr.js")
|
||||
assert_equal '<script src="http://www.railsapplication.com/xmlhr" type="text/javascript"></script>',
|
||||
sprockets_javascript_include_tag("http://www.railsapplication.com/xmlhr")
|
||||
end
|
||||
|
||||
test "stylesheet path" do
|
||||
assert_equal "/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
sprockets_stylesheet_path(:application)
|
||||
|
||||
assert_equal "/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
assert_equal "/assets/style-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
sprockets_stylesheet_path("style")
|
||||
assert_equal "/stylesheets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
assert_equal "/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css",
|
||||
sprockets_stylesheet_path("dir/style.css")
|
||||
assert_equal "/dir/style.css",
|
||||
sprockets_stylesheet_path("/dir/style.css")
|
||||
@ -75,19 +78,19 @@ def url_for(*args)
|
||||
end
|
||||
|
||||
test "stylesheet link tag" do
|
||||
assert_equal '<link href="/stylesheets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
assert_equal '<link href="/assets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag(:application)
|
||||
|
||||
assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag("style")
|
||||
assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag("style.css")
|
||||
|
||||
assert_equal '<link href="http://www.railsapplication.com/style.css" media="screen" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag("http://www.railsapplication.com/style.css")
|
||||
assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />',
|
||||
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag("style", :media => "all")
|
||||
assert_equal '<link href="/stylesheets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />',
|
||||
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />',
|
||||
sprockets_stylesheet_link_tag("style", :media => "print")
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user