mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix AssetIncludeTag ensuring that files are in the wrong directory [#6015 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
parent
cb8f7a1156
commit
deff528947
2 changed files with 47 additions and 3 deletions
|
@ -57,8 +57,8 @@ module ActionView
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def path_to_asset(source)
|
def path_to_asset(source, include_host = true)
|
||||||
asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension)
|
asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension, include_host)
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute_paths(*args)
|
def compute_paths(*args)
|
||||||
|
@ -77,7 +77,7 @@ module ActionView
|
||||||
|
|
||||||
def ensure_sources!(sources)
|
def ensure_sources!(sources)
|
||||||
sources.each do |source|
|
sources.each do |source|
|
||||||
asset_file_path!(path_to_asset(source))
|
asset_file_path!(path_to_asset(source, false))
|
||||||
end
|
end
|
||||||
return sources
|
return sources
|
||||||
end
|
end
|
||||||
|
|
|
@ -680,6 +680,26 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
|
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_caching_javascript_include_tag_with_named_paths_and_relative_url_root_when_caching_off
|
||||||
|
ENV["RAILS_ASSET_ID"] = ""
|
||||||
|
@controller.config.relative_url_root = "/collaboration/hieraki"
|
||||||
|
config.perform_caching = false
|
||||||
|
|
||||||
|
assert_dom_equal(
|
||||||
|
%(<script src="/collaboration/hieraki/javascripts/robber.js" type="text/javascript"></script>),
|
||||||
|
javascript_include_tag('robber', :cache => true)
|
||||||
|
)
|
||||||
|
|
||||||
|
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js'))
|
||||||
|
|
||||||
|
assert_dom_equal(
|
||||||
|
%(<script src="/collaboration/hieraki/javascripts/robber.js" type="text/javascript"></script>),
|
||||||
|
javascript_include_tag('robber', :cache => "money", :recursive => true)
|
||||||
|
)
|
||||||
|
|
||||||
|
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js'))
|
||||||
|
end
|
||||||
|
|
||||||
def test_caching_javascript_include_tag_when_caching_off
|
def test_caching_javascript_include_tag_when_caching_off
|
||||||
ENV["RAILS_ASSET_ID"] = ""
|
ENV["RAILS_ASSET_ID"] = ""
|
||||||
config.perform_caching = false
|
config.perform_caching = false
|
||||||
|
@ -907,6 +927,30 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
|
FileUtils.rm_f(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def test_caching_stylesheet_link_tag_with_named_paths_and_relative_url_root_when_caching_off
|
||||||
|
ENV["RAILS_ASSET_ID"] = ""
|
||||||
|
@controller.config.relative_url_root = "/collaboration/hieraki"
|
||||||
|
config.perform_caching = false
|
||||||
|
|
||||||
|
assert_dom_equal(
|
||||||
|
%(<link href="/collaboration/hieraki/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
|
||||||
|
stylesheet_link_tag('robber', :cache => true)
|
||||||
|
)
|
||||||
|
|
||||||
|
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))
|
||||||
|
|
||||||
|
assert_dom_equal(
|
||||||
|
%(<link href="/collaboration/hieraki/stylesheets/robber.css" media="screen" rel="stylesheet" type="text/css" />),
|
||||||
|
stylesheet_link_tag('robber', :cache => "money")
|
||||||
|
)
|
||||||
|
|
||||||
|
assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css'))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_caching_stylesheet_include_tag_when_caching_off
|
def test_caching_stylesheet_include_tag_when_caching_off
|
||||||
ENV["RAILS_ASSET_ID"] = ""
|
ENV["RAILS_ASSET_ID"] = ""
|
||||||
config.perform_caching = false
|
config.perform_caching = false
|
||||||
|
|
Loading…
Reference in a new issue