From e1724b553e25339cd09df325523cce2f76f464f0 Mon Sep 17 00:00:00 2001
From: Rodrigo Pavano
Date: Tue, 1 May 2012 19:18:53 -0300
Subject: Documentation fix in options_for_select helper. Fixed display errors
caused by mixing Ruby and HTML code inside the same pre tag [ci skip]
---
.../lib/action_view/helpers/form_options_helper.rb | 35 ++++++++++++++++------
1 file changed, 26 insertions(+), 9 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index d61c2bbee2..cafcd93f58 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -288,38 +288,55 @@ module ActionView
#
# Examples (call, result):
# options_for_select([["Dollar", "$"], ["Kroner", "DKK"]])
- # \n
+ # #
+ # #
#
# options_for_select([ "VISA", "MasterCard" ], "MasterCard")
- # \n
+ # #
+ # #
#
# options_for_select({ "Basic" => "$20", "Plus" => "$40" }, "$40")
- # \n
+ # #
+ # #
#
# options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"])
- # \n\n
+ # #
+ # #
+ # #
#
# You can optionally provide html attributes as the last element of the array.
#
# Examples:
# options_for_select([ "Denmark", ["USA", {:class => 'bold'}], "Sweden" ], ["USA", "Sweden"])
- # \n\n
+ # #
+ # #
+ # #
#
# options_for_select([["Dollar", "$", {:class => "bold"}], ["Kroner", "DKK", {:onclick => "alert('HI');"}]])
- # \n
+ # #
+ # #
#
# If you wish to specify disabled option tags, set +selected+ to be a hash, with :disabled being either a value
# or array of values to be disabled. In this case, you can use :selected to specify selected option tags.
#
# Examples:
# options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => "Super Platinum")
- # \n\n\n
+ # #
+ # #
+ # #
+ # #
#
# options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => ["Advanced", "Super Platinum"])
- # \n\n\n
+ # #
+ # #
+ # #
+ # #
#
# options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :selected => "Free", :disabled => "Super Platinum")
- # \n\n\n
+ # #
+ # #
+ # #
+ # #
#
# NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
def options_for_select(container, selected = nil)
--
cgit v1.2.3
From 7b9faf7b283c55d35124a3c665f170663994124b Mon Sep 17 00:00:00 2001
From: Alexey Vakhov
Date: Wed, 2 May 2012 09:20:50 +0400
Subject: Fix form tag with non GET/POST method example
---
actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index b5e0970612..ef35a411ad 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -45,7 +45,7 @@ module ActionView
# # =>
+
+<%= render :template => "rescues/_trace" %>
--
cgit v1.2.3
From ce9e2534bfe68a1e14b686632cf848909558c098 Mon Sep 17 00:00:00 2001
From: Anuj Dutta
Date: Thu, 3 May 2012 00:56:28 +0000
Subject: Corrected the name of the module that should be included to get the
url helpers.
---
actionpack/lib/action_dispatch/routing/url_for.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index d75bb1c2de..ee02f4b531 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -68,7 +68,7 @@ module ActionDispatch
# This generates, among other things, the method users_path. By default,
# this method is accessible from your controllers, views and mailers. If you need
# to access this auto-generated method from other places (such as a model), then
- # you can do that by including ActionController::UrlFor in your class:
+ # you can do that by including Rails.application.routes.url_helpers in your class:
#
# class User < ActiveRecord::Base
# include Rails.application.routes.url_helpers
--
cgit v1.2.3
From e821611cb6142d2055de565fabe783ffd6ef4cfb Mon Sep 17 00:00:00 2001
From: Paul McMahon
Date: Thu, 3 May 2012 18:02:25 +0900
Subject: use extract_options!
---
actionpack/lib/action_dispatch/routing/redirection.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb
index 444a79c50d..95c588c00a 100644
--- a/actionpack/lib/action_dispatch/routing/redirection.rb
+++ b/actionpack/lib/action_dispatch/routing/redirection.rb
@@ -1,5 +1,6 @@
require 'action_dispatch/http/request'
require 'active_support/core_ext/uri'
+require 'active_support/core_ext/array/extract_options'
require 'rack/utils'
module ActionDispatch
@@ -99,7 +100,7 @@ module ActionDispatch
# match 'accounts/:name' => redirect(SubdomainRedirector.new('api'))
#
def redirect(*args, &block)
- options = args.last.is_a?(Hash) ? args.pop : {}
+ options = args.extract_options!
status = options.delete(:status) || 301
return OptionRedirect.new(status, options) if options.any?
--
cgit v1.2.3
From a544e006814a1ef82db6af50637eee3d35740c39 Mon Sep 17 00:00:00 2001
From: Andy Lindeman
Date: Thu, 3 May 2012 09:16:38 -0400
Subject: Allows assert_redirected_to to accept a regular expression
---
.../action_dispatch/testing/assertions/response.rb | 33 +++++++++++++---------
1 file changed, 20 insertions(+), 13 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index 40d38c59d6..8f6fff5d32 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -53,15 +53,18 @@ module ActionDispatch
# # assert that the redirection was to the url for @customer
# assert_redirected_to @customer
#
+ # # asserts that the redirection matches the regular expression
+ # assert_redirected_to %r(\Ahttp://example.org)
+ #
def assert_redirected_to(options = {}, message=nil)
assert_response(:redirect, message)
- return true if options == @response.location
+ return true if options === @response.location
redirect_is = normalize_argument_to_redirection(@response.location)
redirect_expected = normalize_argument_to_redirection(options)
message ||= "Expected response to be a redirect to <#{redirect_expected}> but was a redirect to <#{redirect_is}>"
- assert_equal redirect_expected, redirect_is, message
+ assert_operator redirect_expected, :===, redirect_is, message
end
private
@@ -71,17 +74,21 @@ module ActionDispatch
end
def normalize_argument_to_redirection(fragment)
- case fragment
- when %r{^\w[A-Za-z\d+.-]*:.*}
- fragment
- when String
- @request.protocol + @request.host_with_port + fragment
- when :back
- raise RedirectBackError unless refer = @request.headers["Referer"]
- refer
- else
- @controller.url_for(fragment)
- end.delete("\0\r\n")
+ normalized = case fragment
+ when Regexp
+ fragment
+ when %r{^\w[A-Za-z\d+.-]*:.*}
+ fragment
+ when String
+ @request.protocol + @request.host_with_port + fragment
+ when :back
+ raise RedirectBackError unless refer = @request.headers["Referer"]
+ refer
+ else
+ @controller.url_for(fragment)
+ end
+
+ normalized.respond_to?(:delete) ? normalized.delete("\0\r\n") : normalized
end
end
end
--
cgit v1.2.3
From 1ab0523cfd405f2f8097841405947c0d26b72150 Mon Sep 17 00:00:00 2001
From: Bogdan Gusiev
Date: Thu, 3 May 2012 18:44:12 +0300
Subject: RouteSet: optimize routes generation when globbing is used
---
actionpack/lib/action_dispatch/routing/route_set.rb | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 57ce7b4ba9..7abd7bd008 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -202,7 +202,7 @@ module ActionDispatch
# Clause check about when we need to generate an optimized helper.
def optimize_helper?(route) #:nodoc:
- route.ast.grep(Journey::Nodes::Star).empty? && route.requirements.except(:controller, :action).empty?
+ route.requirements.except(:controller, :action).empty?
end
# Generates the interpolation to be used in the optimized helper.
@@ -214,7 +214,10 @@ module ActionDispatch
end
route.required_parts.each_with_index do |part, i|
- string_route.gsub!(part.inspect, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}")
+ # Replace each route parameter
+ # e.g. :id for regular parameter or *path for globbing
+ # with ruby string interpolation code
+ string_route.gsub!(/(\*|:)#{part}/, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}")
end
string_route
--
cgit v1.2.3
From 8eedd1a4a7bed400d0daed1fecafc4f84c5561f2 Mon Sep 17 00:00:00 2001
From: twinturbo
Date: Thu, 3 May 2012 15:47:02 -0700
Subject: Make ActionController#head pass rack-link
---
actionpack/lib/action_controller/metal/head.rb | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index a618533d09..802c44cc73 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -27,8 +27,27 @@ module ActionController
self.status = status
self.location = url_for(location) if location
- self.content_type = Mime[formats.first] if formats
+
+ if include_content_type?(self.status)
+ self.content_type = Mime[formats.first] if formats
+ else
+ headers.delete('Content-Type')
+ end
+
self.response_body = " "
end
+
+ private
+ # :nodoc:
+ def include_content_type?(status)
+ case status
+ when 100..199
+ false
+ when 204, 205, 304
+ false
+ else
+ true
+ end
+ end
end
end
--
cgit v1.2.3
From 8edd21c66fee41f755cf962e898646005ae866c0 Mon Sep 17 00:00:00 2001
From: twinturbo
Date: Thu, 3 May 2012 17:24:05 -0700
Subject: Remove content-length as well
---
actionpack/lib/action_controller/metal/head.rb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'actionpack/lib')
diff --git a/actionpack/lib/action_controller/metal/head.rb b/actionpack/lib/action_controller/metal/head.rb
index 802c44cc73..5bdbde9ebb 100644
--- a/actionpack/lib/action_controller/metal/head.rb
+++ b/actionpack/lib/action_controller/metal/head.rb
@@ -28,10 +28,11 @@ module ActionController
self.status = status
self.location = url_for(location) if location
- if include_content_type?(self.status)
+ if include_content_headers?(self.status)
self.content_type = Mime[formats.first] if formats
else
headers.delete('Content-Type')
+ headers.delete('Content-Length')
end
self.response_body = " "
@@ -39,7 +40,7 @@ module ActionController
private
# :nodoc:
- def include_content_type?(status)
+ def include_content_headers?(status)
case status
when 100..199
false
--
cgit v1.2.3