aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md70
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb7
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb11
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb8
-rw-r--r--actionpack/test/dispatch/rack_test.rb12
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb2
6 files changed, 68 insertions, 42 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 5a3b4dc4a2..248677688f 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,15 @@
## Rails 4.0.0 (unreleased) ##
+* `image_tag` will set the same width and height for image if numerical value
+ passed to `size` option.
+
+ *Nihad Abbasov*
+
+* Deprecate Mime::Type#verify_request? and Mime::Type.browser_generated_types,
+ since they are no longer used inside of Rails, they will be removed in Rails 4.1
+
+ *Michael Grosser*
+
* `ActionDispatch::Http::UploadedFile` now delegates `close` to its tempfile. *Sergio Gil*
* Add `ActionController::StrongParameters`, this module converts `params` hash into
@@ -86,26 +96,26 @@
end
end
-* Add automatic template digests to all CacheHelper#cache calls (originally spiked in the cache_digests plugin) *DHH*
+* Add automatic template digests to all `CacheHelper#cache` calls (originally spiked in the cache_digests plugin) *DHH*
* When building a URL fails, add missing keys provided by Journey. Failed URL
generation now returns a 500 status instead of a 404.
*Richard Schneeman*
-* Deprecate availbility of ActionView::RecordIdentifier in controllers by default.
+* Deprecate availbility of `ActionView::RecordIdentifier` in controllers by default.
It's view specific and can be easily included in controller manually if someone
- really needs it. RecordIdentifier will be removed from ActionController::Base
- in Rails 4.1 *Piotr Sarnacki*
+ really needs it. RecordIdentifier will be removed from `ActionController::Base`
+ in Rails 4.1. *Piotr Sarnacki*
-* Fix ActionView::RecordIdentifier to work as a singleton *Piotr Sarnacki*
+* Fix `ActionView::RecordIdentifier` to work as a singleton. *Piotr Sarnacki*
-* Deprecate Template#mime_type, it will be removed in Rails 4.1 in favor of #type.
+* Deprecate `Template#mime_type`, it will be removed in Rails 4.1 in favor of `#type`.
*Piotr Sarnacki*
-* Move vendored html-scanner from action_controller to action_view directory. If you
+* Move vendored html-scanner from `action_controller` to `action_view` directory. If you
require it directly, please use 'action_view/vendor/html-scanner', reference to
- 'action_controller/vendor/html-scanner' will be removed in Rails 4.1 *Piot Sarnacki*
+ 'action_controller/vendor/html-scanner' will be removed in Rails 4.1. *Piot Sarnacki*
* Fix handling of date selects when using both disabled and discard options.
Fixes #7431.
@@ -116,12 +126,12 @@
Setting `config.session_store` to `:active_record_store` will no longer work and will break
if the `activerecord-session_store` gem isn't available. *Prem Sichanugrist*
-* Fix select_tag when option_tags is nil.
+* Fix `select_tag` when `option_tags` is nil.
Fixes #7404.
*Sandeep Ravichandran*
-* Add Request#formats=(extensions) that lets you set multiple formats directly in a prioritized order *DHH*
+* Add `Request#formats=(extensions)` that lets you set multiple formats directly in a prioritized order.
Example of using this for custom iphone views with an HTML fallback:
@@ -134,6 +144,7 @@
end
end
+ *DHH*
* Add Routing Concerns to declare common routes that can be reused inside
others resources and routes.
@@ -165,9 +176,9 @@
*DHH + Rafael Mendonça França*
-* Add start_hour and end_hour options to the select_hour helper. *Evan Tann*
+* Add `start_hour` and `end_hour` options to the `select_hour` helper. *Evan Tann*
-* Raises an ArgumentError when the first argument in `form_for` contain `nil`
+* Raises an `ArgumentError` when the first argument in `form_for` contain `nil`
or is empty.
*Richard Schneeman*
@@ -209,9 +220,9 @@
*Armand du Plessis*
-* Fixed issue with where Digest authentication would not work behind a proxy. *Arthur Smith*
+* Fixed issue with where digest authentication would not work behind a proxy. *Arthur Smith*
-* Added ActionController::Live. Mix it in to your controller and you can
+* Added `ActionController::Live`. Mix it in to your controller and you can
stream data to the client live. For example:
class FooController < ActionController::Base
@@ -227,7 +238,9 @@
end
end
-* Remove ActionDispatch::Head middleware in favor of Rack::Head. *Santiago Pastorino*
+ *Aaron Patterson*
+
+* Remove `ActionDispatch::Head` middleware in favor of `Rack::Head`. *Santiago Pastorino*
* Deprecate `:confirm` in favor of `:data => { :confirm => "Text" }` option for `button_to`, `button_tag`, `image_submit_tag`, `link_to` and `submit_tag` helpers.
@@ -267,7 +280,7 @@
*Jeremy Friesen*
-* Make possible to use a block in button_to helper if button text is hard
+* Make possible to use a block in `button_to` if the button text is hard
to fit into the name parameter, e.g.:
<%= button_to [:make_happy, @user] do %>
@@ -470,27 +483,28 @@
* Add `:format` option to number_to_percentage *Rodrigo Flores*
-* Add `config.action_view.logger` to configure logger for ActionView. *Rafael Mendonça França*
+* Add `config.action_view.logger` to configure logger for Action View. *Rafael Mendonça França*
-* Deprecated ActionController::Integration in favour of ActionDispatch::Integration
+* Deprecated `ActionController::Integration` in favour of `ActionDispatch::Integration`.
-* Deprecated ActionController::IntegrationTest in favour of ActionDispatch::IntegrationTest
+* Deprecated `ActionController::IntegrationTest` in favour of `ActionDispatch::IntegrationTest`.
-* Deprecated ActionController::PerformanceTest in favour of ActionDispatch::PerformanceTest
+* Deprecated `ActionController::PerformanceTest` in favour of `ActionDispatch::PerformanceTest`.
-* Deprecated ActionController::AbstractRequest in favour of ActionDispatch::Request
+* Deprecated `ActionController::AbstractRequest` in favour of `ActionDispatch::Request`.
-* Deprecated ActionController::Request in favour of ActionDispatch::Request
+* Deprecated `ActionController::Request` in favour of `ActionDispatch::Request`.
-* Deprecated ActionController::AbstractResponse in favour of ActionDispatch::Response
+* Deprecated `ActionController::AbstractResponse` in favour of `ActionDispatch::Response`.
-* Deprecated ActionController::Response in favour of ActionDispatch::Response
+* Deprecated `ActionController::Response` in favour of `ActionDispatch::Response`.
-* Deprecated ActionController::Routing in favour of ActionDispatch::Routing
+* Deprecated `ActionController::Routing` in favour of `ActionDispatch::Routing`.
-* check_box helper with :disabled => true will generate a disabled hidden field to conform with the HTML convention where disabled fields are not submitted with the form.
- This is a behavior change, previously the hidden tag had a value of the disabled checkbox.
- *Tadas Tamosauskas*
+* `check_box helper` with `:disabled => true` will generate a disabled
+ hidden field to conform with the HTML convention where disabled fields are
+ not submitted with the form. This is a behavior change, previously the hidden
+ tag had a value of the disabled checkbox. *Tadas Tamosauskas*
* `favicon_link_tag` helper will now use the favicon in app/assets by default. *Lucas Caton*
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index f86ae26b8a..3d560518e1 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -57,7 +57,6 @@ module Mime
# i.e. following a link, getting an image or posting a form. CSRF protection
# only needs to protect against these types.
@@browser_generated_types = Set.new [:html, :url_encoded_form, :multipart_form, :text]
- cattr_reader :browser_generated_types
attr_reader :symbol
@register_callbacks = []
@@ -276,9 +275,15 @@ module Mime
# Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
# ActionController::RequestForgeryProtection.
def verify_request?
+ ActiveSupport::Deprecation.warn "Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1"
@@browser_generated_types.include?(to_sym)
end
+ def self.browser_generated_types
+ ActiveSupport::Deprecation.warn "Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1"
+ @@browser_generated_types
+ end
+
def html?
@@html_types.include?(to_sym) || @string =~ /html/
end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index db4da6f9c8..27ba57ff58 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -364,9 +364,9 @@ module ActionView
#
# * <tt>:alt</tt> - If no alt text is given, the file name part of the
# +source+ is used (capitalized and without the extension)
- # * <tt>:size</tt> - Supplied as "{Width}x{Height}", so "30x45" becomes
- # width="30" and height="45". <tt>:size</tt> will be ignored if the
- # value is not in the correct format.
+ # * <tt>:size</tt> - Supplied as "{Width}x{Height}" or "{Number}", so "30x45" becomes
+ # width="30" and height="45", and "50" becomes width="50" and height="50".
+ # <tt>:size</tt> will be ignored if the value is not in the correct format.
#
# image_tag("icon")
# # => <img src="/assets/icon" alt="Icon" />
@@ -374,7 +374,7 @@ module ActionView
# # => <img src="/assets/icon.png" alt="Icon" />
# image_tag("icon.png", :size => "16x10", :alt => "Edit Entry")
# # => <img src="/assets/icon.png" width="16" height="10" alt="Edit Entry" />
- # image_tag("/icons/icon.gif", :size => "16x16")
+ # image_tag("/icons/icon.gif", :size => "16")
# # => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" />
# image_tag("/icons/icon.gif", :height => '32', :width => '32')
# # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
@@ -390,7 +390,8 @@ module ActionView
end
if size = options.delete(:size)
- options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
+ options[:width], options[:height] = size.split("x") if size =~ %r{\A\d+x\d+\z}
+ options[:width] = options[:height] = size if size =~ %r{\A\d+\z}
end
tag("img", options)
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index 3e83f3d4fa..e2a9ba782d 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -185,9 +185,11 @@ class MimeTypeTest < ActiveSupport::TestCase
all_types.uniq!
# Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE
all_types.delete_if { |type| !Mime.const_defined?(type.upcase) }
- verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
- assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
- assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ assert_deprecated do
+ verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
+ assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
+ assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ end
end
test "references gives preference to symbols before strings" do
diff --git a/actionpack/test/dispatch/rack_test.rb b/actionpack/test/dispatch/rack_test.rb
index 698f980296..6d239d0a0c 100644
--- a/actionpack/test/dispatch/rack_test.rb
+++ b/actionpack/test/dispatch/rack_test.rb
@@ -176,13 +176,17 @@ end
class RackRequestContentTypeTest < BaseRackTest
test "html content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
- assert @request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
+ assert @request.content_mime_type.verify_request?
+ end
end
test "xml content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::XML.to_s
- assert !@request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::XML.to_s
+ assert !@request.content_mime_type.verify_request?
+ end
end
end
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 25d85c47c7..a04694714d 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -192,9 +192,9 @@ class AssetTagHelperTest < ActionView::TestCase
ImageLinkToTag = {
%(image_tag("xml.png")) => %(<img alt="Xml" src="/images/xml.png" />),
%(image_tag("rss.gif", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.gif" />),
+ %(image_tag("gold.png", :size => "20")) => %(<img alt="Gold" height="20" src="/images/gold.png" width="20" />),
%(image_tag("gold.png", :size => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
%(image_tag("gold.png", "size" => "45x70")) => %(<img alt="Gold" height="70" src="/images/gold.png" width="45" />),
- %(image_tag("error.png", "size" => "45")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("error.png", "size" => "45 x 70")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("error.png", "size" => "x")) => %(<img alt="Error" src="/images/error.png" />),
%(image_tag("google.com.png")) => %(<img alt="Google.com" src="/images/google.com.png" />),