actionpack 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +66 -0
- data/README +94 -64
- data/install.rb +1 -20
- data/lib/action_controller.rb +15 -7
- data/lib/action_controller/assertions/action_pack_assertions.rb +56 -3
- data/lib/action_controller/base.rb +137 -64
- data/lib/action_controller/caching.rb +11 -11
- data/lib/action_controller/cgi_ext/cgi_ext.rb +2 -2
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +4 -4
- data/lib/action_controller/cgi_process.rb +9 -1
- data/lib/action_controller/components.rb +73 -0
- data/lib/action_controller/cookies.rb +1 -1
- data/lib/action_controller/dependencies.rb +6 -1
- data/lib/action_controller/filters.rb +1 -1
- data/lib/action_controller/flash.rb +3 -3
- data/lib/action_controller/helpers.rb +17 -21
- data/lib/action_controller/layout.rb +2 -2
- data/lib/action_controller/request.rb +16 -6
- data/lib/action_controller/rescue.rb +15 -3
- data/lib/action_controller/routing.rb +304 -0
- data/lib/action_controller/scaffolding.rb +10 -12
- data/lib/action_controller/session/active_record_store.rb +4 -7
- data/lib/action_controller/session/mem_cache_store.rb +2 -2
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +9 -1
- data/lib/action_controller/templates/rescues/diagnostics.rhtml +1 -1
- data/lib/action_controller/templates/rescues/routing_error.rhtml +8 -0
- data/lib/action_controller/test_process.rb +29 -7
- data/lib/action_controller/url_rewriter.rb +28 -112
- data/lib/action_view.rb +1 -1
- data/lib/action_view/base.rb +44 -17
- data/lib/action_view/helpers/active_record_helper.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +59 -0
- data/lib/action_view/helpers/date_helper.rb +24 -13
- data/lib/action_view/helpers/form_helper.rb +6 -1
- data/lib/action_view/helpers/form_options_helper.rb +87 -9
- data/lib/action_view/helpers/form_tag_helper.rb +80 -0
- data/lib/action_view/helpers/tag_helper.rb +0 -23
- data/lib/action_view/helpers/text_helper.rb +26 -1
- data/lib/action_view/helpers/url_helper.rb +29 -35
- data/lib/action_view/partials.rb +2 -2
- data/lib/action_view/vendor/builder/xmlbase.rb +3 -3
- data/rakefile +5 -2
- data/test/abstract_unit.rb +3 -1
- data/test/controller/action_pack_assertions_test.rb +29 -1
- data/test/controller/active_record_assertions_test.rb +109 -101
- data/test/controller/base_tests.rb +72 -0
- data/test/controller/components_test.rb +74 -0
- data/test/controller/cookie_test.rb +0 -9
- data/test/controller/custom_handler_test.rb +33 -0
- data/test/controller/filters_test.rb +36 -0
- data/test/controller/helper_test.rb +27 -10
- data/test/controller/redirect_test.rb +23 -31
- data/test/controller/render_test.rb +81 -66
- data/test/controller/request_test.rb +22 -0
- data/test/controller/routing_tests.rb +490 -0
- data/test/controller/{url_test.rb → url_obsolete.rb} +24 -14
- data/test/controller/url_obsolete.rb.rej +747 -0
- data/test/fixtures/fun/games/hello_world.rhtml +1 -0
- data/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/test/template/asset_tag_helper_test.rb +45 -0
- data/test/template/form_options_helper_test.rb +161 -1
- data/test/template/form_tag_helper_test.rb +22 -0
- data/test/template/text_helper_test.rb +7 -0
- data/test/template/url_helper_test.rb +5 -2
- data/test/template/url_helper_test.rb.rej +105 -0
- metadata +32 -27
- data/lib/action_controller/support/binding_of_caller.rb +0 -83
- data/lib/action_controller/support/breakpoint.rb +0 -518
- data/lib/action_controller/support/class_attribute_accessors.rb +0 -57
- data/lib/action_controller/support/class_inheritable_attributes.rb +0 -117
- data/lib/action_controller/support/clean_logger.rb +0 -10
- data/lib/action_controller/support/core_ext.rb +0 -1
- data/lib/action_controller/support/core_ext/hash.rb +0 -5
- data/lib/action_controller/support/core_ext/hash/keys.rb +0 -35
- data/lib/action_controller/support/core_ext/numeric.rb +0 -7
- data/lib/action_controller/support/core_ext/numeric/bytes.rb +0 -33
- data/lib/action_controller/support/core_ext/numeric/time.rb +0 -59
- data/lib/action_controller/support/core_ext/object_and_class.rb +0 -24
- data/lib/action_controller/support/core_ext/string.rb +0 -5
- data/lib/action_controller/support/core_ext/string/inflections.rb +0 -45
- data/lib/action_controller/support/dependencies.rb +0 -63
- data/lib/action_controller/support/inflector.rb +0 -84
- data/lib/action_controller/support/misc.rb +0 -8
- data/lib/action_controller/support/module_attribute_accessors.rb +0 -57
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require File.dirname(__FILE__) + '/../abstract_unit'
         | 
| 2 2 | 
             
            require 'action_controller/url_rewriter'
         | 
| 3 3 |  | 
| 4 | 
            -
            MockRequest = Struct.new("MockRequest", :protocol, :host, :port, :path, :parameters)
         | 
| 4 | 
            +
            MockRequest = Struct.new("MockRequest", :protocol, :host, :port, :path, :parameters, :path_parameters)
         | 
| 5 5 | 
             
            class MockRequest
         | 
| 6 6 | 
             
              def host_with_port
         | 
| 7 7 | 
             
                if (protocol == "http://" && port == 80) || (protocol == "https://" && port == 443)
         | 
| @@ -16,14 +16,24 @@ class UrlMockFactory | |
| 16 16 | 
             
              def self.create(path, parameters)
         | 
| 17 17 | 
             
                ActionController::UrlRewriter.new(
         | 
| 18 18 | 
             
                  MockRequest.new("http://", "example.com", 80, path, parameters), 
         | 
| 19 | 
            -
                  parameters | 
| 19 | 
            +
                  parameters
         | 
| 20 20 | 
             
                )
         | 
| 21 21 | 
             
              end
         | 
| 22 22 | 
             
            end
         | 
| 23 23 |  | 
| 24 | 
            +
            # old-style support for .new
         | 
| 25 | 
            +
            module ActionController
         | 
| 26 | 
            +
              class UrlRewriter
         | 
| 27 | 
            +
                def self.old_new(request, controller, action)
         | 
| 28 | 
            +
                  request.parameters[:controller] = controller
         | 
| 29 | 
            +
                  request.parameters[:action] = action
         | 
| 30 | 
            +
                  return new(request, request.parameters)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| 24 34 | 
             
            class UrlTest < Test::Unit::TestCase
         | 
| 25 35 | 
             
              def setup
         | 
| 26 | 
            -
                @library_url = ActionController::UrlRewriter. | 
| 36 | 
            +
                @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 27 37 | 
             
                  "http://",
         | 
| 28 38 | 
             
                  "www.singlefile.com", 
         | 
| 29 39 | 
             
                  80,
         | 
| @@ -31,7 +41,7 @@ class UrlTest < Test::Unit::TestCase | |
| 31 41 | 
             
                  { "type" => "ISBN", "code" => "0743536703" }
         | 
| 32 42 | 
             
                ), "books", "show")
         | 
| 33 43 |  | 
| 34 | 
            -
                @library_url_using_module = ActionController::UrlRewriter. | 
| 44 | 
            +
                @library_url_using_module = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 35 45 | 
             
                  "http://",
         | 
