Skip to content

Commit

Permalink
Tagged Rails 2.0.2
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/tags/rel_2-0-2@8430 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Dec 17, 2007
1 parent 7af985f commit c8da518
Show file tree
Hide file tree
Showing 33 changed files with 276 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -11,7 +11,7 @@ end
desc 'Run all tests by default'
task :default => :test

%w(test docs package pgem release).each do |task_name|
%w(test rdoc package pgem release).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
PROJECTS.each do |project|
Expand Down
5 changes: 5 additions & 0 deletions actionmailer/CHANGELOG
@@ -1,3 +1,8 @@
*2.0.2* (December 16th, 2007)

* Included in Rails 2.0.2


*2.0.1* (December 7th, 2007)

* Update ActionMailer so it treats ActionView the same way that ActionController does. Closes #10244 [rick]
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/Rakefile
Expand Up @@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
s.rubyforge_project = "actionmailer"
s.homepage = "http://www.rubyonrails.org"

s.add_dependency('actionpack', '= 2.0.1' + PKG_BUILD)
s.add_dependency('actionpack', '= 2.0.2' + PKG_BUILD)

s.has_rdoc = true
s.requirements << 'none'
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/version.rb
Expand Up @@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 2
MINOR = 0
TINY = 1
TINY = 2

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
18 changes: 17 additions & 1 deletion actionpack/CHANGELOG
@@ -1,4 +1,20 @@
*SVN*
*2.0.2* (December 16th, 2007)

* Added delete_via_redirect and put_via_redirect to integration testing #10497 [philodespotos]

* Allow headers['Accept'] to be set by hand when calling xml_http_request #10461 [BMorearty]

* Added OPTIONS to list of default accepted HTTP methods #10449 [holoway]

* Added option to pass proc to ActionController::Base.asset_host for maximum configurability #10521 [chuyeow]. Example:

ActionController::Base.asset_host = Proc.new { |source|
if source.starts_with?('/images')
"http://images.example.com"
else
"http://assets.example.com"
end
}

* Fixed that ActionView#file_exists? would be incorrect if @first_render is set #10569 [dbussink]

Expand Down
2 changes: 1 addition & 1 deletion actionpack/Rakefile
Expand Up @@ -76,7 +76,7 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.requirements << 'none'

s.add_dependency('activesupport', '= 2.0.1' + PKG_BUILD)
s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD)

s.require_path = 'lib'
s.autorequire = 'action_controller'
Expand Down
43 changes: 29 additions & 14 deletions actionpack/lib/action_controller/integration.rb
Expand Up @@ -121,23 +121,38 @@ def follow_redirect!
status
end

# Performs a GET request, following any subsequent redirect. Note that
# the redirects are followed until the response is not a redirect--this
# means you may run into an infinite loop if your redirect loops back to
# itself. Headers are treated in the same way as #get.
def get_via_redirect(path, args={}, headers = {})
get path, args, headers
# Performs a request using the specified method, following any subsequent
# redirect. Note that the redirects are followed until the response is
# not a redirect--this means you may run into an infinite loop if your
# redirect loops back to itself.
def request_via_redirect(http_method, path, parameters = nil, headers = nil)
send(http_method, path, parameters, headers)
follow_redirect! while redirect?
status
end

# Performs a POST request, following any subsequent redirect. This is
# vulnerable to infinite loops, the same as #get_via_redirect. Headers are
# treated in the same way as #get.
def post_via_redirect(path, args={}, headers = {})
post path, args, headers
follow_redirect! while redirect?
status
# Performs a GET request, following any subsequent redirect.
# See #request_via_redirect() for more information.
def get_via_redirect(path, parameters = nil, headers = nil)
request_via_redirect(:get, path, parameters, headers)
end

# Performs a POST request, following any subsequent redirect.
# See #request_via_redirect() for more information.
def post_via_redirect(path, parameters = nil, headers = nil)
request_via_redirect(:post, path, parameters, headers)
end

# Performs a PUT request, following any subsequent redirect.
# See #request_via_redirect() for more information.
def put_via_redirect(path, parameters = nil, headers = nil)
request_via_redirect(:put, path, parameters, headers)
end

# Performs a DELETE request, following any subsequent redirect.
# See #request_via_redirect() for more information.
def delete_via_redirect(path, parameters = nil, headers = nil)
request_via_redirect(:delete, path, parameters, headers)
end

