mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Merge pull request #15312 from JuanitoFatas/action_view/asset_path"
This reverts commit 21ec7fefea
.
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.
This commit is contained in:
parent
75e06a197f
commit
457c876b15
2 changed files with 12 additions and 1 deletions
|
@ -121,8 +121,8 @@ module ActionView
|
|||
# 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 @@ class AssetTagHelperTest < ActionView::TestCase
|
|||
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")
|
||||
|
|
Loading…
Reference in a new issue