| 36 46 | 
             
                  "www.singlefile.com", 
         | 
| 37 47 | 
             
                  80,
         | 
| @@ -39,7 +49,7 @@ class UrlTest < Test::Unit::TestCase | |
| 39 49 | 
             
                  { "type" => "ISBN", "code" => "0743536703", "module" => "library" }
         | 
| 40 50 | 
             
                ), "books", "show")
         | 
| 41 51 |  | 
| 42 | 
            -
                @library_url_on_index = ActionController::UrlRewriter. | 
| 52 | 
            +
                @library_url_on_index = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 43 53 | 
             
                  "http://",
         | 
| 44 54 | 
             
                  "www.singlefile.com", 
         | 
| 45 55 | 
             
                  80,
         | 
| @@ -48,27 +58,27 @@ class UrlTest < Test::Unit::TestCase | |
| 48 58 | 
             
                ), "books", "index")
         | 
| 49 59 |  | 
| 50 60 | 
             
                @clean_urls = [
         | 
| 51 | 
            -
                  ActionController::UrlRewriter. | 
| 61 | 
            +
                  ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 52 62 | 
             
                    "http://", "www.singlefile.com", 80, "/identity/", {}
         | 
| 53 63 | 
             
                  ), "identity", "index"),
         | 
| 54 | 
            -
                  ActionController::UrlRewriter. | 
| 64 | 
            +
                  ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 55 65 | 
             
                    "http://", "www.singlefile.com", 80, "/identity", {}
         | 
| 56 66 | 
             
                  ), "identity", "index")
         | 
| 57 67 | 
             
                ]
         | 
| 58 68 |  | 
| 59 | 
            -
                @clean_url_with_id = ActionController::UrlRewriter. | 
| 69 | 
            +
                @clean_url_with_id = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 60 70 | 
             
                  "http://", "www.singlefile.com", 80, "/identity/show/5", { "id" => "5" }
         | 
| 61 71 | 
             
                ), "identity", "show")
         | 
| 62 72 |  | 
| 63 | 
            -
                @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter. | 
| 73 | 
            +
                @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 64 74 | 
             
                  "http://", "www.singlefile.com", 80, "/login/login", {  }
         | 
| 65 75 | 
             
                ), "login", "login")
         | 
| 66 76 |  | 
| 67 | 
            -
                @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter. | 
| 77 | 
            +
                @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 68 78 | 
             
                  "http://", "www.singlefile.com", 80, "/login/login/login", { "module" => "login" }
         | 
| 69 79 | 
             
                ), "login", "login")
         | 
| 70 80 |  | 
| 71 | 
            -
                @clean_url_with_id_as_char = ActionController::UrlRewriter. | 
| 81 | 
            +
                @clean_url_with_id_as_char = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 72 82 | 
             
                  "http://", "www.singlefile.com", 80, "/teachers/show/t", { "id" => "t" }
         | 
| 73 83 | 
             
                ), "teachers", "show")
         | 
| 74 84 | 
             
              end
         | 
| @@ -386,7 +396,7 @@ class UrlTest < Test::Unit::TestCase | |
| 386 396 | 
             
              end
         | 
| 387 397 |  | 
| 388 398 | 
             
              def test_from_another_port
         | 
| 389 | 
            -
                @library_url = ActionController::UrlRewriter. | 
| 399 | 
            +
                @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 390 400 | 
             
                  "http://",
         | 
| 391 401 | 
             
                  "www.singlefile.com", 
         | 
| 392 402 | 
             
                  8080,
         | 
| @@ -403,7 +413,7 @@ class UrlTest < Test::Unit::TestCase | |
| 403 413 | 
             
              end
         | 
| 404 414 |  | 
| 405 415 | 
             
              def test_basecamp
         | 
| 406 | 
            -
                basecamp_url = ActionController::UrlRewriter. | 
| 416 | 
            +
                basecamp_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 407 417 | 
             
                  "http://",
         | 
| 408 418 | 
             
                  "projects.basecamp", 
         | 
| 409 419 | 
             
                  80,
         | 
| @@ -418,7 +428,7 @@ class UrlTest < Test::Unit::TestCase | |
| 418 428 | 
             
              end
         | 
| 419 429 |  | 
| 420 430 | 
             
              def test_on_explicit_index_page # My index page is very modest, thank you...
         | 
| 421 | 
            -
                url = ActionController::UrlRewriter. | 
| 431 | 
            +
                url = ActionController::UrlRewriter.old_new(
         | 
| 422 432 | 
             
                  MockRequest.new(
         | 
| 423 433 | 
             
                    "http://", "example.com", 80, "/controller/index",
         | 
| 424 434 | 
             
                    {"controller"=>"controller", "action"=>"index"}
         | 
| @@ -0,0 +1,747 @@ | |
| 1 | 
            +
            ***************
         | 
| 2 | 
            +
            *** 35,41 ****
         | 
| 3 | 
            +
                def setup
         | 
| 4 | 
            +
                  @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 5 | 
            +
                    "http://",
         | 
| 6 | 
            +
            -       "www.singlefile.com", 
         | 
| 7 | 
            +
                    80,
         | 
| 8 | 
            +
                    "/library/books/ISBN/0743536703/show",
         | 
| 9 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 10 | 
            +
            --- 35,41 ----
         | 
| 11 | 
            +
                def setup
         | 
| 12 | 
            +
                  @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 13 | 
            +
                    "http://",
         | 
| 14 | 
            +
            +       "www.example.com", 
         | 
| 15 | 
            +
                    80,
         | 
| 16 | 
            +
                    "/library/books/ISBN/0743536703/show",
         | 
| 17 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 18 | 
            +
            ***************
         | 
| 19 | 
            +
            *** 43,49 ****
         | 
| 20 | 
            +
              
         | 
| 21 | 
            +
                  @library_url_using_module = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 22 | 
            +
                    "http://",
         | 
| 23 | 
            +
            -       "www.singlefile.com", 
         | 
| 24 | 
            +
                    80,
         | 
| 25 | 
            +
                    "/library/books/ISBN/0743536703/show",
         | 
| 26 | 
            +
                    { "type" => "ISBN", "code" => "0743536703", "module" => "library" }
         | 
| 27 | 
            +
            --- 43,49 ----
         | 
| 28 | 
            +
              
         | 
| 29 | 
            +
                  @library_url_using_module = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 30 | 
            +
                    "http://",
         | 
| 31 | 
            +
            +       "www.example.com", 
         | 
| 32 | 
            +
                    80,
         | 
| 33 | 
            +
                    "/library/books/ISBN/0743536703/show",
         | 
| 34 | 
            +
                    { "type" => "ISBN", "code" => "0743536703", "module" => "library" }
         | 
| 35 | 
            +
            ***************
         | 
| 36 | 
            +
            *** 51,57 ****
         | 
| 37 | 
            +
              
         | 
| 38 | 
            +
                  @library_url_on_index = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 39 | 
            +
                    "http://",
         | 
| 40 | 
            +
            -       "www.singlefile.com", 
         | 
| 41 | 
            +
                    80,
         | 
| 42 | 
            +
                    "/library/books/ISBN/0743536703/", 
         | 
| 43 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 44 | 
            +
            --- 51,57 ----
         | 
| 45 | 
            +
              
         | 
| 46 | 
            +
                  @library_url_on_index = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 47 | 
            +
                    "http://",
         | 
| 48 | 
            +
            +       "www.example.com", 
         | 
| 49 | 
            +
                    80,
         | 
| 50 | 
            +
                    "/library/books/ISBN/0743536703/", 
         | 
| 51 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 52 | 
            +
            ***************
         | 
| 53 | 
            +
            *** 59,103 ****
         | 
| 54 | 
            +
                  
         | 
| 55 | 
            +
                  @clean_urls = [
         | 
| 56 | 
            +
                    ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 57 | 
            +
            -         "http://", "www.singlefile.com", 80, "/identity/", {}
         | 
| 58 | 
            +
                    ), "identity", "index"),
         | 
| 59 | 
            +
                    ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 60 | 
            +
            -         "http://", "www.singlefile.com", 80, "/identity", {}
         | 
| 61 | 
            +
                    ), "identity", "index")
         | 
