actionpack 2.2.3 → 2.3.2
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.
- data/CHANGELOG +433 -375
- data/MIT-LICENSE +1 -1
- data/README +21 -75
- data/Rakefile +1 -1
- data/lib/action_controller.rb +80 -43
- data/lib/action_controller/assertions/model_assertions.rb +1 -0
- data/lib/action_controller/assertions/response_assertions.rb +43 -16
- data/lib/action_controller/assertions/routing_assertions.rb +1 -1
- data/lib/action_controller/assertions/selector_assertions.rb +17 -12
- data/lib/action_controller/assertions/tag_assertions.rb +1 -4
- data/lib/action_controller/base.rb +153 -82
- data/lib/action_controller/benchmarking.rb +9 -9
- data/lib/action_controller/caching.rb +9 -11
- data/lib/action_controller/caching/actions.rb +11 -18
- data/lib/action_controller/caching/fragments.rb +28 -20
- data/lib/action_controller/caching/pages.rb +13 -15
- data/lib/action_controller/caching/sweeping.rb +2 -2
- data/lib/action_controller/cgi_ext.rb +0 -1
- data/lib/action_controller/cgi_ext/cookie.rb +2 -0
- data/lib/action_controller/cgi_process.rb +54 -162
- data/lib/action_controller/cookies.rb +13 -25
- data/lib/action_controller/dispatcher.rb +43 -122
- data/lib/action_controller/failsafe.rb +52 -0
- data/lib/action_controller/flash.rb +38 -47
- data/lib/action_controller/helpers.rb +13 -9
- data/lib/action_controller/http_authentication.rb +203 -23
- data/lib/action_controller/integration.rb +126 -70
- data/lib/action_controller/layout.rb +36 -39
- data/lib/action_controller/middleware_stack.rb +119 -0
- data/lib/action_controller/middlewares.rb +13 -0
- data/lib/action_controller/mime_responds.rb +19 -4
- data/lib/action_controller/mime_type.rb +8 -0
- data/lib/action_controller/params_parser.rb +71 -0
- data/lib/action_controller/performance_test.rb +0 -1
- data/lib/action_controller/polymorphic_routes.rb +36 -30
- data/lib/action_controller/reloader.rb +14 -0
- data/lib/action_controller/request.rb +107 -499
- data/lib/action_controller/request_forgery_protection.rb +7 -39
- data/lib/action_controller/rescue.rb +55 -35
- data/lib/action_controller/resources.rb +34 -31
- data/lib/action_controller/response.rb +99 -57
- data/lib/action_controller/rewindable_input.rb +28 -0
- data/lib/action_controller/routing.rb +7 -7
- data/lib/action_controller/routing/builder.rb +4 -1
- data/lib/action_controller/routing/optimisations.rb +1 -1
- data/lib/action_controller/routing/recognition_optimisation.rb +1 -2
- data/lib/action_controller/routing/route.rb +15 -5
- data/lib/action_controller/routing/route_set.rb +82 -35
- data/lib/action_controller/routing/segments.rb +35 -0
- data/lib/action_controller/session/abstract_store.rb +181 -0
- data/lib/action_controller/session/cookie_store.rb +197 -175
- data/lib/action_controller/session/mem_cache_store.rb +36 -83
- data/lib/action_controller/session_management.rb +26 -134
- data/lib/action_controller/streaming.rb +24 -7
- data/lib/action_controller/templates/rescues/diagnostics.erb +2 -2
- data/lib/action_controller/templates/rescues/template_error.erb +2 -2
- data/lib/action_controller/test_case.rb +87 -30
- data/lib/action_controller/test_process.rb +145 -104
- data/lib/action_controller/uploaded_file.rb +44 -0
- data/lib/action_controller/url_rewriter.rb +3 -6
- data/lib/action_controller/vendor/html-scanner.rb +16 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +1 -1
- data/lib/action_controller/vendor/rack-1.0/rack.rb +89 -0
- data/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +22 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +37 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +37 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +58 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +124 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +51 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +40 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +480 -0
- data/lib/action_controller/vendor/rack-1.0/rack/builder.rb +63 -0
- data/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +36 -0
- data/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +49 -0
- data/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +61 -0
- data/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +45 -0
- data/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +29 -0
- data/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +23 -0
- data/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +85 -0
- data/lib/action_controller/vendor/rack-1.0/rack/directory.rb +153 -0
- data/lib/action_controller/vendor/rack-1.0/rack/file.rb +88 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler.rb +48 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +61 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +8 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +89 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +84 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +59 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +8 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +18 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +67 -0
- data/lib/action_controller/vendor/rack-1.0/rack/head.rb +19 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lint.rb +462 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +65 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lock.rb +16 -0
- data/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +27 -0
- data/lib/action_controller/vendor/rack-1.0/rack/mime.rb +204 -0
- data/lib/action_controller/vendor/rack-1.0/rack/mock.rb +160 -0
- data/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +57 -0
- data/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +64 -0
- data/lib/action_controller/vendor/rack-1.0/rack/request.rb +241 -0
- data/lib/action_controller/vendor/rack-1.0/rack/response.rb +179 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +142 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +91 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +109 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +100 -0
- data/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +349 -0
- data/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +106 -0
- data/lib/action_controller/vendor/rack-1.0/rack/static.rb +38 -0
- data/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/utils.rb +392 -0
- data/lib/action_controller/verification.rb +1 -1
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +2 -2
- data/lib/action_view.rb +22 -17
- data/lib/action_view/base.rb +53 -79
- data/lib/action_view/erb/util.rb +38 -0
- data/lib/action_view/helpers.rb +24 -5
- data/lib/action_view/helpers/active_record_helper.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +81 -50
- data/lib/action_view/helpers/atom_feed_helper.rb +1 -1
- data/lib/action_view/helpers/benchmark_helper.rb +26 -5
- data/lib/action_view/helpers/date_helper.rb +82 -7
- data/lib/action_view/helpers/form_helper.rb +295 -64
- data/lib/action_view/helpers/form_options_helper.rb +160 -18
- data/lib/action_view/helpers/form_tag_helper.rb +2 -2
- data/lib/action_view/helpers/number_helper.rb +31 -18
- data/lib/action_view/helpers/prototype_helper.rb +2 -12
- data/lib/action_view/helpers/sanitize_helper.rb +0 -10
- data/lib/action_view/helpers/scriptaculous_helper.rb +1 -0
- data/lib/action_view/helpers/tag_helper.rb +3 -4
- data/lib/action_view/helpers/text_helper.rb +99 -122
- data/lib/action_view/helpers/translation_helper.rb +19 -1
- data/lib/action_view/helpers/url_helper.rb +25 -2
- data/lib/action_view/inline_template.rb +1 -1
- data/lib/action_view/locale/en.yml +19 -1
- data/lib/action_view/partials.rb +46 -9
- data/lib/action_view/paths.rb +28 -84
- data/lib/action_view/reloadable_template.rb +117 -0
- data/lib/action_view/renderable.rb +28 -35
- data/lib/action_view/renderable_partial.rb +3 -4
- data/lib/action_view/template.rb +172 -31
- data/lib/action_view/template_error.rb +8 -9
- data/lib/action_view/template_handler.rb +1 -1
- data/lib/action_view/template_handlers.rb +9 -6
- data/lib/action_view/template_handlers/erb.rb +2 -39
- data/lib/action_view/template_handlers/rjs.rb +1 -0
- data/lib/action_view/test_case.rb +27 -1
- data/test/abstract_unit.rb +23 -17
- data/test/active_record_unit.rb +5 -4
- data/test/activerecord/active_record_store_test.rb +139 -106
- data/test/activerecord/render_partial_with_record_identification_test.rb +5 -21
- data/test/controller/action_pack_assertions_test.rb +25 -23
- data/test/controller/addresses_render_test.rb +3 -6
- data/test/controller/assert_select_test.rb +83 -70
- data/test/controller/base_test.rb +11 -13
- data/test/controller/benchmark_test.rb +3 -3
- data/test/controller/caching_test.rb +34 -24
- data/test/controller/capture_test.rb +3 -6
- data/test/controller/content_type_test.rb +3 -6
- data/test/controller/cookie_test.rb +31 -66
- data/test/controller/deprecation/deprecated_base_methods_test.rb +9 -11
- data/test/controller/dispatcher_test.rb +23 -28
- data/test/controller/fake_models.rb +8 -0
- data/test/controller/filters_test.rb +6 -2
- data/test/controller/flash_test.rb +2 -6
- data/test/controller/helper_test.rb +15 -1
- data/test/controller/html-scanner/document_test.rb +1 -1
- data/test/controller/html-scanner/sanitizer_test.rb +1 -1
- data/test/controller/http_basic_authentication_test.rb +88 -0
- data/test/controller/http_digest_authentication_test.rb +178 -0
- data/test/controller/integration_test.rb +56 -52
- data/test/controller/layout_test.rb +46 -44
- data/test/controller/middleware_stack_test.rb +90 -0
- data/test/controller/mime_responds_test.rb +7 -11
- data/test/controller/mime_type_test.rb +9 -0
- data/test/controller/polymorphic_routes_test.rb +235 -151
- data/test/controller/rack_test.rb +52 -81
- data/test/controller/redirect_test.rb +6 -14
- data/test/controller/render_test.rb +273 -60
- data/test/controller/request/json_params_parsing_test.rb +45 -0
- data/test/controller/request/multipart_params_parsing_test.rb +223 -0
- data/test/controller/request/query_string_parsing_test.rb +120 -0
- data/test/controller/request/url_encoded_params_parsing_test.rb +184 -0
- data/test/controller/request/xml_params_parsing_test.rb +88 -0
- data/test/controller/request_forgery_protection_test.rb +17 -98
- data/test/controller/request_test.rb +45 -530
- data/test/controller/rescue_test.rb +45 -22
- data/test/controller/resources_test.rb +112 -37
- data/test/controller/routing_test.rb +1442 -1384
- data/test/controller/selector_test.rb +3 -3
- data/test/controller/send_file_test.rb +30 -3
- data/test/controller/session/cookie_store_test.rb +169 -240
- data/test/controller/session/mem_cache_store_test.rb +94 -148
- data/test/controller/session/test_session_test.rb +58 -0
- data/test/controller/test_test.rb +32 -13
- data/test/controller/url_rewriter_test.rb +54 -4
- data/test/controller/verification_test.rb +1 -1
- data/test/controller/view_paths_test.rb +15 -15
- data/test/controller/webservice_test.rb +178 -147
- data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
- data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
- data/test/fixtures/layouts/default_html.html.erb +1 -0
- data/test/fixtures/layouts/xhr.html.erb +2 -0
- data/test/fixtures/multipart/empty +10 -0
- data/test/fixtures/multipart/hello.txt +1 -0
- data/test/fixtures/multipart/none +9 -0
- data/test/fixtures/public/500.da.html +1 -0
- data/test/fixtures/quiz/questions/_question.html.erb +1 -0
- data/test/fixtures/replies.yml +1 -1
- data/test/fixtures/test/_one.html.erb +1 -0
- data/test/fixtures/test/_two.html.erb +1 -0
- data/test/fixtures/test/dont_pick_me +1 -0
- data/test/fixtures/test/hello.builder +1 -1
- data/test/fixtures/test/hello_world.da.html.erb +1 -0
- data/test/fixtures/test/hello_world.erb~ +1 -0
- data/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
- data/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
- data/test/fixtures/test/malformed/malformed.erb~ +1 -0
- data/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
- data/test/fixtures/test/render_explicit_html_template.js.rjs +1 -0
- data/test/fixtures/test/render_implicit_html_template.js.rjs +1 -0
- data/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
- data/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
- data/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +1 -0
- data/test/fixtures/test/utf8.html.erb +2 -0
- data/test/template/active_record_helper_i18n_test.rb +31 -33
- data/test/template/active_record_helper_test.rb +34 -0
- data/test/template/asset_tag_helper_test.rb +52 -14
- data/test/template/atom_feed_helper_test.rb +3 -5
- data/test/template/benchmark_helper_test.rb +50 -24
- data/test/template/compiled_templates_test.rb +177 -33
- data/test/template/date_helper_i18n_test.rb +88 -81
- data/test/template/date_helper_test.rb +427 -43
- data/test/template/form_helper_test.rb +243 -44
- data/test/template/form_options_helper_test.rb +631 -565
- data/test/template/form_tag_helper_test.rb +9 -2
- data/test/template/javascript_helper_test.rb +0 -5
- data/test/template/number_helper_i18n_test.rb +60 -48
- data/test/template/number_helper_test.rb +1 -0
- data/test/template/render_test.rb +117 -35
- data/test/template/test_test.rb +4 -6
- data/test/template/text_helper_test.rb +129 -50
- data/test/template/translation_helper_test.rb +23 -19
- data/test/template/url_helper_test.rb +35 -2
- data/test/view/test_case_test.rb +8 -0
- metadata +197 -23
- data/lib/action_controller/assertions.rb +0 -69
- data/lib/action_controller/caching/sql_cache.rb +0 -18
- data/lib/action_controller/cgi_ext/session.rb +0 -53
- data/lib/action_controller/components.rb +0 -169
- data/lib/action_controller/rack_process.rb +0 -297
- data/lib/action_controller/request_profiler.rb +0 -169
- data/lib/action_controller/session/active_record_store.rb +0 -340
- data/lib/action_controller/session/drb_server.rb +0 -32
- data/lib/action_controller/session/drb_store.rb +0 -35
- data/test/controller/cgi_test.rb +0 -269
- data/test/controller/components_test.rb +0 -156
- data/test/controller/http_authentication_test.rb +0 -54
- data/test/controller/integration_upload_test.rb +0 -43
- data/test/controller/session_fixation_test.rb +0 -89
- data/test/controller/session_management_test.rb +0 -178
- data/test/fixtures/test/hello_world.js +0 -1
@@ -162,13 +162,11 @@ class RespondToController < ActionController::Base
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
class MimeControllerTest <
|
165
|
+
class MimeControllerTest < ActionController::TestCase
|
166
|
+
tests RespondToController
|
167
|
+
|
166
168
|
def setup
|
167
169
|
ActionController::Base.use_accept_header = true
|
168
|
-
@request = ActionController::TestRequest.new
|
169
|
-
@response = ActionController::TestResponse.new
|
170
|
-
|
171
|
-
@controller = RespondToController.new
|
172
170
|
@request.host = "www.example.com"
|
173
171
|
end
|
174
172
|
|
@@ -471,7 +469,7 @@ class MimeControllerTest < Test::Unit::TestCase
|
|
471
469
|
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
|
472
470
|
|
473
471
|
@request.accept = "text/iphone"
|
474
|
-
|
472
|
+
assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
|
475
473
|
end
|
476
474
|
end
|
477
475
|
|
@@ -509,12 +507,10 @@ class SuperPostController < PostController
|
|
509
507
|
end
|
510
508
|
end
|
511
509
|
|
512
|
-
class MimeControllerLayoutsTest <
|
513
|
-
|
514
|
-
@request = ActionController::TestRequest.new
|
515
|
-
@response = ActionController::TestResponse.new
|
510
|
+
class MimeControllerLayoutsTest < ActionController::TestCase
|
511
|
+
tests PostController
|
516
512
|
|
517
|
-
|
513
|
+
def setup
|
518
514
|
@request.host = "www.example.com"
|
519
515
|
end
|
520
516
|
|
@@ -81,4 +81,13 @@ class MimeTypeTest < Test::Unit::TestCase
|
|
81
81
|
assert verified.each { |type| assert Mime.const_get(type.to_s.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
|
82
82
|
assert unverified.each { |type| assert !Mime.const_get(type.to_s.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
|
83
83
|
end
|
84
|
+
|
85
|
+
def test_regexp_matcher
|
86
|
+
assert Mime::JS =~ "text/javascript"
|
87
|
+
assert Mime::JS =~ "application/javascript"
|
88
|
+
assert Mime::JS !~ "text/html"
|
89
|
+
assert !(Mime::JS !~ "text/javascript")
|
90
|
+
assert !(Mime::JS !~ "application/javascript")
|
91
|
+
assert Mime::HTML =~ 'application/xhtml+xml'
|
92
|
+
end
|
84
93
|
end
|
@@ -18,192 +18,276 @@ class Tag < Article
|
|
18
18
|
def response_id; 1 end
|
19
19
|
end
|
20
20
|
|
21
|
+
class Tax
|
22
|
+
attr_reader :id
|
23
|
+
def save; @id = 1 end
|
24
|
+
def new_record?; @id.nil? end
|
25
|
+
def name
|
26
|
+
model = self.class.name.downcase
|
27
|
+
@id.nil? ? "new #{model}" : "#{model} ##{@id}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Fax < Tax
|
32
|
+
def store_id; 1 end
|
33
|
+
end
|
34
|
+
|
21
35
|
# TODO: test nested models
|
22
36
|
class Response::Nested < Response; end
|
23
37
|
|
24
|
-
|
25
|
-
|
38
|
+
class PolymorphicRoutesTest < ActiveSupport::TestCase
|
39
|
+
include ActionController::PolymorphicRoutes
|
26
40
|
|
27
|
-
|
41
|
+
def setup
|
42
|
+
@article = Article.new
|
43
|
+
@response = Response.new
|
44
|
+
@tax = Tax.new
|
45
|
+
@fax = Fax.new
|
46
|
+
end
|
28
47
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def test_with_record
|
35
|
-
@article.save
|
36
|
-
expects(:article_url).with(@article)
|
37
|
-
polymorphic_url(@article)
|
38
|
-
end
|
48
|
+
def test_with_record
|
49
|
+
@article.save
|
50
|
+
expects(:article_url).with(@article)
|
51
|
+
polymorphic_url(@article)
|
52
|
+
end
|
39
53
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
54
|
+
def test_with_new_record
|
55
|
+
expects(:articles_url).with()
|
56
|
+
@article.expects(:new_record?).returns(true)
|
57
|
+
polymorphic_url(@article)
|
58
|
+
end
|
45
59
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
def test_with_record_and_action
|
61
|
+
expects(:new_article_url).with()
|
62
|
+
@article.expects(:new_record?).never
|
63
|
+
polymorphic_url(@article, :action => 'new')
|
64
|
+
end
|
51
65
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
def test_url_helper_prefixed_with_new
|
67
|
+
expects(:new_article_url).with()
|
68
|
+
new_polymorphic_url(@article)
|
69
|
+
end
|
56
70
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
71
|
+
def test_url_helper_prefixed_with_edit
|
72
|
+
@article.save
|
73
|
+
expects(:edit_article_url).with(@article)
|
74
|
+
edit_polymorphic_url(@article)
|
75
|
+
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
77
|
+
def test_url_helper_prefixed_with_edit_with_url_options
|
78
|
+
@article.save
|
79
|
+
expects(:edit_article_url).with(@article, :param1 => '10')
|
80
|
+
edit_polymorphic_url(@article, :param1 => '10')
|
81
|
+
end
|
68
82
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
83
|
+
def test_url_helper_with_url_options
|
84
|
+
@article.save
|
85
|
+
expects(:article_url).with(@article, :param1 => '10')
|
86
|
+
polymorphic_url(@article, :param1 => '10')
|
87
|
+
end
|
74
88
|
|
75
|
-
|
76
|
-
|
89
|
+
def test_formatted_url_helper_is_deprecated
|
90
|
+
expects(:articles_url).with(:format => :pdf)
|
91
|
+
assert_deprecated do
|
77
92
|
formatted_polymorphic_url([@article, :pdf])
|
78
93
|
end
|
94
|
+
end
|
79
95
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
96
|
+
def test_format_option
|
97
|
+
@article.save
|
98
|
+
expects(:article_url).with(@article, :format => :pdf)
|
99
|
+
polymorphic_url(@article, :format => :pdf)
|
100
|
+
end
|
85
101
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
102
|
+
def test_format_option_with_url_options
|
103
|
+
@article.save
|
104
|
+
expects(:article_url).with(@article, :format => :pdf, :param1 => '10')
|
105
|
+
polymorphic_url(@article, :format => :pdf, :param1 => '10')
|
106
|
+
end
|
91
107
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
108
|
+
def test_id_and_format_option
|
109
|
+
@article.save
|
110
|
+
expects(:article_url).with(:id => @article, :format => :pdf)
|
111
|
+
polymorphic_url(:id => @article, :format => :pdf)
|
112
|
+
end
|
97
113
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
114
|
+
def test_with_nested
|
115
|
+
@response.save
|
116
|
+
expects(:article_response_url).with(@article, @response)
|
117
|
+
polymorphic_url([@article, @response])
|
118
|
+
end
|
103
119
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
120
|
+
def test_with_nested_unsaved
|
121
|
+
expects(:article_responses_url).with(@article)
|
122
|
+
polymorphic_url([@article, @response])
|
123
|
+
end
|
108
124
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
125
|
+
def test_new_with_array_and_namespace
|
126
|
+
expects(:new_admin_article_url).with()
|
127
|
+
polymorphic_url([:admin, @article], :action => 'new')
|
128
|
+
end
|
113
129
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
130
|
+
def test_unsaved_with_array_and_namespace
|
131
|
+
expects(:admin_articles_url).with()
|
132
|
+
polymorphic_url([:admin, @article])
|
133
|
+
end
|
118
134
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
135
|
+
def test_nested_unsaved_with_array_and_namespace
|
136
|
+
@article.save
|
137
|
+
expects(:admin_article_url).with(@article)
|
138
|
+
polymorphic_url([:admin, @article])
|
139
|
+
expects(:admin_article_responses_url).with(@article)
|
140
|
+
polymorphic_url([:admin, @article, @response])
|
141
|
+
end
|
126
142
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
143
|
+
def test_nested_with_array_and_namespace
|
144
|
+
@response.save
|
145
|
+
expects(:admin_article_response_url).with(@article, @response)
|
146
|
+
polymorphic_url([:admin, @article, @response])
|
131
147
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
148
|
+
# a ridiculously long named route tests correct ordering of namespaces and nesting:
|
149
|
+
@tag = Tag.new
|
150
|
+
@tag.save
|
151
|
+
expects(:site_admin_article_response_tag_url).with(@article, @response, @tag)
|
152
|
+
polymorphic_url([:site, :admin, @article, @response, @tag])
|
153
|
+
end
|
138
154
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
155
|
+
def test_nesting_with_array_ending_in_singleton_resource
|
156
|
+
expects(:article_response_url).with(@article)
|
157
|
+
polymorphic_url([@article, :response])
|
158
|
+
end
|
143
159
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
160
|
+
def test_nesting_with_array_containing_singleton_resource
|
161
|
+
@tag = Tag.new
|
162
|
+
@tag.save
|
163
|
+
expects(:article_response_tag_url).with(@article, @tag)
|
164
|
+
polymorphic_url([@article, :response, @tag])
|
165
|
+
end
|
150
166
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
167
|
+
def test_nesting_with_array_containing_namespace_and_singleton_resource
|
168
|
+
@tag = Tag.new
|
169
|
+
@tag.save
|
170
|
+
expects(:admin_article_response_tag_url).with(@article, @tag)
|
171
|
+
polymorphic_url([:admin, @article, :response, @tag])
|
172
|
+
end
|
157
173
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
174
|
+
def test_nesting_with_array_containing_singleton_resource_and_format
|
175
|
+
@tag = Tag.new
|
176
|
+
@tag.save
|
177
|
+
expects(:article_response_tag_url).with(@article, @tag, :format => :pdf)
|
178
|
+
polymorphic_url([@article, :response, @tag], :format => :pdf)
|
179
|
+
end
|
164
180
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
181
|
+
def test_nesting_with_array_containing_singleton_resource_and_format_option
|
182
|
+
@tag = Tag.new
|
183
|
+
@tag.save
|
184
|
+
expects(:article_response_tag_url).with(@article, @tag, :format => :pdf)
|
185
|
+
polymorphic_url([@article, :response, @tag], :format => :pdf)
|
186
|
+
end
|
171
187
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
188
|
+
def test_nesting_with_array_containing_nil
|
189
|
+
expects(:article_response_url).with(@article)
|
190
|
+
polymorphic_url([@article, nil, :response])
|
191
|
+
end
|
176
192
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
193
|
+
def test_with_array_containing_single_object
|
194
|
+
@article.save
|
195
|
+
expects(:article_url).with(@article)
|
196
|
+
polymorphic_url([nil, @article])
|
197
|
+
end
|
182
198
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
199
|
+
def test_with_array_containing_single_name
|
200
|
+
@article.save
|
201
|
+
expects(:articles_url)
|
202
|
+
polymorphic_url([:articles])
|
203
|
+
end
|
188
204
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
205
|
+
# TODO: Needs to be updated to correctly know about whether the object is in a hash or not
|
206
|
+
def xtest_with_hash
|
207
|
+
expects(:article_url).with(@article)
|
208
|
+
@article.save
|
209
|
+
polymorphic_url(:id => @article)
|
210
|
+
end
|
195
211
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
212
|
+
def test_polymorphic_path_accepts_options
|
213
|
+
expects(:new_article_path).with()
|
214
|
+
polymorphic_path(@article, :action => :new)
|
215
|
+
end
|
200
216
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
217
|
+
def test_polymorphic_path_does_not_modify_arguments
|
218
|
+
expects(:admin_article_responses_url).with(@article)
|
219
|
+
path = [:admin, @article, @response]
|
220
|
+
assert_no_difference 'path.size' do
|
221
|
+
polymorphic_url(path)
|
207
222
|
end
|
208
223
|
end
|
224
|
+
|
225
|
+
# Tests for names where .plural.singular doesn't round-trip
|
226
|
+
def test_with_irregular_plural_record
|
227
|
+
@tax.save
|
228
|
+
expects(:taxis_url).with(@tax)
|
229
|
+
polymorphic_url(@tax)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_with_irregular_plural_new_record
|
233
|
+
expects(:taxes_url).with()
|
234
|
+
@tax.expects(:new_record?).returns(true)
|
235
|
+
polymorphic_url(@tax)
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_with_irregular_plural_record_and_action
|
239
|
+
expects(:new_taxis_url).with()
|
240
|
+
@tax.expects(:new_record?).never
|
241
|
+
polymorphic_url(@tax, :action => 'new')
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_irregular_plural_url_helper_prefixed_with_new
|
245
|
+
expects(:new_taxis_url).with()
|
246
|
+
new_polymorphic_url(@tax)
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_irregular_plural_url_helper_prefixed_with_edit
|
250
|
+
@tax.save
|
251
|
+
expects(:edit_taxis_url).with(@tax)
|
252
|
+
edit_polymorphic_url(@tax)
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_with_nested_irregular_plurals
|
256
|
+
@fax.save
|
257
|
+
expects(:taxis_faxis_url).with(@tax, @fax)
|
258
|
+
polymorphic_url([@tax, @fax])
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_with_nested_unsaved_irregular_plurals
|
262
|
+
expects(:taxis_faxes_url).with(@tax)
|
263
|
+
polymorphic_url([@tax, @fax])
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_new_with_irregular_plural_array_and_namespace
|
267
|
+
expects(:new_admin_taxis_url).with()
|
268
|
+
polymorphic_url([:admin, @tax], :action => 'new')
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_unsaved_with_irregular_plural_array_and_namespace
|
272
|
+
expects(:admin_taxes_url).with()
|
273
|
+
polymorphic_url([:admin, @tax])
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource
|
277
|
+
expects(:taxis_faxis_url).with(@tax)
|
278
|
+
polymorphic_url([@tax, :faxis])
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_with_array_containing_single_irregular_plural_object
|
282
|
+
@tax.save
|
283
|
+
expects(:taxis_url).with(@tax)
|
284
|
+
polymorphic_url([nil, @tax])
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_with_array_containing_single_name_irregular_plural
|
288
|
+
@tax.save
|
289
|
+
expects(:taxes_url)
|
290
|
+
polymorphic_url([:taxes])
|
291
|
+
end
|
292
|
+
|
209
293
|
end
|