# Returns +true+ if the last response was a redirect.
Expand Down Expand Up @@ -187,7 +202,7 @@ def head(path, parameters = nil, headers = nil)
def xml_http_request(request_method, path, parameters = nil, headers = nil)
headers ||= {}
headers['X-Requested-With'] = 'XMLHttpRequest'
headers['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*'
headers['Accept'] ||= 'text/javascript, text/html, application/xml, text/xml, */*'

process(request_method, path, parameters, headers)
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/request.rb
Expand Up @@ -4,7 +4,7 @@

module ActionController
# HTTP methods which are accepted by default.
ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete ))
ACCEPTED_HTTP_METHODS = Set.new(%w( get head put post delete options ))

# CgiRequest and TestRequest provide concrete implementations.
class AbstractRequest
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/session/cookie_store.rb
Expand Up @@ -35,7 +35,7 @@
# such as 'MD5', 'RIPEMD160', 'SHA256', etc.
#
# To generate a secret key for an existing application, run
# `rake generate:secret` and set the key in config/environment.rb
# `rake secret` and set the key in config/environment.rb
#
# Note that changing digest or secret invalidates all existing sessions!
class CGI::Session::CookieStore
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_pack/version.rb
Expand Up @@ -2,7 +2,7 @@ module ActionPack #:nodoc:
module VERSION #:nodoc:
MAJOR = 2
MINOR = 0
TINY = 1
TINY = 2

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
46 changes: 38 additions & 8 deletions actionpack/lib/action_view/helpers/asset_tag_helper.rb
Expand Up @@ -31,14 +31,40 @@ module Helpers #:nodoc:
# stylesheet_include_tag("application")
# => <link href="http://assets3.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
#
# To do this, you can either setup four actual hosts, or you can use wildcard DNS to CNAME
# To do this, you can either setup 4 actual hosts, or you can use wildcard DNS to CNAME
# the wildcard to a single asset host. You can read more about setting up your DNS CNAME records from
# your ISP.
#
# Note: This is purely a browser performance optimization and is not meant
# for server load balancing. See http://www.die.net/musings/page_load_time/
# for background.
#
# Alternatively, you can exert more control over the asset host by setting <tt>asset_host</tt> to a proc
# that takes a single source argument. This is useful if you are unable to setup 4 actual hosts or have
# fewer/more than 4 hosts. The example proc below generates http://assets1.example.com and
# http://assets2.example.com randomly.
#
# ActionController::Base.asset_host = Proc.new { |source| "http://assets#{rand(2) + 1}.example.com" }
# image_tag("rails.png")
# => <img src="http://assets2.example.com/images/rails.png" alt="Rails" />
# stylesheet_include_tag("application")
# => <link href="http://assets1.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
#
# The proc takes a single <tt>source</tt> parameter which is the path of the source asset. This can be used to
# generate a particular asset host depending on the asset path.
#
# ActionController::Base.asset_host = Proc.new { |source|
# if source.starts_with?('/images')
# "http://images.example.com"
# else
# "http://assets.example.com"
# end
# }
# image_tag("rails.png")
# => <img src="http://images.example.com/images/rails.png" alt="Rails" />
# stylesheet_include_tag("application")
# => <link href="http://assets.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
#
# === Using asset timestamps
#
# By default, Rails will append all asset paths with that asset's timestamp. This allows you to set a cache-expiration date for the
Expand Down Expand Up @@ -385,19 +411,18 @@ def file_exist?(path)
# Add the .ext if not present. Return full URLs otherwise untouched.
# Prefix with /dir/ if lacking a leading /. Account for relative URL
# roots. Rewrite the asset path for cache-busting asset ids. Include
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
# asset host, if configured, with the correct request protocol.
def compute_public_path(source, dir, ext = nil, include_host = true)
has_request = @controller.respond_to?(:request)