| 62 | 
            +
                  ]
         | 
| 63 | 
            +
              
         | 
| 64 | 
            +
                  @clean_url_with_id = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 65 | 
            +
            -       "http://", "www.singlefile.com", 80, "/identity/show/5", { "id" => "5" }
         | 
| 66 | 
            +
                  ), "identity", "show")
         | 
| 67 | 
            +
              
         | 
| 68 | 
            +
                  @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 69 | 
            +
            -       "http://", "www.singlefile.com", 80, "/login/login", {  }
         | 
| 70 | 
            +
                  ), "login", "login")
         | 
| 71 | 
            +
              
         | 
| 72 | 
            +
                  @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 73 | 
            +
            -       "http://", "www.singlefile.com", 80, "/login/login/login", { "module" => "login" }
         | 
| 74 | 
            +
                  ), "login", "login")
         | 
| 75 | 
            +
              
         | 
| 76 | 
            +
                  @clean_url_with_id_as_char = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 77 | 
            +
            -       "http://", "www.singlefile.com", 80, "/teachers/show/t", { "id" => "t" }
         | 
| 78 | 
            +
                  ), "teachers", "show")
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
              
         | 
| 81 | 
            +
                def test_clean_action
         | 
| 82 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/edit", @library_url.rewrite(:action => "edit")
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
              
         | 
| 85 | 
            +
                def test_clean_action_to_another_host
         | 
| 86 | 
            +
                  assert_equal(
         | 
| 87 | 
            +
            -       "http://www.booksphere.com/library/books/ISBN/0743536703/edit", 
         | 
| 88 | 
            +
            -       @library_url.rewrite(:action => "edit", :host => "www.booksphere.com")
         | 
| 89 | 
            +
                  )
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
              
         | 
| 92 | 
            +
                def test_clean_action_to_another_host_and_protocol
         | 
| 93 | 
            +
                  assert_equal(
         | 
| 94 | 
            +
            -       "https://www.booksphere.com/library/books/ISBN/0743536703/edit", 
         | 
| 95 | 
            +
            -       @library_url.rewrite(:action => "edit", :host => "www.booksphere.com", :protocol => "https://")
         | 
| 96 | 
            +
                  )
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
              
         | 
| 99 | 
            +
            --- 59,103 ----
         | 
| 100 | 
            +
                  
         | 
| 101 | 
            +
                  @clean_urls = [
         | 
| 102 | 
            +
                    ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 103 | 
            +
            +         "http://", "www.example.com", 80, "/identity/", {}
         | 
| 104 | 
            +
                    ), "identity", "index"),
         | 
| 105 | 
            +
                    ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 106 | 
            +
            +         "http://", "www.example.com", 80, "/identity", {}
         | 
| 107 | 
            +
                    ), "identity", "index")
         | 
| 108 | 
            +
                  ]
         | 
| 109 | 
            +
              
         | 
| 110 | 
            +
                  @clean_url_with_id = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 111 | 
            +
            +       "http://", "www.example.com", 80, "/identity/show/5", { "id" => "5" }
         | 
| 112 | 
            +
                  ), "identity", "show")
         | 
| 113 | 
            +
              
         | 
| 114 | 
            +
                  @clean_url_with_same_action_and_controller_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 115 | 
            +
            +       "http://", "www.example.com", 80, "/login/login", {  }
         | 
| 116 | 
            +
                  ), "login", "login")
         | 
| 117 | 
            +
              
         | 
| 118 | 
            +
                  @clean_url_with_same_action_and_controller_and_module_name = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 119 | 
            +
            +       "http://", "www.example.com", 80, "/login/login/login", { "module" => "login" }
         | 
| 120 | 
            +
                  ), "login", "login")
         | 
| 121 | 
            +
              
         | 
| 122 | 
            +
                  @clean_url_with_id_as_char = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 123 | 
            +
            +       "http://", "www.example.com", 80, "/teachers/show/t", { "id" => "t" }
         | 
| 124 | 
            +
                  ), "teachers", "show")
         | 
| 125 | 
            +
                end
         | 
| 126 | 
            +
              
         | 
| 127 | 
            +
                def test_clean_action
         | 
| 128 | 
            +
            +     assert_equal "http://www.example.com/library/books/ISBN/0743536703/edit", @library_url.rewrite(:action => "edit")
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
              
         | 
| 131 | 
            +
                def test_clean_action_to_another_host
         | 
| 132 | 
            +
                  assert_equal(
         | 
| 133 | 
            +
            +       "http://www.example.com/library/books/ISBN/0743536703/edit", 
         | 
| 134 | 
            +
            +       @library_url.rewrite(:action => "edit", :host => "www.example.com")
         | 
| 135 | 
            +
                  )
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
              
         | 
| 138 | 
            +
                def test_clean_action_to_another_host_and_protocol
         | 
| 139 | 
            +
                  assert_equal(
         | 
| 140 | 
            +
            +       "https://www.example.com/library/books/ISBN/0743536703/edit", 
         | 
| 141 | 
            +
            +       @library_url.rewrite(:action => "edit", :host => "www.example.com", :protocol => "https://")
         | 
| 142 | 
            +
                  )
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
              
         | 
| 145 | 
            +
            ***************
         | 
| 146 | 
            +
            *** 106,246 ****
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
              
         | 
| 149 | 
            +
                def test_action_from_index
         | 
| 150 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/edit", @library_url_on_index.rewrite(:action => "edit")
         | 
| 151 | 
            +
                end
         | 
| 152 | 
            +
              
         | 
| 153 | 
            +
                def test_action_from_index_on_clean
         | 
| 154 | 
            +
                  @clean_urls.each do |url|
         | 
| 155 | 
            +
            -       assert_equal "http://www.singlefile.com/identity/edit", url.rewrite(:action => "edit")
         | 
| 156 | 
            +
                  end
         | 
| 157 | 
            +
                end
         | 
| 158 | 
            +
              
         | 
| 159 | 
            +
                def test_action_without_prefix
         | 
| 160 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/", @library_url.rewrite(:action => "index", :action_prefix => "")
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
              
         | 
| 163 | 
            +
                def test_action_with_prefix
         | 
| 164 | 
            +
                  assert_equal(
         | 
| 165 | 
            +
            -       "http://www.singlefile.com/library/books/XTC/123/show", 
         | 
| 166 | 
            +
                    @library_url.rewrite(:action => "show", :action_prefix => "XTC/123")
         | 
| 167 | 
            +
                  )
         | 
| 168 | 
            +
                end
         | 
| 169 | 
            +
              
         | 
| 170 | 
            +
                def test_action_prefix_alone
         | 
| 171 | 
            +
                  assert_equal(
         | 
| 172 | 
            +
            -       "http://www.singlefile.com/library/books/XTC/123/",
         | 
| 173 | 
            +
                    @library_url.rewrite(:action_prefix => "XTC/123")
         | 
| 174 | 
            +
                  )
         | 
| 175 | 
            +
                end
         | 
| 176 | 
            +
              
         | 
| 177 | 
            +
                def test_action_with_suffix
         | 
