Removed the deprecated behavior of appending ".png" to image_tag/image_path...

Removed the deprecated behavior of appending ".png" to image_tag/image_path calls without an existing extension [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7432 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 44a17875
*SVN*
* Removed the deprecated behavior of appending ".png" to image_tag/image_path calls without an existing extension [DHH]
* Removed ActionController::Base.scaffold -- it went through the whole idea of scaffolding (card board walls you remove and tweak one by one). Use the scaffold generator instead (it does resources too now!) [DHH]
* Optimise named route generation when using positional arguments. [Koz]
......
......@@ -319,25 +319,17 @@ def stylesheet_link_tag(*sources)
# a filename without an extension is deprecated.
#
# ==== Examples
# image_path("edit.png") # => /images/edit.png
# image_path("icons/edit.png") # => /images/icons/edit.png
# image_path("/icons/edit.png") # => /icons/edit.png
# image_path("edit") # => /images/edit
# image_path("edit.png") # => /images/edit.png
# image_path("icons/edit.png") # => /images/icons/edit.png
# image_path("/icons/edit.png") # => /icons/edit.png
# image_path("http://www.railsapplication.com/img/edit.png") # => http://www.railsapplication.com/img/edit.png
def image_path(source)
unless (source.split("/").last || source).include?(".") || source.blank?
ActiveSupport::Deprecation.warn(
"You've called image_path with a source that doesn't include an extension. " +
"In Rails 2.0, that will not result in .png automatically being appended. " +
"So you should call image_path('#{source}.png') instead", caller
)
end
compute_public_path(source, 'images', 'png')
compute_public_path(source, 'images')
end
# Returns an html image tag for the +source+. The +source+ can be a full
# path or a file that exists in your public images directory. Note that
# specifying a filename without the extension is now deprecated in Rails.
# path or a file that exists in your public images directory.
#
# ==== Options
# You can add HTML attributes using the +options+. The +options+ supports
......@@ -350,6 +342,8 @@ def image_path(source)
# value is not in the correct format.
#
# ==== Examples
# image_tag("icon") # =>
# <img src="/images/icon" alt="Icon" />
# image_tag("icon.png") # =>
# <img src="/images/icon.png" alt="Icon" />
# image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # =>
......@@ -380,8 +374,8 @@ def image_tag(source, options = {})
# roots. Rewrite the asset path for cache-busting asset ids. Include
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
def compute_public_path(source, dir, ext, include_host = true)
source += ".#{ext}" if File.extname(source).blank?
def compute_public_path(source, dir, ext = nil, include_host = true)
source += ".#{ext}" if File.extname(source).blank? && ext
if source =~ %r{^[-a-z]+://}
source
......
......@@ -98,8 +98,9 @@ def teardown
}
ImagePathToTag = {
%(image_path("xml.png")) => %(/images/xml.png),
%(image_path("dir/xml.png")) => %(/images/dir/xml.png),
%(image_path("xml")) => %(/images/xml),
%(image_path("xml.png")) => %(/images/xml.png),
%(image_path("dir/xml.png")) => %(/images/dir/xml.png),
%(image_path("/dir/xml.png")) => %(/dir/xml.png)
}
......@@ -114,10 +115,6 @@ def teardown
%(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="Rails" src="http://www.rubyonrails.com/images/rails.png" />)
}
DeprecatedImagePathToTag = {
%(image_path("xml")) => %(/images/xml.png)
}
def test_auto_discovery_link_tag
AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
......@@ -160,12 +157,6 @@ def test_image_tag
ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
end
def test_should_deprecate_image_filename_with_no_extension
DeprecatedImagePathToTag.each do |method, tag|
assert_deprecated("image_path") { assert_dom_equal(tag, eval(method)) }
end
end
def test_timebased_asset_id
expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s
assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册