- D
- S
- T
-
- test_build_empty_query_string,
- test_build_query_string_with_nil_value,
- test_builder_complains_without_controller,
- test_convert_ints_build_query_string,
- test_default_route_recognition,
- test_default_route_should_include_default_action_when_id_present,
- test_default_route_should_omit_default_action,
- test_default_route_should_work_with_action_but_no_id,
- test_defaults,
- test_escape_spaces_build_query_string,
- test_escape_spaces_build_query_string_selected_keys,
- test_expand_array_build_query_string,
- test_parameter_shell,
- test_significant_keys,
- test_significant_keys_for_default_route,
- test_simple_build_query_string
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 814 def default_route unless @default_route @default_route = ROUTING::Route.new @default_route.segments << (s = ROUTING::StaticSegment.new) s.value = '/' s.raw = true @default_route.segments << (s = ROUTING::DynamicSegment.new) s.key = :controller @default_route.segments << slash_segment(:optional) @default_route.segments << (s = ROUTING::DynamicSegment.new) s.key = :action s.default = 'index' s.is_optional = true @default_route.segments << slash_segment(:optional) @default_route.segments << (s = ROUTING::DynamicSegment.new) s.key = :id s.is_optional = true @default_route.segments << slash_segment(:optional) end @default_route end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 804 def setup @route = ROUTING::Route.new end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 808 def slash_segment(is_optional = false) returning ROUTING::DividerSegment.new('/') do |s| s.is_optional = is_optional end end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 928 def test_build_empty_query_string assert_equal '', @route.build_query_string({}) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 932 def test_build_query_string_with_nil_value assert_equal '', @route.build_query_string({:x => nil}) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 889 def test_builder_complains_without_controller assert_raises(ArgumentError) do ROUTING::RouteBuilder.new.build '/contact', :contoller => "contact", :action => "index" end end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 940 def test_convert_ints_build_query_string assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => 1, :y => 2)) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 841 def test_default_route_recognition expected = {:controller => 'accounts', :action => 'show', :id => '10'} assert_equal expected, default_route.recognize('/accounts/show/10') assert_equal expected, default_route.recognize('/accounts/show/10/') expected[:id] = 'jamis' assert_equal expected, default_route.recognize('/accounts/show/jamis/') expected.delete :id assert_equal expected, default_route.recognize('/accounts/show') assert_equal expected, default_route.recognize('/accounts/show/') expected[:action] = 'index' assert_equal expected, default_route.recognize('/accounts/') assert_equal expected, default_route.recognize('/accounts') assert_equal nil, default_route.recognize('/') assert_equal nil, default_route.recognize('/accounts/how/goood/it/is/to/be/free') end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 866 def test_default_route_should_include_default_action_when_id_present o = {:controller => 'accounts', :action => 'index', :id => '20'} assert_equal '/accounts/index/20', default_route.generate(o, o, {}) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 861 def test_default_route_should_omit_default_action o = {:controller => 'accounts', :action => 'index'} assert_equal '/accounts', default_route.generate(o, o, {}) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 871 def test_default_route_should_work_with_action_but_no_id o = {:controller => 'accounts', :action => 'list_all'} assert_equal '/accounts/list_all', default_route.generate(o, o, {}) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 882 def test_defaults route = ROUTING::RouteBuilder.new.build '/users/:id.:format', :controller => "users", :action => "show", :format => "html" assert_equal( { :controller => "users", :action => "show", :format => "html" }, route.defaults) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 944 def test_escape_spaces_build_query_string assert_equal '?x=hello+world&y=goodbye+world', order_query_string(@route.build_query_string(:x => 'hello world', :y => 'goodbye world')) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 952 def test_escape_spaces_build_query_string_selected_keys assert_equal '?x=hello+world', order_query_string(@route.build_query_string({:x => 'hello world', :y => 'goodbye world'}, [:x])) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 948 def test_expand_array_build_query_string assert_equal '?x%5B%5D=1&x%5B%5D=2', order_query_string(@route.build_query_string(:x => [1, 2])) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 876 def test_parameter_shell page_url = ROUTING::Route.new page_url.requirements = {:controller => 'pages', :action => 'show', :id => %r\d+/} assert_equal({:controller => 'pages', :action => 'show'}, page_url.parameter_shell) end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 900 def test_significant_keys user_url = ROUTING::Route.new user_url.segments << (s = ROUTING::StaticSegment.new) s.value = '/' s.raw = true user_url.segments << (s = ROUTING::StaticSegment.new) s.value = 'user' user_url.segments << (s = ROUTING::StaticSegment.new) s.value = '/' s.raw = true s.is_optional = true user_url.segments << (s = ROUTING::DynamicSegment.new) s.key = :user user_url.segments << (s = ROUTING::StaticSegment.new) s.value = '/' s.raw = true s.is_optional = true user_url.requirements = {:controller => 'users', :action => 'show'} keys = user_url.significant_keys.sort_by { |k| k.to_s } assert_equal [:action, :controller, :user], keys end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 895 def test_significant_keys_for_default_route keys = default_route.significant_keys.sort_by {|k| k.to_s } assert_equal [:action, :controller, :id], keys end
Source: show
# File rails/actionpack/test/controller/routing_test.rb, line 936 def test_simple_build_query_string assert_equal '?x=1&y=2', order_query_string(@route.build_query_string(:x => '1', :y => '2')) end