| 178 | 
            +
                  assert_equal(
         | 
| 179 | 
            +
            -       "http://www.singlefile.com/library/books/show/XTC/123",
         | 
| 180 | 
            +
                    @library_url.rewrite(:action => "show", :action_prefix => "", :action_suffix => "XTC/123")
         | 
| 181 | 
            +
                  )
         | 
| 182 | 
            +
                end
         | 
| 183 | 
            +
              
         | 
| 184 | 
            +
                def test_clean_controller
         | 
| 185 | 
            +
            -     assert_equal "http://www.singlefile.com/library/settings/", @library_url.rewrite(:controller => "settings")
         | 
| 186 | 
            +
                end
         | 
| 187 | 
            +
              
         | 
| 188 | 
            +
                def test_clean_controller_prefix
         | 
| 189 | 
            +
            -     assert_equal "http://www.singlefile.com/shop/", @library_url.rewrite(:controller_prefix => "shop")
         | 
| 190 | 
            +
                end
         | 
| 191 | 
            +
              
         | 
| 192 | 
            +
                def test_clean_controller_with_module
         | 
| 193 | 
            +
            -     assert_equal "http://www.singlefile.com/shop/purchases/", @library_url.rewrite(:module => "shop", :controller => "purchases")
         | 
| 194 | 
            +
                end
         | 
| 195 | 
            +
                
         | 
| 196 | 
            +
                def test_getting_out_of_a_module
         | 
| 197 | 
            +
            -     assert_equal "http://www.singlefile.com/purchases/", @library_url_using_module.rewrite(:module => false, :controller => "purchases")
         | 
| 198 | 
            +
                end
         | 
| 199 | 
            +
              
         | 
| 200 | 
            +
                def test_controller_and_action
         | 
| 201 | 
            +
            -     assert_equal "http://www.singlefile.com/library/settings/show", @library_url.rewrite(:controller => "settings", :action => "show")
         | 
| 202 | 
            +
                end
         | 
| 203 | 
            +
              
         | 
| 204 | 
            +
                def test_controller_and_action_and_anchor
         | 
| 205 | 
            +
                  assert_equal(
         | 
| 206 | 
            +
            -       "http://www.singlefile.com/library/settings/show#5", 
         | 
| 207 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :anchor => "5")
         | 
| 208 | 
            +
                  )
         | 
| 209 | 
            +
                end
         | 
| 210 | 
            +
              
         | 
| 211 | 
            +
                def test_controller_and_action_and_empty_overwrite_params_and_anchor
         | 
| 212 | 
            +
                  assert_equal(
         | 
| 213 | 
            +
            -       "http://www.singlefile.com/library/settings/show?code=0743536703&type=ISBN#5", 
         | 
| 214 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {},  :anchor => "5")
         | 
| 215 | 
            +
                  )
         | 
| 216 | 
            +
                end
         | 
| 217 | 
            +
                
         | 
| 218 | 
            +
                def test_controller_and_action_and_overwrite_params_and_anchor
         | 
| 219 | 
            +
                  assert_equal(
         | 
| 220 | 
            +
            -       "http://www.singlefile.com/library/settings/show?code=0000001&type=ISBN#5", 
         | 
| 221 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code"=>"0000001"},  :anchor => "5")
         | 
| 222 | 
            +
                  )
         | 
| 223 | 
            +
                end
         | 
| 224 | 
            +
              
         | 
| 225 | 
            +
                def test_controller_and_action_and_overwrite_params_with_nil_value_and_anchor
         | 
| 226 | 
            +
                  assert_equal(
         | 
| 227 | 
            +
            -       "http://www.singlefile.com/library/settings/show?type=ISBN#5", 
         | 
| 228 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code" => nil},  :anchor => "5")
         | 
| 229 | 
            +
                  )
         | 
| 230 | 
            +
                end
         | 
| 231 | 
            +
              
         | 
| 232 | 
            +
                def test_controller_and_action_params_and_overwrite_params_and_anchor
         | 
| 233 | 
            +
                  assert_equal(
         | 
| 234 | 
            +
            -       "http://www.singlefile.com/library/settings/show?code=0000001&version=5.0#5", 
         | 
| 235 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :params=>{"version" => "5.0"},  :overwrite_params => {"code"=>"0000001"},  :anchor => "5")
         | 
| 236 | 
            +
                  )
         | 
| 237 | 
            +
                end
         | 
| 238 | 
            +
              
         | 
| 239 | 
            +
                def test_controller_and_action_and_params_anchor
         | 
| 240 | 
            +
                  assert_equal(
         | 
| 241 | 
            +
            -       "http://www.singlefile.com/library/settings/show?update=1#5", 
         | 
| 242 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :params => { "update" => "1"}, :anchor => "5")
         | 
| 243 | 
            +
                  )
         | 
| 244 | 
            +
                end
         | 
| 245 | 
            +
              
         | 
| 246 | 
            +
                def test_controller_and_index_action
         | 
| 247 | 
            +
            -     assert_equal "http://www.singlefile.com/library/settings/", @library_url.rewrite(:controller => "settings", :action => "index")
         | 
| 248 | 
            +
                end
         | 
| 249 | 
            +
              
         | 
| 250 | 
            +
                def test_same_controller_and_action_names
         | 
| 251 | 
            +
            -     assert_equal "http://www.singlefile.com/login/logout", @clean_url_with_same_action_and_controller_name.rewrite(:action => "logout")
         | 
| 252 | 
            +
                end
         | 
| 253 | 
            +
              
         | 
| 254 | 
            +
                def xtest_same_module_and_controller_and_action_names
         | 
| 255 | 
            +
            -     assert_equal "http://www.singlefile.com/login/login/logout", @clean_url_with_same_action_and_controller_and_module_name.rewrite(:action => "logout")
         | 
| 256 | 
            +
                end
         | 
| 257 | 
            +
              
         | 
| 258 | 
            +
                def test_controller_and_action_with_same_name_as_controller
         | 
| 259 | 
            +
                  @clean_urls.each do |url|
         | 
| 260 | 
            +
            -       assert_equal "http://www.singlefile.com/anything/identity", url.rewrite(:controller => "anything", :action => "identity")
         | 
| 261 | 
            +
                  end
         | 
| 262 | 
            +
                end
         | 
| 263 | 
            +
              
         | 
| 264 | 
            +
                def test_controller_and_index_action_without_controller_prefix
         | 
| 265 | 
            +
                  assert_equal(
         | 
| 266 | 
            +
            -       "http://www.singlefile.com/settings/", 
         | 
| 267 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "index", :controller_prefix => "")
         | 
| 268 | 
            +
                  )
         | 
| 269 | 
            +
                end
         | 
| 270 | 
            +
              
         | 
| 271 | 
            +
                def test_controller_and_index_action_with_controller_prefix
         | 
| 272 | 
            +
                  assert_equal(
         | 
| 273 | 
            +
            -       "http://www.singlefile.com/fantastic/settings/show", 
         | 
| 274 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :controller_prefix => "fantastic")
         | 
| 275 | 
            +
                  )
         | 
| 276 | 
            +
                end
         | 
| 277 | 
            +
              
         | 
| 278 | 
            +
                def test_path_parameters
         | 
| 279 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/EXBC/0743536703/show", @library_url.rewrite(:path_params => {"type" => "EXBC"})
         | 
| 280 | 
            +
                end
         | 
| 281 | 
            +
                
         | 
| 282 | 
            +
                def test_parameters
         | 
| 283 | 
            +
                  assert_equal(
         | 
| 284 | 
            +
            -       "http://www.singlefile.com/library/books/ISBN/0743536703/show?delete=1&name=David", 
         | 
| 285 | 
            +
                    @library_url.rewrite(:params => {"delete" => "1", "name" => "David"})
         | 
| 286 | 
            +
                  )
         | 
