aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/url_rewriter_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/url_rewriter_test.rb')
-rw-r--r--actionpack/test/controller/url_rewriter_test.rb44
1 files changed, 15 insertions, 29 deletions
diff --git a/actionpack/test/controller/url_rewriter_test.rb b/actionpack/test/controller/url_rewriter_test.rb
index 199b824a7a..3bc8bec3fb 100644
--- a/actionpack/test/controller/url_rewriter_test.rb
+++ b/actionpack/test/controller/url_rewriter_test.rb
@@ -4,10 +4,24 @@ require 'controller/fake_controllers'
ActionController::UrlRewriter
class UrlRewriterTests < ActionController::TestCase
+ class Rewriter
+ def initialize(request)
+ @options = {
+ :host => request.host_with_port,
+ :protocol => request.protocol
+ }
+ end
+
+ def rewrite(router, options)
+ options = @options.merge(options)
+ ActionController::UrlRewriter.rewrite(router, options)
+ end
+ end
+
def setup
@request = ActionController::TestRequest.new
@params = {}
- @rewriter = ActionController::UrlRewriter.new(@request, @params)
+ @rewriter = Rewriter.new(@request) #.new(@request, @params)
end
def test_port
@@ -61,34 +75,6 @@ class UrlRewriterTests < ActionController::TestCase
)
end
- def test_overwrite_params
- @params[:controller] = 'hi'
- @params[:action] = 'bye'
- @params[:id] = '2'
-
- assert_equal '/hi/hi/2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {:action => 'hi'})
- u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:action => 'hi'})
- assert_match %r(/hi/hi/2$), u
- end
-
- def test_overwrite_removes_original
- @params[:controller] = 'search'
- @params[:action] = 'list'
- @params[:list_page] = 1
-
- assert_equal '/search/list?list_page=2', @rewriter.rewrite(@router, :only_path => true, :overwrite_params => {"list_page" => 2})
- u = @rewriter.rewrite(@router, :only_path => false, :overwrite_params => {:list_page => 2})
- assert_equal 'http://test.host/search/list?list_page=2', u
- end
-
- def test_to_str
- @params[:controller] = 'hi'
- @params[:action] = 'bye'
- @request.parameters[:id] = '2'
-
- assert_equal 'http://, test.host, /, hi, bye, {"id"=>"2"}', @rewriter.to_str
- end
-
def test_trailing_slash
options = {:controller => 'foo', :action => 'bar', :id => '3', :only_path => true}
assert_equal '/foo/bar/3', @rewriter.rewrite(@router, options)