b20c575ac0
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4394 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
30 lines
821 B
Ruby
30 lines
821 B
Ruby
require File.dirname(__FILE__) + '/../abstract_unit'
|
|
|
|
class UrlRewriterTests < Test::Unit::TestCase
|
|
def setup
|
|
@request = ActionController::TestRequest.new
|
|
@params = {}
|
|
@rewriter = ActionController::UrlRewriter.new(@request, @params)
|
|
end
|
|
|
|
def test_overwrite_params
|
|
@params[:controller] = 'hi'
|
|
@params[:action] = 'bye'
|
|
@params[:id] = '2'
|
|
|
|
assert_equal '/hi/hi/2', @rewriter.rewrite(:only_path => true, :overwrite_params => {:action => 'hi'})
|
|
u = @rewriter.rewrite(:only_path => false, :overwrite_params => {:action => 'hi'})
|
|
assert_match %r(/hi/hi/2$), u
|
|
end
|
|
|
|
|
|
private
|
|
def split_query_string(str)
|
|
[str[0].chr] + str[1..-1].split(/&/).sort
|
|
end
|
|
|
|
def assert_query_equal(q1, q2)
|
|
assert_equal(split_query_string(q1), split_query_string(q2))
|
|
end
|
|
end
|