| 287 | 
            +
                end
         | 
| 288 | 
            +
            --- 106,246 ----
         | 
| 289 | 
            +
                end
         | 
| 290 | 
            +
              
         | 
| 291 | 
            +
                def test_action_from_index
         | 
| 292 | 
            +
            +     assert_equal "http://www.example.com/library/books/ISBN/0743536703/edit", @library_url_on_index.rewrite(:action => "edit")
         | 
| 293 | 
            +
                end
         | 
| 294 | 
            +
              
         | 
| 295 | 
            +
                def test_action_from_index_on_clean
         | 
| 296 | 
            +
                  @clean_urls.each do |url|
         | 
| 297 | 
            +
            +       assert_equal "http://www.example.com/identity/edit", url.rewrite(:action => "edit")
         | 
| 298 | 
            +
                  end
         | 
| 299 | 
            +
                end
         | 
| 300 | 
            +
              
         | 
| 301 | 
            +
                def test_action_without_prefix
         | 
| 302 | 
            +
            +     assert_equal "http://www.example.com/library/books/", @library_url.rewrite(:action => "index", :action_prefix => "")
         | 
| 303 | 
            +
                end
         | 
| 304 | 
            +
              
         | 
| 305 | 
            +
                def test_action_with_prefix
         | 
| 306 | 
            +
                  assert_equal(
         | 
| 307 | 
            +
            +       "http://www.example.com/library/books/XTC/123/show", 
         | 
| 308 | 
            +
                    @library_url.rewrite(:action => "show", :action_prefix => "XTC/123")
         | 
| 309 | 
            +
                  )
         | 
| 310 | 
            +
                end
         | 
| 311 | 
            +
              
         | 
| 312 | 
            +
                def test_action_prefix_alone
         | 
| 313 | 
            +
                  assert_equal(
         | 
| 314 | 
            +
            +       "http://www.example.com/library/books/XTC/123/",
         | 
| 315 | 
            +
                    @library_url.rewrite(:action_prefix => "XTC/123")
         | 
| 316 | 
            +
                  )
         | 
| 317 | 
            +
                end
         | 
| 318 | 
            +
              
         | 
| 319 | 
            +
                def test_action_with_suffix
         | 
| 320 | 
            +
                  assert_equal(
         | 
| 321 | 
            +
            +       "http://www.example.com/library/books/show/XTC/123",
         | 
| 322 | 
            +
                    @library_url.rewrite(:action => "show", :action_prefix => "", :action_suffix => "XTC/123")
         | 
| 323 | 
            +
                  )
         | 
| 324 | 
            +
                end
         | 
| 325 | 
            +
              
         | 
| 326 | 
            +
                def test_clean_controller
         | 
| 327 | 
            +
            +     assert_equal "http://www.example.com/library/settings/", @library_url.rewrite(:controller => "settings")
         | 
| 328 | 
            +
                end
         | 
| 329 | 
            +
              
         | 
| 330 | 
            +
                def test_clean_controller_prefix
         | 
| 331 | 
            +
            +     assert_equal "http://www.example.com/shop/", @library_url.rewrite(:controller_prefix => "shop")
         | 
| 332 | 
            +
                end
         | 
| 333 | 
            +
              
         | 
| 334 | 
            +
                def test_clean_controller_with_module
         | 
| 335 | 
            +
            +     assert_equal "http://www.example.com/shop/purchases/", @library_url.rewrite(:module => "shop", :controller => "purchases")
         | 
| 336 | 
            +
                end
         | 
| 337 | 
            +
                
         | 
| 338 | 
            +
                def test_getting_out_of_a_module
         | 
| 339 | 
            +
            +     assert_equal "http://www.example.com/purchases/", @library_url_using_module.rewrite(:module => false, :controller => "purchases")
         | 
| 340 | 
            +
                end
         | 
| 341 | 
            +
              
         | 
| 342 | 
            +
                def test_controller_and_action
         | 
| 343 | 
            +
            +     assert_equal "http://www.example.com/library/settings/show", @library_url.rewrite(:controller => "settings", :action => "show")
         | 
| 344 | 
            +
                end
         | 
| 345 | 
            +
              
         | 
| 346 | 
            +
                def test_controller_and_action_and_anchor
         | 
| 347 | 
            +
                  assert_equal(
         | 
| 348 | 
            +
            +       "http://www.example.com/library/settings/show#5", 
         | 
| 349 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :anchor => "5")
         | 
| 350 | 
            +
                  )
         | 
| 351 | 
            +
                end
         | 
| 352 | 
            +
              
         | 
| 353 | 
            +
                def test_controller_and_action_and_empty_overwrite_params_and_anchor
         | 
| 354 | 
            +
                  assert_equal(
         | 
| 355 | 
            +
            +       "http://www.example.com/library/settings/show?code=0743536703&type=ISBN#5", 
         | 
| 356 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {},  :anchor => "5")
         | 
| 357 | 
            +
                  )
         | 
| 358 | 
            +
                end
         | 
| 359 | 
            +
                
         | 
| 360 | 
            +
                def test_controller_and_action_and_overwrite_params_and_anchor
         | 
| 361 | 
            +
                  assert_equal(
         | 
| 362 | 
            +
            +       "http://www.example.com/library/settings/show?code=0000001&type=ISBN#5", 
         | 
| 363 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code"=>"0000001"},  :anchor => "5")
         | 
| 364 | 
            +
                  )
         | 
| 365 | 
            +
                end
         | 
| 366 | 
            +
              
         | 
| 367 | 
            +
                def test_controller_and_action_and_overwrite_params_with_nil_value_and_anchor
         | 
| 368 | 
            +
                  assert_equal(
         | 
| 369 | 
            +
            +       "http://www.example.com/library/settings/show?type=ISBN#5", 
         | 
| 370 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :overwrite_params => {"code" => nil},  :anchor => "5")
         | 
| 371 | 
            +
                  )
         | 
| 372 | 
            +
                end
         | 
| 373 | 
            +
              
         | 
| 374 | 
            +
                def test_controller_and_action_params_and_overwrite_params_and_anchor
         | 
| 375 | 
            +
                  assert_equal(
         | 
| 376 | 
            +
            +       "http://www.example.com/library/settings/show?code=0000001&version=5.0#5", 
         | 
| 377 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :params=>{"version" => "5.0"},  :overwrite_params => {"code"=>"0000001"},  :anchor => "5")
         | 
| 378 | 
            +
                  )
         | 
| 379 | 
            +
                end
         | 
| 380 | 
            +
              
         | 
| 381 | 
            +
                def test_controller_and_action_and_params_anchor
         | 
| 382 | 
            +
                  assert_equal(
         | 
| 383 | 
            +
            +       "http://www.example.com/library/settings/show?update=1#5", 
         | 
| 384 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :params => { "update" => "1"}, :anchor => "5")
         | 
| 385 | 
            +
                  )
         | 
| 386 | 
            +
                end
         | 
| 387 | 
            +
              
         | 
| 388 | 
            +
                def test_controller_and_index_action
         | 
| 389 | 
            +
            +     assert_equal "http://www.example.com/library/settings/", @library_url.rewrite(:controller => "settings", :action => "index")
         | 
| 390 | 
            +
                end
         | 
| 391 | 
            +
              
         | 
| 392 | 
            +
                def test_same_controller_and_action_names
         | 
| 393 | 
            +
            +     assert_equal "http://www.example.com/login/logout", @clean_url_with_same_action_and_controller_name.rewrite(:action => "logout")
         | 
| 394 | 
            +
                end
         | 
