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_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_changes_controller_module,
- 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_later_named_routes_take_precedence,
- test_named_draw,
- test_named_route_hash_access_method,
- 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_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_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
Instance Public methods
default_route_set()
Link
request()
Link
set()
Link
setup_named_route_test()
Link
# File actionpack/test/controller/routing_test.rb, line 932 def setup_named_route_test set.draw do match '/people(/:id)' => 'people#show', :as => 'show' match '/people' => 'people#index', :as => 'index' match '/people/go/:foo/:bar/joe(/:id)' => 'people#multi', :as => 'multi' match '/admin/users' => 'admin/users#index', :as => "users" end MockController.build(set.url_helpers).new end
test_action_left_off_when_id_is_recalled()
Link
# File actionpack/test/controller/routing_test.rb, line 1357 def test_action_left_off_when_id_is_recalled set.draw do match ':controller(/:action(/:id))' end assert_equal '/books', url_for(set, {:controller => 'books', :action => 'index'}, {:controller => 'books', :action => 'show', :id => '10'} ) end
test_assign_route_options_with_anchor_chars()
Link
# File actionpack/test/controller/routing_test.rb, line 1551 def test_assign_route_options_with_anchor_chars set.draw do match '/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 1601 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 1633 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 1035 def test_draw_default_route set.draw do match '/: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_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 1394 def test_expiry_determination_should_consider_values_with_to_param set.draw { match 'projects/:project_id/:controller/:action' } assert_equal '/projects/1/weblog/show', url_for(set, { :action => 'show', :project_id => 1 }, { :controller => 'weblog', :action => 'show', :project_id => '1' }) end
test_extra_keys()
Link
# File actionpack/test/controller/routing_test.rb, line 864 def test_extra_keys set.draw { match ':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 889 def test_extra_keys_not_first set.draw do match ':controller/:action/:id.:format' match ':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 1378 def test_format_is_not_inherit set.draw do match '/posts(.:format)' => 'posts#index' end assert_equal '/posts', url_for(set, {:controller => 'posts'}, {:controller => 'posts', :action => 'index', :format => 'xml'} ) assert_equal '/posts.xml', url_for(set, {:controller => 'posts', :format => 'xml'}, {:controller => 'posts', :action => 'index', :format => 'xml'} ) end
test_generate()
Link
# File actionpack/test/controller/routing_test.rb, line 1312 def test_generate set.draw { match ':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_changes_controller_module()
Link
# File actionpack/test/controller/routing_test.rb, line 1283 def test_generate_changes_controller_module set.draw { match ':controller/:action/:id' } current = { :controller => "bling/bloop", :action => "bap", :id => 9 } assert_equal "/foo/bar/baz/7", url_for(set, { :controller => "foo/bar", :action => "baz", :id => 7 }, current) end
test_generate_extras()
Link
# File actionpack/test/controller/routing_test.rb, line 857 def test_generate_extras set.draw { match ':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 870 def test_generate_extras_not_first set.draw do match ':controller/:action/:id.:format' match ':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 880 def test_generate_not_first set.draw do match ':controller/:action/:id.:format' match ':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 1332 def test_generate_with_blank_path_prefix set.draw do scope "" do match ':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 1215 def test_generate_with_default_action set.draw do match "/people", :controller => "people", :action => "index" match "/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 1672 def test_generate_with_default_params set.draw do match 'dummy/page/:page' => 'dummy#show' match 'dummy/dots/page.:page' => 'dummy#dots' match 'ibocorp(/:page)' => 'ibocorp#show', :constraints => { :page => /\d+/ }, :defaults => { :page => 1 } match ':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 1686 def test_generate_with_optional_params_recalls_last_request set.draw do match "blog/", :controller => "blog", :action => "index" match "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 match "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/ match "blog/:controller/:action(/:id)" match "*anything", :controller => "blog", :action => "unknown_request" end assert_equal({:controller => "blog", :action => "index"}, set.recognize_path("/blog")) assert_equal({:controller => "blog", :action => "show", :id => "123"}, set.recognize_path("/blog/show/123")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :day => nil, :month => nil }, set.recognize_path("/blog/2004")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :month => "12", :day => nil }, set.recognize_path("/blog/2004/12")) assert_equal({:controller => "blog", :action => "show_date", :year => "2004", :month => "12", :day => "25"}, set.recognize_path("/blog/2004/12/25")) assert_equal({:controller => "articles", :action => "edit", :id => "123"}, set.recognize_path("/blog/articles/edit/123")) assert_equal({:controller => "articles", :action => "show_stats"}, set.recognize_path("/blog/articles/show_stats")) assert_equal({:controller => "blog", :action => "unknown_request", :anything => "blog/wibble"}, set.recognize_path("/blog/wibble")) assert_equal({:controller => "blog", :action => "unknown_request", :anything => "junk"}, set.recognize_path("/junk")) last_request = set.recognize_path("/blog/2006/07/28").freeze assert_equal({:controller => "blog", :action => "show_date", :year => "2006", :month => "07", :day => "28"}, last_request) assert_equal("/blog/2006/07/25", url_for(set, { :day => 25 }, last_request)) assert_equal("/blog/2005", url_for(set, { :year => 2005 }, last_request)) assert_equal("/blog/show/123", url_for(set, { :action => "show" , :id => 123 }, last_request)) assert_equal("/blog/2006", url_for(set, { :year => 2006 }, last_request)) assert_equal("/blog/2006", url_for(set, { :year => 2006, :month => nil }, last_request)) end
test_generate_with_path_prefix()
Link
# File actionpack/test/controller/routing_test.rb, line 1321 def test_generate_with_path_prefix set.draw do scope "my" do match ':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 1291 def test_id_is_sticky_when_it_ought_to_be set.draw do match ':controller/:id/:action' end url = url_for(set, { :action => "destroy" }, { :controller => "people", :action => "show", :id => "7" }) assert_equal "/people/7/destroy", url end
test_later_named_routes_take_precedence()
Link
test_named_draw()
Link
test_named_route_hash_access_method()
Link
# File actionpack/test/controller/routing_test.rb, line 943 def test_named_route_hash_access_method controller = setup_named_route_test assert_equal( { :controller => 'people', :action => 'show', :id => 5, :use_route => "show", :only_path => false }, controller.send(:hash_for_show_url, :id => 5)) assert_equal( { :controller => 'people', :action => 'index', :use_route => "index", :only_path => false }, controller.send(:hash_for_index_url)) assert_equal( { :controller => 'people', :action => 'show', :id => 5, :use_route => "show", :only_path => true }, controller.send(:hash_for_show_path, :id => 5) ) end
test_named_route_in_nested_resource()
Link
# File actionpack/test/controller/routing_test.rb, line 1401 def test_named_route_in_nested_resource set.draw do resources :projects do member do match '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 960 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) assert_equal '/admin/users', url_for(set, controller.send(:hash_for_users_url), { :controller => 'users', :action => 'index' }) end
test_named_route_url_method_with_anchor()
Link
# File actionpack/test/controller/routing_test.rb, line 974 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') 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 1023 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 1017 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 1343 def test_named_routes_are_never_relative_to_modules set.draw do match "/connection/manage(/:action)" => 'connection/manage#index' match "/connection/connection" => "connection/connection#index" match '/connection' => 'connection#index', :as => 'family_connection' end url = url_for(set, { :controller => "connection" }, { :controller => 'connection/manage' }) assert_equal "/connection/connection", url url = url_for(set, { :use_route => :family_connection, :controller => "connection" }, { :controller => 'connection/manage' }) assert_equal "/connection", url end
test_namespace()
Link
# File actionpack/test/controller/routing_test.rb, line 1233 def test_namespace set.draw do namespace 'api' do match 'inventory' => 'products#inventory' end end params = set.recognize_path("/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 1271 def test_namespace_with_blank_path_prefix set.draw do scope :module => "api", :path => "" do match 'inventory' => 'products#inventory' end end params = set.recognize_path("/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 1259 def test_namespace_with_path_prefix set.draw do scope :module => "api", :path => "prefix" do match 'inventory' => 'products#inventory' end end params = set.recognize_path("/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 1247 def test_namespaced_root_map set.draw do namespace 'api' do root :to => 'products#index' end end params = set.recognize_path("/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 1367 def test_query_params_will_be_shown_when_recalled set.draw do match 'show_weblog/:parameter' => 'weblog#show' match ':controller(/:action(/:id))' end assert_equal '/weblog/edit?parameter=1', url_for(set, {:action => 'edit', :parameter => 1}, {:controller => 'weblog', :action => 'show', :parameter => 1} ) end
test_recognize_with_alias_in_conditions()
Link
# File actionpack/test/controller/routing_test.rb, line 1155 def test_recognize_with_alias_in_conditions set.draw do match "/people" => 'people#index', :as => 'people', :via => :get root :to => "people#index" end params = set.recognize_path("/people", :method => :get) assert_equal("people", params[:controller]) assert_equal("index", params[:action]) params = set.recognize_path("/", :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 1195 def test_recognize_with_conditions_and_format set.draw do get "people/:id" => "people#show", :as => "person" put "people/:id" => "people#update" get "people/:id(.:format)" => "people#show" end params = set.recognize_path("/people/5", :method => :get) assert_equal("show", params[:action]) assert_equal("5", params[:id]) params = set.recognize_path("/people/5", :method => :put) assert_equal("update", params[:action]) params = set.recognize_path("/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 1107 def test_recognize_with_encoded_id_and_regex set.draw do match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/ end assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) assert_equal({:controller => 'pages', :action => 'show', :id => 'hello+world'}, set.recognize_path('/page/hello+world')) end
test_recognize_with_http_methods()
Link
# File actionpack/test/controller/routing_test.rb, line 1116 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" delete "/people/:id" => "people#destroy" end params = set.recognize_path("/people", :method => :get) assert_equal("index", params[:action]) params = set.recognize_path("/people", :method => :post) assert_equal("create", params[:action]) params = set.recognize_path("/people/5", :method => :put) assert_equal("update", params[:action]) assert_raise(ActionController::UnknownHttpMethod) { set.recognize_path("/people", :method => :bacon) } params = set.recognize_path("/people/5", :method => :get) assert_equal("show", params[:action]) assert_equal("5", params[:id]) params = set.recognize_path("/people/5", :method => :put) assert_equal("update", params[:action]) assert_equal("5", params[:id]) params = set.recognize_path("/people/5", :method => :delete) assert_equal("destroy", params[:action]) assert_equal("5", params[:id]) assert_raise(ActionController::RoutingError) { set.recognize_path("/people/5", :method => :post) } end
test_regexp_chunk_should_add_question_mark_for_optionals()
Link
# File actionpack/test/controller/routing_test.rb, line 1538 def test_regexp_chunk_should_add_question_mark_for_optionals set.draw do match '/' => 'foo#index' match '/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 1071 def test_route_constraints_with_anchor_chars_are_invalid assert_raise ArgumentError do set.draw do match 'page/:id' => 'pages#show', :id => /^\d+/ end end assert_raise ArgumentError do set.draw do match 'page/:id' => 'pages#show', :id => /\A\d+/ end end assert_raise ArgumentError do set.draw do match 'page/:id' => 'pages#show', :id => /\d+$/ end end assert_raise ArgumentError do set.draw do match 'page/:id' => 'pages#show', :id => /\d+\Z/ end end assert_raise ArgumentError do set.draw do match '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 1444 def test_route_constraints_with_supported_options_must_not_error assert_nothing_raised do set.draw do match 'page/:name' => 'pages#show', :constraints => { :name => /(david|jamis)/i } end end assert_nothing_raised do set.draw do match '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_requirement_generate_with_ignore_case()
Link
# File actionpack/test/controller/routing_test.rb, line 1476 def test_route_requirement_generate_with_ignore_case set.draw do match '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::RoutingError 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 1491 def test_route_requirement_recognize_with_extended_syntax set.draw do match '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 1464 def test_route_requirement_recognize_with_ignore_case set.draw do match '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 1511 def test_route_requirement_with_xi_modifiers set.draw do match '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 1049 def test_route_with_parameter_shell set.draw do match 'page/:id' => 'pages#show', :id => /\d+/ match '/:controller(/:action(/:id))' end assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages')) assert_equal({:controller => 'pages', :action => 'index'}, set.recognize_path('/pages/index')) assert_equal({:controller => 'pages', :action => 'list'}, set.recognize_path('/pages/list')) assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/pages/show/10')) assert_equal({:controller => 'pages', :action => 'show', :id => '10'}, set.recognize_path('/page/10')) end
test_routes_with_symbols()
Link
# File actionpack/test/controller/routing_test.rb, line 1529 def test_routes_with_symbols set.draw do match 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol match '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 1184 def test_routing_traversal_does_not_load_extra_classes assert !Object.const_defined?("Profiler__"), "Profiler should not be loaded" set.draw do match '/profile' => 'profile#index' end set.recognize_path("/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 1561 def test_segmentation_of_dot_path set.draw do match '/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 1571 def test_segmentation_of_dynamic_dot_path set.draw do match '/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 1587 def test_slashes_are_implied @set = nil set.draw { match("/: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 1170 def test_typo_recognition set.draw do match 'articles/:year/:month/:day/:title' => 'articles#permalink', :year => /\d{4}/, :day => /\d{1,2}/, :month => /\d{1,2}/ end params = set.recognize_path("/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 1300 def test_use_static_path_when_possible set.draw do match 'about' => "welcome#about" match ':controller/:action/:id' end url = url_for(set, { :controller => "welcome", :action => "about" }, { :controller => "welcome", :action => "get", :id => "7" }) assert_equal "/about", url end