actionpack 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

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