| 395 | 
            +
              
         | 
| 396 | 
            +
                def xtest_same_module_and_controller_and_action_names
         | 
| 397 | 
            +
            +     assert_equal "http://www.example.com/login/login/logout", @clean_url_with_same_action_and_controller_and_module_name.rewrite(:action => "logout")
         | 
| 398 | 
            +
                end
         | 
| 399 | 
            +
              
         | 
| 400 | 
            +
                def test_controller_and_action_with_same_name_as_controller
         | 
| 401 | 
            +
                  @clean_urls.each do |url|
         | 
| 402 | 
            +
            +       assert_equal "http://www.example.com/anything/identity", url.rewrite(:controller => "anything", :action => "identity")
         | 
| 403 | 
            +
                  end
         | 
| 404 | 
            +
                end
         | 
| 405 | 
            +
              
         | 
| 406 | 
            +
                def test_controller_and_index_action_without_controller_prefix
         | 
| 407 | 
            +
                  assert_equal(
         | 
| 408 | 
            +
            +       "http://www.example.com/settings/", 
         | 
| 409 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "index", :controller_prefix => "")
         | 
| 410 | 
            +
                  )
         | 
| 411 | 
            +
                end
         | 
| 412 | 
            +
              
         | 
| 413 | 
            +
                def test_controller_and_index_action_with_controller_prefix
         | 
| 414 | 
            +
                  assert_equal(
         | 
| 415 | 
            +
            +       "http://www.example.com/fantastic/settings/show", 
         | 
| 416 | 
            +
                    @library_url.rewrite(:controller => "settings", :action => "show", :controller_prefix => "fantastic")
         | 
| 417 | 
            +
                  )
         | 
| 418 | 
            +
                end
         | 
| 419 | 
            +
              
         | 
| 420 | 
            +
                def test_path_parameters
         | 
| 421 | 
            +
            +     assert_equal "http://www.example.com/library/books/EXBC/0743536703/show", @library_url.rewrite(:path_params => {"type" => "EXBC"})
         | 
| 422 | 
            +
                end
         | 
| 423 | 
            +
                
         | 
| 424 | 
            +
                def test_parameters
         | 
| 425 | 
            +
                  assert_equal(
         | 
| 426 | 
            +
            +       "http://www.example.com/library/books/ISBN/0743536703/show?delete=1&name=David", 
         | 
| 427 | 
            +
                    @library_url.rewrite(:params => {"delete" => "1", "name" => "David"})
         | 
| 428 | 
            +
                  )
         | 
| 429 | 
            +
                end
         | 
| 430 | 
            +
            ***************
         | 
| 431 | 
            +
            *** 248,254 ****
         | 
| 432 | 
            +
                def test_parameters_with_id
         | 
| 433 | 
            +
                  @clean_urls.each do |url|
         | 