cache_key =
if has_request
[ @controller.request.protocol,
ActionController::Base.asset_host,
ActionController::Base.asset_host.to_s,
@controller.request.relative_url_root,
dir, source, ext, include_host ].join
else
[ ActionController::Base.asset_host,
[ ActionController::Base.asset_host.to_s,
dir, source, ext, include_host ].join
end

Expand Down Expand Up @@ -430,11 +455,16 @@ def compute_public_path(source, dir, ext = nil, include_host = true)
end

# Pick an asset host for this source. Returns nil if no host is set,
# the host if no wildcard is set, or the host interpolated with the
# numbers 0-3 if it contains %d. The number is the source hash mod 4.
# the host if no wildcard is set, the host interpolated with the
# numbers 0-3 if it contains %d (the number is the source hash mod 4),
# or the value returned from invoking the proc if it's a proc.
def compute_asset_host(source)
if host = ActionController::Base.asset_host
host % (source.hash % 4)
if host.is_a?(Proc)
host.call(source)
else
host % (source.hash % 4)
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -287,8 +287,8 @@ def simple_format(text)
#
# ==== Examples
# auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com")
# # => "Go to <a href="http://www.rubyonrails.org">http://www.rubyonrails.org</a> and
# # say hello to <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>"
# # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> and
# # say hello to <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
#
# auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :urls)
# # => "Visit <a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a>
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template_handlers/erb.rb
Expand Up @@ -5,7 +5,7 @@ module Util
HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }

def html_escape(s)
s.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
end
end
end
Expand Down
52 changes: 41 additions & 11 deletions actionpack/test/controller/integration_test.rb
Expand Up @@ -49,28 +49,49 @@ def test_follow_redirect_calls_get_and_returns_status
assert_equal 200, @session.follow_redirect!
end

def test_get_via_redirect
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }

@session.expects(:get).with(path,args,headers)
def test_request_via_redirect_uses_given_method
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
@session.expects(:put).with(path, args, headers)
@session.stubs(:redirect?).returns(false)
@session.request_via_redirect(:put, path, args, headers)
end

def test_request_via_redirect_follows_redirects
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
@session.stubs(:redirect?).returns(true, true, false)
@session.expects(:follow_redirect!).times(2)
@session.request_via_redirect(:get, path, args, headers)
end

def test_request_via_redirect_returns_status
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
@session.stubs(:redirect?).returns(false)
@session.stubs(:status).returns(200)
assert_equal 200, @session.get_via_redirect(path, args, headers)
assert_equal 200, @session.request_via_redirect(:get, path, args, headers)
end

def test_post_via_redirect
def test_get_via_redirect
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
@session.expects(:request_via_redirect).with(:get, path, args, headers)
@session.get_via_redirect(path, args, headers)
end

@session.expects(:post).with(path,args,headers)
def test_post_via_redirect
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
@session.expects(:request_via_redirect).with(:post, path, args, headers)
@session.post_via_redirect(path, args, headers)
end

@session.stubs(:redirect?).returns(true, true, false)
@session.expects(:follow_redirect!).times(2)
def test_put_via_redirect
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
@session.expects(:request_via_redirect).with(:put, path, args, headers)
@session.put_via_redirect(path, args, headers)
end

@session.stubs(:status).returns(200)
assert_equal 200, @session.post_via_redirect(path, args, headers)
def test_delete_via_redirect
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
@session.expects(:request_via_redirect).with(:delete, path, args, headers)
@session.delete_via_redirect(path, args, headers)
end

def test_url_for_with_controller
Expand Down Expand Up @@ -179,6 +200,15 @@ def test_xml_http_request_head
@session.expects(:process).with(:head,path,params,headers_after_xhr)
@session.xml_http_request(:head,path,params,headers)
end

def test_xml_http_request_override_accept
path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"}
headers_after_xhr = headers.merge(
"X-Requested-With" => "XMLHttpRequest"
)
@session.expects(:process).with(:post,path,params,headers_after_xhr)
@session.xml_http_request(:post,path,params,headers)
end
end

class IntegrationTestTest < Test::Unit::TestCase
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/request_test.rb
Expand Up @@ -316,7 +316,7 @@ def test_invalid_http_method_raises_exception

def test_allow_method_hacking_on_post
set_request_method_to :post
[:get, :head, :put, :post, :delete].each do |method|
[:get, :head, :options, :put, :post, :delete].each do |method|
@request.instance_eval { @parameters = { :_method => method } ; @request_method = nil }
assert_equal(method == :head ? :get : method, @request.method)
end
Expand Down

0 comments on commit c8da518

Please sign in to comment.