aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/url_rewriter_tests.rb
blob: 392024f03d13805a117787ff87b923b992b5d4f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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_simple_build_query_string
    assert_equal '?x=1&y=2', @rewriter.send(:build_query_string, :x => '1', :y => '2')
  end
  def test_convert_ints_build_query_string
    assert_equal '?x=1&y=2', @rewriter.send(:build_query_string, :x => 1, :y => 2)
  end
  def test_escape_spaces_build_query_string
    assert_equal '?x=hello+world&y=goodbye+world', @rewriter.send(:build_query_string, :x => 'hello world', :y => 'goodbye world')
  end
  def test_expand_array_build_query_string
    assert_equal '?x[]=1&x[]=2', @rewriter.send(:build_query_string, :x => [1, 2])
  end

  def test_escape_spaces_build_query_string_selected_keys
    assert_equal '?x=hello+world', @rewriter.send(:build_query_string, {:x => 'hello world', :y => 'goodbye world'}, [:x])
  end
  
end