| 434 | 
            +
                    assert_equal(
         | 
| 435 | 
            +
            -         "http://www.singlefile.com/identity/show?name=David&id=5", 
         | 
| 436 | 
            +
                      url.rewrite(
         | 
| 437 | 
            +
                        :action => "show",
         | 
| 438 | 
            +
                        :params => { "id" => "5", "name" => "David" }
         | 
| 439 | 
            +
            --- 248,254 ----
         | 
| 440 | 
            +
                def test_parameters_with_id
         | 
| 441 | 
            +
                  @clean_urls.each do |url|
         | 
| 442 | 
            +
                    assert_equal(
         | 
| 443 | 
            +
            +         "http://www.example.com/identity/show?name=David&id=5", 
         | 
| 444 | 
            +
                      url.rewrite(
         | 
| 445 | 
            +
                        :action => "show",
         | 
| 446 | 
            +
                        :params => { "id" => "5", "name" => "David" }
         | 
| 447 | 
            +
            ***************
         | 
| 448 | 
            +
            *** 260,266 ****
         | 
| 449 | 
            +
                def test_parameters_with_array
         | 
| 450 | 
            +
                  @clean_urls.each do |url|
         | 
| 451 | 
            +
                    assert_equal(
         | 
| 452 | 
            +
            -         "http://www.singlefile.com/identity/show?id[]=3&id[]=5&id[]=10",
         | 
| 453 | 
            +
              	url.rewrite(
         | 
| 454 | 
            +
              		:action => "show",
         | 
| 455 | 
            +
              		:params => { 'id' => [ 3, 5, 10 ] } )
         | 
| 456 | 
            +
            --- 260,266 ----
         | 
| 457 | 
            +
                def test_parameters_with_array
         | 
| 458 | 
            +
                  @clean_urls.each do |url|
         | 
| 459 | 
            +
                    assert_equal(
         | 
| 460 | 
            +
            +         "http://www.example.com/identity/show?id[]=3&id[]=5&id[]=10",
         | 
| 461 | 
            +
              	url.rewrite(
         | 
| 462 | 
            +
              		:action => "show",
         | 
| 463 | 
            +
              		:params => { 'id' => [ 3, 5, 10 ] } )
         | 
| 464 | 
            +
            ***************
         | 
| 465 | 
            +
            *** 270,276 ****
         | 
| 466 | 
            +
              
         | 
| 467 | 
            +
                def test_action_with_id
         | 
| 468 | 
            +
                 assert_equal(
         | 
| 469 | 
            +
            -       "http://www.singlefile.com/identity/show/7", 
         | 
| 470 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 471 | 
            +
                      :action => "show", 
         | 
| 472 | 
            +
                      :id => 7
         | 
| 473 | 
            +
            --- 270,276 ----
         | 
| 474 | 
            +
              
         | 
| 475 | 
            +
                def test_action_with_id
         | 
| 476 | 
            +
                 assert_equal(
         | 
| 477 | 
            +
            +       "http://www.example.com/identity/show/7", 
         | 
| 478 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 479 | 
            +
                      :action => "show", 
         | 
| 480 | 
            +
                      :id => 7
         | 
| 481 | 
            +
            ***************
         | 
| 482 | 
            +
            *** 278,284 ****
         | 
| 483 | 
            +
                  )
         | 
| 484 | 
            +
                  @clean_urls.each do |url|
         | 
| 485 | 
            +
                    assert_equal(
         | 
| 486 | 
            +
            -         "http://www.singlefile.com/identity/index/7", 
         | 
| 487 | 
            +
                      url.rewrite(:id => 7)
         | 
| 488 | 
            +
                    )
         | 
| 489 | 
            +
                  end
         | 
| 490 | 
            +
            --- 278,284 ----
         | 
| 491 | 
            +
                  )
         | 
| 492 | 
            +
                  @clean_urls.each do |url|
         | 
| 493 | 
            +
                    assert_equal(
         | 
| 494 | 
            +
            +         "http://www.example.com/identity/index/7", 
         | 
| 495 | 
            +
                      url.rewrite(:id => 7)
         | 
| 496 | 
            +
                    )
         | 
| 497 | 
            +
                  end
         | 
| 498 | 
            +
            ***************
         | 
| 499 | 
            +
            *** 286,292 ****
         | 
| 500 | 
            +
              
         | 
| 501 | 
            +
                def test_parameters_with_id_and_away
         | 
| 502 | 
            +
                  assert_equal(
         | 
| 503 | 
            +
            -       "http://www.singlefile.com/identity/show/25?name=David", 
         | 
| 504 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 505 | 
            +
                      :path_params => { "id" => "25" },
         | 
| 506 | 
            +
                      :params => { "name" => "David" }
         | 
| 507 | 
            +
            --- 286,292 ----
         | 
| 508 | 
            +
              
         | 
| 509 | 
            +
                def test_parameters_with_id_and_away
         | 
| 510 | 
            +
                  assert_equal(
         | 
| 511 | 
            +
            +       "http://www.example.com/identity/show/25?name=David", 
         | 
| 512 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 513 | 
            +
                      :path_params => { "id" => "25" },
         | 
| 514 | 
            +
                      :params => { "name" => "David" }
         | 
| 515 | 
            +
            ***************
         | 
| 516 | 
            +
            *** 297,303 ****
         | 
| 517 | 
            +
                def test_parameters_with_index_and_id
         | 
| 518 | 
            +
                  @clean_urls.each do |url|
         | 
| 519 | 
            +
                    assert_equal(
         | 
| 520 | 
            +
            -         "http://www.singlefile.com/identity/index/25?name=David", 
         | 
| 521 | 
            +
                      url.rewrite(
         | 
| 522 | 
            +
                        :path_params => { "id" => "25" },
         | 
| 523 | 
            +
                        :params => { "name" => "David" }
         | 
| 524 | 
            +
            --- 297,303 ----
         | 
| 525 | 
            +
                def test_parameters_with_index_and_id
         | 
| 526 | 
            +
                  @clean_urls.each do |url|
         | 
| 527 | 
            +
                    assert_equal(
         | 
| 528 | 
            +
            +         "http://www.example.com/identity/index/25?name=David", 
         | 
| 529 | 
            +
                      url.rewrite(
         | 
| 530 | 
            +
                        :path_params => { "id" => "25" },
         | 
| 531 | 
            +
                        :params => { "name" => "David" }
         | 
| 532 | 
            +
            ***************
         | 
| 533 | 
            +
            *** 308,314 ****
         | 
| 534 | 
            +
              
         | 
| 535 | 
            +
                def test_action_going_away_from_id
         | 
| 536 | 
            +
                  assert_equal(
         | 
| 537 | 
            +
            -       "http://www.singlefile.com/identity/list", 
         | 
| 538 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 539 | 
            +
                      :action => "list"
         | 
| 540 | 
            +
                    )
         | 
| 541 | 
            +
            --- 308,314 ----
         | 
| 542 | 
            +
              
         | 
| 543 | 
            +
                def test_action_going_away_from_id
         | 
| 544 | 
            +
                  assert_equal(
         | 
| 545 | 
            +
            +       "http://www.example.com/identity/list", 
         | 
| 546 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 547 | 
            +
                      :action => "list"
         | 
| 548 | 
            +
                    )
         | 
| 549 | 
            +
            ***************
         | 
| 550 | 
            +
            *** 317,323 ****
         | 
| 551 | 
            +
              
         | 
| 552 | 
            +
                def test_parameters_with_direct_id_and_away
         | 
| 553 | 
            +
                  assert_equal(
         | 
| 554 | 
            +
            -       "http://www.singlefile.com/identity/show/25?name=David", 
         | 
| 555 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 556 | 
            +
                      :id => "25",
         | 
| 557 | 
            +
                      :params => { "name" => "David" }
         | 
| 558 | 
            +
            --- 317,323 ----
         | 
| 559 | 
            +
              
         | 
| 560 | 
            +
                def test_parameters_with_direct_id_and_away
         | 
| 561 | 
            +
                  assert_equal(
         | 
| 562 | 
            +
            +       "http://www.example.com/identity/show/25?name=David", 
         | 
| 563 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 564 | 
            +
                      :id => "25",
         | 
| 565 | 
            +
                      :params => { "name" => "David" }
         | 
| 566 | 
            +
            ***************
         | 
| 567 | 
            +
            *** 327,333 ****
         | 
| 568 | 
            +
              
         | 
| 569 | 
            +
                def test_parameters_with_direct_id_and_away
         | 
| 570 | 
            +
                  assert_equal(
         | 
| 571 | 
            +
            -       "http://www.singlefile.com/store/open/25?name=David", 
         | 
| 572 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 573 | 
            +
                      :controller => "store",
         | 
| 574 | 
            +
                      :action => "open",
         | 
| 575 | 
            +
            --- 327,333 ----
         | 
| 576 | 
            +
              
         | 
| 577 | 
            +
                def test_parameters_with_direct_id_and_away
         | 
| 578 | 
            +
                  assert_equal(
         | 
| 579 | 
            +
            +       "http://www.example.com/store/open/25?name=David", 
         | 
| 580 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 581 | 
            +
                      :controller => "store",
         | 
| 582 | 
            +
                      :action => "open",
         | 
| 583 | 
            +
            ***************
         | 
| 584 | 
            +
            *** 341,347 ****
         | 
| 585 | 
            +
                  @clean_urls.each do |url|
         | 
| 586 | 
            +
                    %w(show index).each do |action|
         | 
| 587 | 
            +
                      assert_equal(
         | 
| 588 | 
            +
            -           "http://www.singlefile.com/identity/#{action}/25?name=David", 
         | 
| 589 | 
            +
                        url.rewrite(
         | 
| 590 | 
            +
                          :action => action,
         | 
| 591 | 
            +
                          :path_params => { "id" => "25" },
         | 
| 592 | 
            +
            --- 341,347 ----
         | 
| 593 | 
            +
                  @clean_urls.each do |url|
         | 
| 594 | 
            +
                    %w(show index).each do |action|
         | 
| 595 | 
            +
                      assert_equal(
         | 
| 596 | 
            +
            +           "http://www.example.com/identity/#{action}/25?name=David", 
         | 
| 597 | 
            +
                        url.rewrite(
         | 
| 598 | 
            +
                          :action => action,
         | 
| 599 | 
            +
                          :path_params => { "id" => "25" },
         | 
| 600 | 
            +
            ***************
         | 
| 601 | 
            +
            *** 354,360 ****
         | 
| 602 | 
            +
              
         | 
| 603 | 
            +
                def test_parameters_from_id
         | 
| 604 | 
            +
                  assert_equal(
         | 
| 605 | 
            +
            -       "http://www.singlefile.com/identity/", 
         | 
| 606 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 607 | 
            +
                      :action => "index"
         | 
| 608 | 
            +
                    )
         | 
| 609 | 
            +
            --- 354,360 ----
         | 
| 610 | 
            +
              
         | 
| 611 | 
            +
                def test_parameters_from_id
         | 
| 612 | 
            +
                  assert_equal(
         | 
| 613 | 
            +
            +       "http://www.example.com/identity/", 
         | 
| 614 | 
            +
                    @clean_url_with_id.rewrite(
         | 
| 615 | 
            +
                      :action => "index"
         | 
| 616 | 
            +
                    )
         | 
| 617 | 
            +
            ***************
         | 
| 618 | 
            +
            *** 363,369 ****
         | 
| 619 | 
            +
                
         | 
| 620 | 
            +
                def test_id_as_char_and_part_of_controller
         | 
| 621 | 
            +
                  assert_equal(
         | 
| 622 | 
            +
            -       "http://www.singlefile.com/teachers/skill/5", 
         | 
| 623 | 
            +
                    @clean_url_with_id_as_char.rewrite(
         | 
| 624 | 
            +
                      :action => "skill",
         | 
| 625 | 
            +
                      :id => 5
         | 
| 626 | 
            +
            --- 363,369 ----
         | 
| 627 | 
            +
                
         | 
| 628 | 
            +
                def test_id_as_char_and_part_of_controller
         | 
| 629 | 
            +
                  assert_equal(
         | 
| 630 | 
            +
            +       "http://www.example.com/teachers/skill/5", 
         | 
| 631 | 
            +
                    @clean_url_with_id_as_char.rewrite(
         | 
| 632 | 
            +
                      :action => "skill",
         | 
| 633 | 
            +
                      :id => 5
         | 
| 634 | 
            +
            ***************
         | 
| 635 | 
            +
            *** 374,380 ****
         | 
| 636 | 
            +
                def test_from_clean_to_library
         | 
| 637 | 
            +
                  @clean_urls.each do |url|
         | 
| 638 | 
            +
                    assert_equal(
         | 
| 639 | 
            +
            -         "http://www.singlefile.com/library/books/ISBN/0743536703/show?delete=1&name=David", 
         | 
| 640 | 
            +
                      url.rewrite(
         | 
| 641 | 
            +
                        :controller_prefix => "library",
         | 
| 642 | 
            +
                        :controller => "books", 
         | 
| 643 | 
            +
            --- 374,380 ----
         | 
| 644 | 
            +
                def test_from_clean_to_library
         | 
| 645 | 
            +
                  @clean_urls.each do |url|
         | 
| 646 | 
            +
                    assert_equal(
         | 
| 647 | 
            +
            +         "http://www.example.com/library/books/ISBN/0743536703/show?delete=1&name=David", 
         | 
| 648 | 
            +
                      url.rewrite(
         | 
| 649 | 
            +
                        :controller_prefix => "library",
         | 
| 650 | 
            +
                        :controller => "books", 
         | 
| 651 | 
            +
            ***************
         | 
| 652 | 
            +
            *** 388,394 ****
         | 
| 653 | 
            +
                
         | 
| 654 | 
            +
                def test_from_library_to_clean
         | 
| 655 | 
            +
                  assert_equal(
         | 
| 656 | 
            +
            -       "http://www.singlefile.com/identity/", 
         | 
| 657 | 
            +
                    @library_url.rewrite(
         | 
| 658 | 
            +
                      :controller => "identity", :controller_prefix => ""
         | 
| 659 | 
            +
                    )
         | 
| 660 | 
            +
            --- 388,394 ----
         | 
| 661 | 
            +
                
         | 
| 662 | 
            +
                def test_from_library_to_clean
         | 
| 663 | 
            +
                  assert_equal(
         | 
| 664 | 
            +
            +       "http://www.example.com/identity/", 
         | 
| 665 | 
            +
                    @library_url.rewrite(
         | 
| 666 | 
            +
                      :controller => "identity", :controller_prefix => ""
         | 
| 667 | 
            +
                    )
         | 
| 668 | 
            +
            ***************
         | 
| 669 | 
            +
            *** 398,411 ****
         | 
| 670 | 
            +
                def test_from_another_port
         | 
| 671 | 
            +
                  @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 672 | 
            +
                    "http://",
         | 
| 673 | 
            +
            -       "www.singlefile.com", 
         | 
| 674 | 
            +
                    8080,
         | 
| 675 | 
            +
                    "/library/books/ISBN/0743536703/show", 
         | 
| 676 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 677 | 
            +
                  ), "books", "show")
         | 
| 678 | 
            +
              
         | 
| 679 | 
            +
                  assert_equal(
         | 
| 680 | 
            +
            -       "http://www.singlefile.com:8080/identity/", 
         | 
| 681 | 
            +
                    @library_url.rewrite(
         | 
| 682 | 
            +
                      :controller => "identity", :controller_prefix => ""
         | 
| 683 | 
            +
                    )
         | 
| 684 | 
            +
            --- 398,411 ----
         | 
| 685 | 
            +
                def test_from_another_port
         | 
| 686 | 
            +
                  @library_url = ActionController::UrlRewriter.old_new(MockRequest.new(
         | 
| 687 | 
            +
                    "http://",
         | 
| 688 | 
            +
            +       "www.example.com", 
         | 
| 689 | 
            +
                    8080,
         | 
| 690 | 
            +
                    "/library/books/ISBN/0743536703/show", 
         | 
| 691 | 
            +
                    { "type" => "ISBN", "code" => "0743536703" }
         | 
| 692 | 
            +
                  ), "books", "show")
         | 
| 693 | 
            +
              
         | 
| 694 | 
            +
                  assert_equal(
         | 
| 695 | 
            +
            +       "http://www.example.com:8080/identity/", 
         | 
| 696 | 
            +
                    @library_url.rewrite(
         | 
| 697 | 
            +
                      :controller => "identity", :controller_prefix => ""
         | 
| 698 | 
            +
                    )
         | 
| 699 | 
            +
            ***************
         | 
| 700 | 
            +
            *** 465,487 ****
         | 
| 701 | 
            +
                end
         | 
| 702 | 
            +
              
         | 
| 703 | 
            +
                def test_clean_application_prefix
         | 
| 704 | 
            +
            -     assert_equal "http://www.singlefile.com/namespace/library/books/ISBN/0743536703/show",
         | 
| 705 | 
            +
                    @library_url.rewrite(:application_prefix => "/namespace")
         | 
| 706 | 
            +
                end
         | 
| 707 | 
            +
              
         | 
| 708 | 
            +
                def test_clean_application_prefix_with_controller_prefix
         | 
| 709 | 
            +
            -     assert_equal "http://www.singlefile.com/namespace/shop/",
         | 
| 710 | 
            +
                    @library_url.rewrite(:application_prefix => "/namespace",
         | 
| 711 | 
            +
                                         :controller_prefix => "shop" )
         | 
| 712 | 
            +
                end
         | 
| 713 | 
            +
              
         | 
| 714 | 
            +
                def test_blank_application_prefix
         | 
| 715 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/show",
         | 
| 716 | 
            +
                    @library_url.rewrite(:application_prefix => "")
         | 
| 717 | 
            +
                end
         | 
| 718 | 
            +
              
         | 
| 719 | 
            +
                def test_nil_application_prefix
         | 
| 720 | 
            +
            -     assert_equal "http://www.singlefile.com/library/books/ISBN/0743536703/show",
         | 
| 721 | 
            +
                    @library_url.rewrite(:application_prefix => nil)
         | 
| 722 | 
            +
                end
         | 
| 723 | 
            +
              end
         | 
| 724 | 
            +
            --- 465,487 ----
         | 
| 725 | 
            +
                end
         | 
| 726 | 
            +
              
         | 
| 727 | 
            +
                def test_clean_application_prefix
         | 
| 728 | 
            +
            +     assert_equal "http://www.example.com/namespace/library/books/ISBN/0743536703/show",
         | 
| 729 | 
            +
                    @library_url.rewrite(:application_prefix => "/namespace")
         | 
| 730 | 
            +
                end
         | 
| 731 | 
            +
              
         | 
| 732 | 
            +
                def test_clean_application_prefix_with_controller_prefix
         | 
| 733 | 
            +
            +     assert_equal "http://www.example.com/namespace/shop/",
         | 
| 734 | 
            +
                    @library_url.rewrite(:application_prefix => "/namespace",
         | 
| 735 | 
            +
                                         :controller_prefix => "shop" )
         | 
| 736 | 
            +
                end
         | 
| 737 | 
            +
              
         | 
| 738 | 
            +
                def test_blank_application_prefix
         | 
| 739 | 
            +
            +     assert_equal "http://www.example.com/library/books/ISBN/0743536703/show",
         | 
| 740 | 
            +
                    @library_url.rewrite(:application_prefix => "")
         | 
| 741 | 
            +
                end
         | 
| 742 | 
            +
              
         | 
| 743 | 
            +
                def test_nil_application_prefix
         | 
| 744 | 
            +
            +     assert_equal "http://www.example.com/library/books/ISBN/0743536703/show",
         | 
| 745 | 
            +
                    @library_url.rewrite(:application_prefix => nil)
         | 
| 746 | 
            +
                end
         | 
| 747 | 
            +
              end
         |