Namespace
- CLASS RouteSetTest::TestSet
Methods
- D
- R
- S
- T
-
- test_action_left_off_when_id_is_recalled,
- test_assign_route_options_with_anchor_chars,
- test_build_empty_query_string,
- test_build_query_string_with_nil_value,
- 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_uri_escape_pluses,
- test_default_route_should_work_with_action_but_no_id,
- test_draw,
- test_draw_default_route,
- test_draw_symbol_controller_name,
- test_duplicate_named_route_raises_rather_than_pick_precedence,
- test_escape_spaces_build_query_string,
- test_escape_spaces_build_query_string_selected_keys,
- test_expand_array_build_query_string,
- test_expiry_determination_should_consider_values_with_to_param,
- test_extra_keys,
- test_extra_keys_not_first,
- test_format_is_not_inherit,
- test_generate,
- test_generate_extras,
- test_generate_extras_not_first,
- test_generate_not_first,
- test_generate_with_blank_path_prefix,
- test_generate_with_default_action,
- test_generate_with_default_params,
- test_generate_with_optional_params_recalls_last_request,
- test_generate_with_path_prefix,
- test_id_is_sticky_when_it_ought_to_be,
- test_named_draw,
- test_named_route_in_nested_resource,
- test_named_route_url_method,
- test_named_route_url_method_with_anchor,
- test_named_route_url_method_with_host,
- test_named_route_url_method_with_no_positional_arguments,
- test_named_route_url_method_with_ordered_parameters,
- test_named_route_url_method_with_ordered_parameters_and_empty_hash,
- test_named_route_url_method_with_ordered_parameters_and_hash,
- test_named_route_url_method_with_port,
- test_named_route_url_method_with_protocol,
- test_named_routes_are_never_relative_to_modules,
- test_namespace,
- test_namespace_with_blank_path_prefix,
- test_namespace_with_path_prefix,
- test_namespaced_root_map,
- test_query_params_will_be_shown_when_recalled,
- test_recognize_with_alias_in_conditions,
- test_recognize_with_conditions_and_format,
- test_recognize_with_encoded_id_and_regex,
- test_recognize_with_http_methods,
- test_regexp_chunk_should_add_question_mark_for_optionals,
- test_root_map,
- test_route_constraints_on_request_object_with_anchors_are_valid,
- test_route_constraints_with_anchor_chars_are_invalid,
- test_route_constraints_with_options_method_condition_is_valid,
- test_route_constraints_with_supported_options_must_not_error,
- test_route_constraints_with_unsupported_regexp_options_must_error,
- test_route_error_with_missing_controller,
- test_route_requirement_generate_with_ignore_case,
- test_route_requirement_recognize_with_extended_syntax,
- test_route_requirement_recognize_with_ignore_case,
- test_route_requirement_with_xi_modifiers,
- test_route_with_parameter_shell,
- test_route_with_subdomain_and_constraints_must_receive_params,
- test_routes_with_symbols,
- test_routing_traversal_does_not_load_extra_classes,
- test_segmentation_of_dot_path,
- test_segmentation_of_dynamic_dot_path,
- test_setting_root_in_namespace_using_string,
- test_setting_root_in_namespace_using_symbol,
- test_simple_build_query_string,
- test_slashes_are_implied,
- test_typo_recognition,
- test_use_static_path_when_possible
Included Modules
Attributes
| [RW] | controller | |
| [R] | routes | |
| [R] | set |
Instance Public methods
default_route_set()
Link
request()
Link
setup()
Link
setup_named_route_test()
Link
# File actionpack/test/controller/routing_test.rb, line 958 def setup_named_route_test set.draw do get '/people(/:id)' => 'people#show', :as => 'show' get '/people' => 'people#index', :as => 'index' get '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi' get '/admin/users' => 'admin/users#index', :as => "users" end get URI('http://test.host/people') controller end
test_action_left_off_when_id_is_recalled()
Link
# File actionpack/test/controller/routing_test.rb, line 1393 def test_action_left_off_when_id_is_recalled @set = make_set false set.draw do get ':controller(/:action(/:id))' end get URI('http://test.host/books/show/10') assert_equal '/books', controller.url_for(:controller => 'books', :only_path => true, :action => 'index') end
test_assign_route_options_with_anchor_chars()
Link
# File actionpack/test/controller/routing_test.rb, line 1615 def test_assign_route_options_with_anchor_chars set.draw do get '/cars/:action/:person/:car/', :controller => 'cars' end assert_equal '/cars/buy/1/2', url_for(set, { :controller => 'cars', :action => 'buy', :person => '1', :car => '2' }) assert_equal({:controller => "cars", :action => "buy", :person => "1", :car => "2"}, set.recognize_path('/cars/buy/1/2')) end
test_build_empty_query_string()
Link
test_build_query_string_with_nil_value()
Link
test_convert_ints_build_query_string()
Link
test_default_route_recognition()
Link
# File actionpack/test/controller/routing_test.rb, line 1664 def test_default_route_recognition expected = {:controller => 'pages', :action => 'show', :id => '10'} assert_equal expected, default_route_set.recognize_path('/pages/show/10') assert_equal expected, default_route_set.recognize_path('/pages/show/10/') expected[:id] = 'jamis' assert_equal expected, default_route_set.recognize_path('/pages/show/jamis/') expected.delete :id assert_equal expected, default_route_set.recognize_path('/pages/show') assert_equal expected, default_route_set.recognize_path('/pages/show/') expected[:action] = 'index' assert_equal expected, default_route_set.recognize_path('/pages/') assert_equal expected, default_route_set.recognize_path('/pages') assert_raise(ActionController::RoutingError) { default_route_set.recognize_path('/') } assert_raise(ActionController::RoutingError) { default_route_set.recognize_path('/pages/how/goood/it/is/to/be/free') } end
test_default_route_should_include_default_action_when_id_present()
Link
test_default_route_should_omit_default_action()
Link
test_default_route_should_uri_escape_pluses()
Link
# File actionpack/test/controller/routing_test.rb, line 1696 def test_default_route_should_uri_escape_pluses expected = { :controller => 'pages', :action => 'show', :id => 'hello world' } assert_equal expected, default_route_set.recognize_path('/pages/show/hello%20world') assert_equal '/pages/show/hello%20world', url_for(default_route_set, expected) expected[:id] = 'hello+world' assert_equal expected, default_route_set.recognize_path('/pages/show/hello+world') assert_equal expected, default_route_set.recognize_path('/pages/show/hello%2Bworld') assert_equal '/pages/show/hello+world', url_for(default_route_set, expected) end
test_default_route_should_work_with_action_but_no_id()
Link
test_draw()
Link
test_draw_default_route()
Link
# File actionpack/test/controller/routing_test.rb, line 1047 def test_draw_default_route set.draw do get '/:controller/:action/:id' end assert_equal 1, set.routes.size assert_equal '/users/show/10', url_for(set, { :controller => 'users', :action => 'show', :id => 10 }) assert_equal '/users/index/10', url_for(set, { :controller => 'users', :id => 10 }) assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10')) assert_equal({:controller => 'users', :action => 'index', :id => '10'}, set.recognize_path('/users/index/10/')) end
test_draw_symbol_controller_name()
Link
test_duplicate_named_route_raises_rather_than_pick_precedence()
Link
test_escape_spaces_build_query_string()
Link
test_escape_spaces_build_query_string_selected_keys()
Link
test_expand_array_build_query_string()
Link
test_expiry_determination_should_consider_values_with_to_param()
Link
# File actionpack/test/controller/routing_test.rb, line 1437 def test_expiry_determination_should_consider_values_with_to_param @set = make_set false set.draw { get 'projects/:project_id/:controller/:action' } get URI('http://test.host/projects/1/weblog/show') assert_equal( { :controller => 'weblog', :action => 'show', :project_id => '1' }, controller.request.path_parameters) assert_equal '/projects/1/weblog/show', controller.url_for({ :action => 'show', :project_id => 1, :only_path => true }) end
test_extra_keys()
Link
# File actionpack/test/controller/routing_test.rb, line 889 def test_extra_keys set.draw { get ':controller/:action/:id' } extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") assert_equal %w(that this), extras.map { |e| e.to_s }.sort end
test_extra_keys_not_first()
Link
# File actionpack/test/controller/routing_test.rb, line 914 def test_extra_keys_not_first set.draw do get ':controller/:action/:id.:format' get ':controller/:action/:id' end extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") assert_equal %w(that this), extras.map { |e| e.to_s }.sort end
test_format_is_not_inherit()
Link
# File actionpack/test/controller/routing_test.rb, line 1421 def test_format_is_not_inherit set.draw do get '/posts(.:format)' => 'posts#index' end get URI('http://test.host/posts.xml') assert_equal({:controller => 'posts', :action => 'index', :format => 'xml'}, controller.request.path_parameters) assert_equal '/posts', controller.url_for( {:controller => 'posts', :only_path => true}) assert_equal '/posts.xml', controller.url_for( {:controller => 'posts', :format => 'xml', :only_path => true}) end
test_generate()
Link
# File actionpack/test/controller/routing_test.rb, line 1342 def test_generate set.draw { get ':controller/:action/:id' } args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } assert_equal "/foo/bar/7?x=y", url_for(set, args) assert_equal ["/foo/bar/7", [:x]], set.generate_extras(args) assert_equal [:x], set.extra_keys(args) end
test_generate_extras()
Link
# File actionpack/test/controller/routing_test.rb, line 882 def test_generate_extras set.draw { get ':controller/(:action(/:id))' } path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") assert_equal "/foo/bar/15", path assert_equal %w(that this), extras.map { |e| e.to_s }.sort end
test_generate_extras_not_first()
Link
# File actionpack/test/controller/routing_test.rb, line 895 def test_generate_extras_not_first set.draw do get ':controller/:action/:id.:format' get ':controller/:action/:id' end path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world") assert_equal "/foo/bar/15", path assert_equal %w(that this), extras.map { |e| e.to_s }.sort end
test_generate_not_first()
Link
# File actionpack/test/controller/routing_test.rb, line 905 def test_generate_not_first set.draw do get ':controller/:action/:id.:format' get ':controller/:action/:id' end assert_equal "/foo/bar/15?this=hello", url_for(set, { :controller => "foo", :action => "bar", :id => 15, :this => "hello" }) end
test_generate_with_blank_path_prefix()
Link
# File actionpack/test/controller/routing_test.rb, line 1362 def test_generate_with_blank_path_prefix set.draw do scope "" do get ':controller(/:action(/:id))' end end args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } assert_equal "/foo/bar/7?x=y", url_for(set, args) end
test_generate_with_default_action()
Link
# File actionpack/test/controller/routing_test.rb, line 1247 def test_generate_with_default_action set.draw do get "/people", :controller => "people", :action => "index" get "/people/list", :controller => "people", :action => "list" end url = url_for(set, { :controller => "people", :action => "list" }) assert_equal "/people/list", url end
test_generate_with_default_params()
Link
# File actionpack/test/controller/routing_test.rb, line 1735 def test_generate_with_default_params set.draw do get 'dummy/page/:page' => 'dummy#show' get 'dummy/dots/page.:page' => 'dummy#dots' get 'ibocorp(/:page)' => 'ibocorp#show', :constraints => { :page => /\d+/ }, :defaults => { :page => 1 } get ':controller/:action/:id' end assert_equal '/ibocorp', url_for(set, { :controller => 'ibocorp', :action => "show", :page => 1 }) end
test_generate_with_optional_params_recalls_last_request()
Link
# File actionpack/test/controller/routing_test.rb, line 1782 def test_generate_with_optional_params_recalls_last_request controller = nil @set = TestSet.new ->(c) { controller = c } set.draw do get "blog/", :controller => "blog", :action => "index" get "blog(/:year(/:month(/:day)))", :controller => "blog", :action => "show_date", :constraints => { :year => /(19|20)\d\d/, :month => /[01]?\d/, :day => /[0-3]?\d/ }, :day => nil, :month => nil get "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/ get "blog/:controller/:action(/:id)" get "*anything", :controller => "blog", :action => "unknown_request" end recognize_path = ->(path) { get(URI("http://example.org" + path)) controller.request.path_parameters } assert_equal({:controller => "blog", :action => "index"}, recognize_path.("/blog")) assert_equal({:controller => "blog", :action => "show", :id => "123"}, recognize_path.("/blog/show/123")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :day => nil, :month => nil }, recognize_path.("/blog/2004")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :month => "12", :day => nil }, recognize_path.("/blog/2004/12")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :month => "12", :day => "25"}, recognize_path.("/blog/2004/12/25")) assert_equal({:controller => "articles", :action => "edit", :id => "123"}, recognize_path.("/blog/articles/edit/123")) assert_equal({:controller => "articles", :action => "show_stats"}, recognize_path.("/blog/articles/show_stats")) assert_equal({:controller => "blog", :action => "unknown_request", :anything => "blog/wibble"}, recognize_path.("/blog/wibble")) assert_equal({:controller => "blog", :action => "unknown_request", :anything => "junk"}, recognize_path.("/junk")) get URI('http://example.org/blog/2006/07/28') assert_equal({:controller => "blog", :action => "show_date", :year => "2006", :month => "07", :day => "28"}, controller.request.path_parameters) assert_equal("/blog/2006/07/25", controller.url_for({ :day => 25, :only_path => true })) assert_equal("/blog/2005", controller.url_for({ :year => 2005, :only_path => true })) assert_equal("/blog/show/123", controller.url_for({ :action => "show" , :id => 123, :only_path => true })) assert_equal("/blog/2006", controller.url_for({ :year => 2006, :only_path => true })) assert_equal("/blog/2006", controller.url_for({ :year => 2006, :month => nil, :only_path => true })) end
test_generate_with_path_prefix()
Link
# File actionpack/test/controller/routing_test.rb, line 1351 def test_generate_with_path_prefix set.draw do scope "my" do get ':controller(/:action(/:id))' end end args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } assert_equal "/my/foo/bar/7?x=y", url_for(set, args) end
test_id_is_sticky_when_it_ought_to_be()
Link
# File actionpack/test/controller/routing_test.rb, line 1315 def test_id_is_sticky_when_it_ought_to_be @set = make_set false set.draw do get ':controller/:id/:action' end get URI('http://test.host/people/7/show') assert_equal "/people/7/destroy", controller.url_for(:action => 'destroy', :only_path => true) end
test_named_draw()
Link
test_named_route_in_nested_resource()
Link
# File actionpack/test/controller/routing_test.rb, line 1452 def test_named_route_in_nested_resource set.draw do resources :projects do member do get 'milestones' => 'milestones#index', :as => 'milestones' end end end params = set.recognize_path("/projects/1/milestones", :method => :get) assert_equal("milestones", params[:controller]) assert_equal("index", params[:action]) end
test_named_route_url_method()
Link
# File actionpack/test/controller/routing_test.rb, line 970 def test_named_route_url_method controller = setup_named_route_test assert_equal "http://test.host/people/5", controller.send(:show_url, :id => 5) assert_equal "/people/5", controller.send(:show_path, :id => 5) assert_equal "http://test.host/people", controller.send(:index_url) assert_equal "/people", controller.send(:index_path) assert_equal "http://test.host/admin/users", controller.send(:users_url) assert_equal '/admin/users', controller.send(:users_path) end
test_named_route_url_method_with_anchor()
Link
# File actionpack/test/controller/routing_test.rb, line 983 def test_named_route_url_method_with_anchor controller = setup_named_route_test assert_equal "http://test.host/people/5#location", controller.send(:show_url, :id => 5, :anchor => 'location') assert_equal "/people/5#location", controller.send(:show_path, :id => 5, :anchor => 'location') assert_equal "http://test.host/people#location", controller.send(:index_url, :anchor => 'location') assert_equal "/people#location", controller.send(:index_path, :anchor => 'location') assert_equal "http://test.host/admin/users#location", controller.send(:users_url, :anchor => 'location') assert_equal '/admin/users#location', controller.send(:users_path, :anchor => 'location') assert_equal "http://test.host/people/go/7/hello/joe/5#location", controller.send(:multi_url, 7, "hello", 5, :anchor => 'location') assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar#location", controller.send(:multi_url, 7, "hello", 5, :baz => "bar", :anchor => 'location') assert_equal "http://test.host/people?baz=bar#location", controller.send(:index_url, :baz => "bar", :anchor => 'location') assert_equal "http://test.host/people", controller.send(:index_url, anchor: nil) assert_equal "http://test.host/people", controller.send(:index_url, anchor: false) end
test_named_route_url_method_with_host()
Link
test_named_route_url_method_with_no_positional_arguments()
Link
test_named_route_url_method_with_ordered_parameters()
Link
test_named_route_url_method_with_ordered_parameters_and_empty_hash()
Link
# File actionpack/test/controller/routing_test.rb, line 1035 def test_named_route_url_method_with_ordered_parameters_and_empty_hash controller = setup_named_route_test assert_equal "http://test.host/people/go/7/hello/joe/5", controller.send(:multi_url, 7, "hello", 5, {}) end
test_named_route_url_method_with_ordered_parameters_and_hash()
Link
# File actionpack/test/controller/routing_test.rb, line 1029 def test_named_route_url_method_with_ordered_parameters_and_hash controller = setup_named_route_test assert_equal "http://test.host/people/go/7/hello/joe/5?baz=bar", controller.send(:multi_url, 7, "hello", 5, :baz => "bar") end
test_named_route_url_method_with_port()
Link
test_named_route_url_method_with_protocol()
Link
test_named_routes_are_never_relative_to_modules()
Link
# File actionpack/test/controller/routing_test.rb, line 1373 def test_named_routes_are_never_relative_to_modules @set = make_set false set.draw do get "/connection/manage(/:action)" => 'connection/manage#index' get "/connection/connection" => "connection/connection#index" get '/connection' => 'connection#index', :as => 'family_connection' end assert_equal({ :controller => 'connection/manage', :action => 'index', }, request_path_params('/connection/manage')) url = controller.url_for({ :controller => "connection", :only_path => true }) assert_equal "/connection/connection", url url = controller.url_for({ :use_route => "family_connection", :controller => "connection", :only_path => true }) assert_equal "/connection", url end
test_namespace()
Link
# File actionpack/test/controller/routing_test.rb, line 1265 def test_namespace set.draw do namespace 'api' do get 'inventory' => 'products#inventory' end end params = request_path_params("/api/inventory", :method => :get) assert_equal("api/products", params[:controller]) assert_equal("inventory", params[:action]) end
test_namespace_with_blank_path_prefix()
Link
# File actionpack/test/controller/routing_test.rb, line 1303 def test_namespace_with_blank_path_prefix set.draw do scope :module => "api", :path => "" do get 'inventory' => 'products#inventory' end end params = request_path_params("/inventory", :method => :get) assert_equal("api/products", params[:controller]) assert_equal("inventory", params[:action]) end
test_namespace_with_path_prefix()
Link
# File actionpack/test/controller/routing_test.rb, line 1291 def test_namespace_with_path_prefix set.draw do scope :module => "api", :path => "prefix" do get 'inventory' => 'products#inventory' end end params = request_path_params("/prefix/inventory", :method => :get) assert_equal("api/products", params[:controller]) assert_equal("inventory", params[:action]) end
test_namespaced_root_map()
Link
# File actionpack/test/controller/routing_test.rb, line 1279 def test_namespaced_root_map set.draw do namespace 'api' do root :to => 'products#index' end end params = request_path_params("/api", :method => :get) assert_equal("api/products", params[:controller]) assert_equal("index", params[:action]) end
test_query_params_will_be_shown_when_recalled()
Link
# File actionpack/test/controller/routing_test.rb, line 1407 def test_query_params_will_be_shown_when_recalled @set = make_set false set.draw do get 'show_weblog/:parameter' => 'weblog#show' get ':controller(/:action(/:id))' end get URI('http://test.host/weblog/show/1') assert_equal '/weblog/edit?parameter=1', controller.url_for( {:action => 'edit', :parameter => 1, :only_path => true}) end
test_recognize_with_alias_in_conditions()
Link
# File actionpack/test/controller/routing_test.rb, line 1183 def test_recognize_with_alias_in_conditions set.draw do match "/people" => 'people#index', :as => 'people', :via => :get root :to => "people#index" end params = request_path_params("/people", :method => :get) assert_equal("people", params[:controller]) assert_equal("index", params[:action]) params = request_path_params("/", :method => :get) assert_equal("people", params[:controller]) assert_equal("index", params[:action]) end
test_recognize_with_conditions_and_format()
Link
# File actionpack/test/controller/routing_test.rb, line 1223 def test_recognize_with_conditions_and_format set.draw do get "people/:id" => "people#show", :as => "person" put "people/:id" => "people#update" patch "people/:id" => "people#update" get "people/:id(.:format)" => "people#show" end params = request_path_params("/people/5", :method => :get) assert_equal("show", params[:action]) assert_equal("5", params[:id]) params = request_path_params("/people/5", :method => :put) assert_equal("update", params[:action]) params = request_path_params("/people/5", :method => :patch) assert_equal("update", params[:action]) params = request_path_params("/people/5.png", :method => :get) assert_equal("show", params[:action]) assert_equal("5", params[:id]) assert_equal("png", params[:format]) end
test_recognize_with_encoded_id_and_regex()
Link
# File actionpack/test/controller/routing_test.rb, line 1127 def test_recognize_with_encoded_id_and_regex set.draw do get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/ end assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, request_path_params('/page/10')) assert_equal({:controller => 'pages', :action => 'show', :id => 'hello+world'}, request_path_params('/page/hello+world')) end
test_recognize_with_http_methods()
Link
# File actionpack/test/controller/routing_test.rb, line 1136 def test_recognize_with_http_methods set.draw do get "/people" => "people#index", :as => "people" post "/people" => "people#create" get "/people/:id" => "people#show", :as => "person" put "/people/:id" => "people#update" patch "/people/:id" => "people#update" delete "/people/:id" => "people#destroy" end params = request_path_params("/people", :method => :get) assert_equal("index", params[:action]) params = request_path_params("/people", :method => :post) assert_equal("create", params[:action]) params = request_path_params("/people/5", :method => :put) assert_equal("update", params[:action]) params = request_path_params("/people/5", :method => :patch) assert_equal("update", params[:action]) assert_raise(ActionController::UnknownHttpMethod) { request_path_params("/people", :method => :bacon) } params = request_path_params("/people/5", :method => :get) assert_equal("show", params[:action]) assert_equal("5", params[:id]) params = request_path_params("/people/5", :method => :put) assert_equal("update", params[:action]) assert_equal("5", params[:id]) params = request_path_params("/people/5", :method => :patch) assert_equal("update", params[:action]) assert_equal("5", params[:id]) params = request_path_params("/people/5", :method => :delete) assert_equal("destroy", params[:action]) assert_equal("5", params[:id]) assert_raise(ActionController::RoutingError) { request_path_params("/people/5", :method => :post) } end
test_regexp_chunk_should_add_question_mark_for_optionals()
Link
# File actionpack/test/controller/routing_test.rb, line 1602 def test_regexp_chunk_should_add_question_mark_for_optionals set.draw do get '/' => 'foo#index' get '/hello' => 'bar#index' end assert_equal '/', url_for(set, { :controller => 'foo' }) assert_equal '/hello', url_for(set, { :controller => 'bar' }) assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/')) assert_equal({:controller => "bar", :action => "index"}, set.recognize_path('/hello')) end
test_root_map()
Link
test_route_constraints_on_request_object_with_anchors_are_valid()
Link
test_route_constraints_with_anchor_chars_are_invalid()
Link
# File actionpack/test/controller/routing_test.rb, line 1083 def test_route_constraints_with_anchor_chars_are_invalid assert_raise ArgumentError do set.draw do get 'page/:id' => 'pages#show', :id => /^\d+/ end end assert_raise ArgumentError do set.draw do get 'page/:id' => 'pages#show', :id => /\A\d+/ end end assert_raise ArgumentError do set.draw do get 'page/:id' => 'pages#show', :id => /\d+$/ end end assert_raise ArgumentError do set.draw do get 'page/:id' => 'pages#show', :id => /\d+\Z/ end end assert_raise ArgumentError do set.draw do get 'page/:id' => 'pages#show', :id => /\d+\z/ end end end
test_route_constraints_with_options_method_condition_is_valid()
Link
test_route_constraints_with_supported_options_must_not_error()
Link
# File actionpack/test/controller/routing_test.rb, line 1495 def test_route_constraints_with_supported_options_must_not_error assert_nothing_raised do set.draw do get 'page/:name' => 'pages#show', :constraints => { :name => /(david|jamis)/i } end end assert_nothing_raised do set.draw do get 'page/:name' => 'pages#show', :constraints => { :name => / # Desperately overcommented regexp ( #Either david #The Creator | #Or jamis #The Deployer )/x } end end end
test_route_constraints_with_unsupported_regexp_options_must_error()
Link
test_route_error_with_missing_controller()
Link
test_route_requirement_generate_with_ignore_case()
Link
# File actionpack/test/controller/routing_test.rb, line 1540 def test_route_requirement_generate_with_ignore_case set.draw do get 'page/:name' => 'pages#show', :constraints => {:name => /(david|jamis)/i} end url = url_for(set, { :controller => 'pages', :action => 'show', :name => 'david' }) assert_equal "/page/david", url assert_raise(ActionController::UrlGenerationError) do url_for(set, { :controller => 'pages', :action => 'show', :name => 'davidjamis' }) end url = url_for(set, { :controller => 'pages', :action => 'show', :name => 'JAMIS' }) assert_equal "/page/JAMIS", url end
test_route_requirement_recognize_with_extended_syntax()
Link
# File actionpack/test/controller/routing_test.rb, line 1555 def test_route_requirement_recognize_with_extended_syntax set.draw do get 'page/:name' => 'pages#show', :constraints => {:name => / # Desperately overcommented regexp ( #Either david #The Creator | #Or jamis #The Deployer )/x} end assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) assert_equal({:controller => 'pages', :action => 'show', :name => 'david'}, set.recognize_path('/page/david')) assert_raise ActionController::RoutingError do set.recognize_path('/page/david #The Creator') end assert_raise ActionController::RoutingError do set.recognize_path('/page/David') end end
test_route_requirement_recognize_with_ignore_case()
Link
# File actionpack/test/controller/routing_test.rb, line 1528 def test_route_requirement_recognize_with_ignore_case set.draw do get 'page/:name' => 'pages#show', :constraints => {:name => /(david|jamis)/i} end assert_equal({:controller => 'pages', :action => 'show', :name => 'jamis'}, set.recognize_path('/page/jamis')) assert_raise ActionController::RoutingError do set.recognize_path('/page/davidjamis') end assert_equal({:controller => 'pages', :action => 'show', :name => 'DAVID'}, set.recognize_path('/page/DAVID')) end
test_route_requirement_with_xi_modifiers()
Link
# File actionpack/test/controller/routing_test.rb, line 1575 def test_route_requirement_with_xi_modifiers set.draw do get 'page/:name' => 'pages#show', :constraints => {:name => / # Desperately overcommented regexp ( #Either david #The Creator | #Or jamis #The Deployer )/xi} end assert_equal({:controller => 'pages', :action => 'show', :name => 'JAMIS'}, set.recognize_path('/page/JAMIS')) assert_equal "/page/JAMIS", url_for(set, { :controller => 'pages', :action => 'show', :name => 'JAMIS' }) end
test_route_with_parameter_shell()
Link
# File actionpack/test/controller/routing_test.rb, line 1061 def test_route_with_parameter_shell set.draw do get 'page/:id' => 'pages#show', :id => /\d+/ get '/:controller(/:action(/:id))' end assert_equal({:controller => 'pages', :action => 'index'}, request_path_params('/pages')) assert_equal({:controller => 'pages', :action => 'index'}, request_path_params('/pages/index')) assert_equal({:controller => 'pages', :action => 'list'}, request_path_params('/pages/list')) assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, request_path_params('/pages/show/10')) assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, request_path_params('/page/10')) end
test_route_with_subdomain_and_constraints_must_receive_params()
Link
# File actionpack/test/controller/routing_test.rb, line 1515 def test_route_with_subdomain_and_constraints_must_receive_params name_param = nil set.draw do get 'page/:name' => 'pages#show', :constraints => lambda {|request| name_param = request.params[:name] return true } end assert_equal({:controller => 'pages', :action => 'show', :name => 'mypage'}, set.recognize_path('http://subdomain.example.org/page/mypage')) assert_equal(name_param, 'mypage') end
test_routes_with_symbols()
Link
# File actionpack/test/controller/routing_test.rb, line 1593 def test_routes_with_symbols set.draw do get 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol get 'named' , :controller => :pages, :action => :show, :name => :as_symbol, :as => :named end assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/unnamed')) assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named')) end
test_routing_traversal_does_not_load_extra_classes()
Link
# File actionpack/test/controller/routing_test.rb, line 1212 def test_routing_traversal_does_not_load_extra_classes assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" set.draw do get '/profile' => 'profile#index' end request_path_params("/profile") rescue nil assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" end
test_segmentation_of_dot_path()
Link
# File actionpack/test/controller/routing_test.rb, line 1625 def test_segmentation_of_dot_path set.draw do get '/books/:action.rss', :controller => 'books' end assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list' }) assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list.rss')) end
test_segmentation_of_dynamic_dot_path()
Link
# File actionpack/test/controller/routing_test.rb, line 1635 def test_segmentation_of_dynamic_dot_path set.draw do get '/books(/:action(.:format))', :controller => 'books' end assert_equal '/books/list.rss', url_for(set, { :controller => 'books', :action => 'list', :format => 'rss' }) assert_equal '/books/list.xml', url_for(set, { :controller => 'books', :action => 'list', :format => 'xml' }) assert_equal '/books/list', url_for(set, { :controller => 'books', :action => 'list' }) assert_equal '/books', url_for(set, { :controller => 'books', :action => 'index' }) assert_equal({:controller => "books", :action => "list", :format => "rss"}, set.recognize_path('/books/list.rss')) assert_equal({:controller => "books", :action => "list", :format => "xml"}, set.recognize_path('/books/list.xml')) assert_equal({:controller => "books", :action => "list"}, set.recognize_path('/books/list')) assert_equal({:controller => "books", :action => "index"}, set.recognize_path('/books')) end
test_setting_root_in_namespace_using_string()
Link
test_setting_root_in_namespace_using_symbol()
Link
test_simple_build_query_string()
Link
test_slashes_are_implied()
Link
# File actionpack/test/controller/routing_test.rb, line 1651 def test_slashes_are_implied set.draw { get("/:controller(/:action(/:id))") } assert_equal '/content', url_for(set, { :controller => 'content', :action => 'index' }) assert_equal '/content/list', url_for(set, { :controller => 'content', :action => 'list' }) assert_equal '/content/show/1', url_for(set, { :controller => 'content', :action => 'show', :id => '1' }) assert_equal({:controller => "content", :action => "index"}, set.recognize_path('/content')) assert_equal({:controller => "content", :action => "index"}, set.recognize_path('/content/index')) assert_equal({:controller => "content", :action => "list"}, set.recognize_path('/content/list')) assert_equal({:controller => "content", :action => "show", :id => "1"}, set.recognize_path('/content/show/1')) end
test_typo_recognition()
Link
# File actionpack/test/controller/routing_test.rb, line 1198 def test_typo_recognition set.draw do get 'articles/:year/:month/:day/:title' => 'articles#permalink', :year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/ end params = request_path_params("/articles/2005/11/05/a-very-interesting-article", :method => :get) assert_equal("permalink", params[:action]) assert_equal("2005", params[:year]) assert_equal("11", params[:month]) assert_equal("05", params[:day]) assert_equal("a-very-interesting-article", params[:title]) end
test_use_static_path_when_possible()
Link
# File actionpack/test/controller/routing_test.rb, line 1327 def test_use_static_path_when_possible @set = make_set false set.draw do get 'about' => "welcome#about" get ':controller/:action/:id' end get URI('http://test.host/welcom/get/7') assert_equal "/about", controller.url_for(:controller => 'welcome', :action => 'about', :only_path => true) end