aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-09 13:31:42 +0200
committerXavier Noria <fxn@hashref.com>2010-08-09 13:31:42 +0200
commit4434e407e93001409605e5f02650b591a0cede32 (patch)
tree11ff28e8255364f1fc2b9efce386d61afadd84f0 /actionpack/lib/action_dispatch
parentd87c57bf3e5718c6995ecc73cf8d7396e3ba4b19 (diff)
downloadrails-4434e407e93001409605e5f02650b591a0cede32.tar.gz
rails-4434e407e93001409605e5f02650b591a0cede32.tar.bz2
rails-4434e407e93001409605e5f02650b591a0cede32.zip
adds URL to the body generated by the redirect macro in the routes mapper as per the RFC, extracts common test pattern into a test macro, adds a test to cover the :status option
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 526c97ff8e..c118c72440 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1,3 +1,4 @@
+require 'erb'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/object/blank'
@@ -277,7 +278,6 @@ module ActionDispatch
path = args.shift || block
path_proc = path.is_a?(Proc) ? path : proc { |params| path % params }
status = options[:status] || 301
- body = 'Moved Permanently'
lambda do |env|
req = Request.new(env)
@@ -290,11 +290,14 @@ module ActionDispatch
uri.host ||= req.host
uri.port ||= req.port unless req.port == 80
+ body = %(<html><body>You are being <a href="#{ERB::Util.h(uri.to_s)}">redirected</a>.</body></html>)
+
headers = {
'Location' => uri.to_s,
'Content-Type' => 'text/html',
'Content-Length' => body.length.to_s
}
+
[ status, headers, [body] ]
end
end