aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/build_original_fullpath_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2011-12-20 20:17:17 +0100
committerPiotr Sarnacki <drogus@gmail.com>2012-01-10 04:39:43 +0100
commit63305daeba3d85442b3a84d4df0c83f59250c7cb (patch)
tree53127670f46fb10da6a9bc46cbbca1318582cf18 /railties/test/application/build_original_fullpath_test.rb
parenta579d4bb5f1ec1166762f9365c5e3bb2c49225dd (diff)
downloadrails-63305daeba3d85442b3a84d4df0c83f59250c7cb.tar.gz
rails-63305daeba3d85442b3a84d4df0c83f59250c7cb.tar.bz2
rails-63305daeba3d85442b3a84d4df0c83f59250c7cb.zip
Add ORIGINAL_FULLPATH to env
This behaves similarly to REQUEST_URI, but we need to implement it on our own because REQUEST_URI is not reliable. Note that since PATH_INFO does not contain information about trailing question mark, this is not 100% accurate, for example `/foo?` will result in `/foo` in ORIGINAL_FULLPATH
Diffstat (limited to 'railties/test/application/build_original_fullpath_test.rb')
-rw-r--r--railties/test/application/build_original_fullpath_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/railties/test/application/build_original_fullpath_test.rb b/railties/test/application/build_original_fullpath_test.rb
new file mode 100644
index 0000000000..7a679ea04e
--- /dev/null
+++ b/railties/test/application/build_original_fullpath_test.rb
@@ -0,0 +1,27 @@
+require "abstract_unit"
+
+module ApplicationTests
+ class BuildOriginalPathTest < Test::Unit::TestCase
+ def test_include_original_PATH_info_in_ORIGINAL_FULLPATH
+ env = { 'PATH_INFO' => '/foo/' }
+ assert_equal "/foo/", Rails.application.send(:build_original_fullpath, env)
+ end
+
+ def test_include_SCRIPT_NAME
+ env = {
+ 'SCRIPT_NAME' => '/foo',
+ 'PATH_INFO' => '/bar'
+ }
+
+ assert_equal "/foo/bar", Rails.application.send(:build_original_fullpath, env)
+ end
+
+ def test_include_QUERY_STRING
+ env = {
+ 'PATH_INFO' => '/foo',
+ 'QUERY_STRING' => 'bar',
+ }
+ assert_equal "/foo?bar", Rails.application.send(:build_original_fullpath, env)
+ end
+ end
+end