提交 457c876b 编写于 作者: M Matthew Draper

Revert "Merge pull request #15312 from JuanitoFatas/action_view/asset_path"

This reverts commit 21ec7fef.

Per #16911, there's actually a good reason for a "blank" value to have a
useful `to_s` here. So let's also add some tests to prove that.
上级 75e06a19
......@@ -121,8 +121,8 @@ module AssetUrlHelper
# asset_path "application", type: :stylesheet # => /assets/application.css
# asset_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
def asset_path(source, options = {})
return "" unless source.present?
source = source.to_s
return "" unless source.present?
return source if source =~ URI_REGEXP
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
......
......@@ -535,6 +535,17 @@ def test_should_not_modify_source_string
assert_equal copy, source
end
class PlaceholderImage
def blank?; true; end
def to_s; 'no-image-yet.png'; end
end
def test_image_tag_with_blank_placeholder
assert_equal '<img alt="" src="/images/no-image-yet.png" />', image_tag(PlaceholderImage.new, alt: "")
end
def test_image_path_with_blank_placeholder
assert_equal '/images/no-image-yet.png', image_path(PlaceholderImage.new)
end
def test_image_path_with_asset_host_proc_returning_nil
@controller.config.asset_host = Proc.new do |source|
unless source.end_with?("tiff")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册