actionpack 1.13.6 → 2.0.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.
- data/CHANGELOG +1400 -20
- data/MIT-LICENSE +1 -1
- data/README +5 -5
- data/RUNNING_UNIT_TESTS +4 -5
- data/Rakefile +5 -6
- data/install.rb +2 -2
- data/lib/action_controller.rb +11 -15
- data/lib/action_controller/assertions.rb +12 -25
- data/lib/action_controller/assertions/dom_assertions.rb +18 -4
- data/lib/action_controller/assertions/model_assertions.rb +8 -1
- data/lib/action_controller/assertions/response_assertions.rb +35 -12
- data/lib/action_controller/assertions/routing_assertions.rb +56 -12
- data/lib/action_controller/assertions/selector_assertions.rb +105 -38
- data/lib/action_controller/assertions/tag_assertions.rb +28 -15
- data/lib/action_controller/base.rb +318 -250
- data/lib/action_controller/benchmarking.rb +33 -29
- data/lib/action_controller/caching.rb +130 -64
- data/lib/action_controller/cgi_ext.rb +16 -0
- data/lib/action_controller/cgi_ext/{cookie_performance_fix.rb → cookie.rb} +25 -40
- data/lib/action_controller/cgi_ext/query_extension.rb +22 -0
- data/lib/action_controller/cgi_ext/session.rb +73 -0
- data/lib/action_controller/cgi_ext/stdinput.rb +23 -0
- data/lib/action_controller/cgi_process.rb +34 -57
- data/lib/action_controller/components.rb +19 -36
- data/lib/action_controller/cookies.rb +10 -9
- data/lib/action_controller/dispatcher.rb +195 -0
- data/lib/action_controller/filters.rb +35 -34
- data/lib/action_controller/flash.rb +30 -35
- data/lib/action_controller/helpers.rb +121 -47
- data/lib/action_controller/http_authentication.rb +126 -0
- data/lib/action_controller/integration.rb +105 -101
- data/lib/action_controller/layout.rb +59 -47
- data/lib/action_controller/mime_responds.rb +57 -68
- data/lib/action_controller/mime_type.rb +43 -80
- data/lib/action_controller/mime_types.rb +20 -0
- data/lib/action_controller/polymorphic_routes.rb +88 -0
- data/lib/action_controller/record_identifier.rb +91 -0
- data/lib/action_controller/request.rb +553 -88
- data/lib/action_controller/request_forgery_protection.rb +126 -0
- data/lib/action_controller/request_profiler.rb +138 -0
- data/lib/action_controller/rescue.rb +185 -69
- data/lib/action_controller/resources.rb +211 -172
- data/lib/action_controller/response.rb +49 -8
- data/lib/action_controller/routing.rb +359 -236
- data/lib/action_controller/routing_optimisation.rb +119 -0
- data/lib/action_controller/session/active_record_store.rb +3 -2
- data/lib/action_controller/session/cookie_store.rb +161 -0
- data/lib/action_controller/session/mem_cache_store.rb +9 -16
- data/lib/action_controller/session_management.rb +17 -8
- data/lib/action_controller/streaming.rb +6 -3
- data/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
- data/lib/action_controller/templates/rescues/{_trace.rhtml → _trace.erb} +0 -0
- data/lib/action_controller/templates/rescues/{diagnostics.rhtml → diagnostics.erb} +2 -2
- data/lib/action_controller/templates/rescues/{layout.rhtml → layout.erb} +0 -0
- data/lib/action_controller/templates/rescues/{missing_template.rhtml → missing_template.erb} +0 -0
- data/lib/action_controller/templates/rescues/{routing_error.rhtml → routing_error.erb} +0 -0
- data/lib/action_controller/templates/rescues/{template_error.rhtml → template_error.erb} +2 -2
- data/lib/action_controller/templates/rescues/{unknown_action.rhtml → unknown_action.erb} +0 -0
- data/lib/action_controller/test_case.rb +53 -0
- data/lib/action_controller/test_process.rb +59 -46
- data/lib/action_controller/url_rewriter.rb +48 -24
- data/lib/action_controller/vendor/html-scanner/html/document.rb +7 -4
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +11 -6
- data/lib/action_controller/verification.rb +27 -21
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +4 -4
- data/lib/action_view.rb +2 -3
- data/lib/action_view/base.rb +218 -63
- data/lib/action_view/compiled_templates.rb +1 -2
- data/lib/action_view/helpers/active_record_helper.rb +35 -17
- data/lib/action_view/helpers/asset_tag_helper.rb +395 -87
- data/lib/action_view/helpers/atom_feed_helper.rb +111 -0
- data/lib/action_view/helpers/benchmark_helper.rb +12 -5
- data/lib/action_view/helpers/cache_helper.rb +29 -0
- data/lib/action_view/helpers/capture_helper.rb +97 -63
- data/lib/action_view/helpers/date_helper.rb +295 -35
- data/lib/action_view/helpers/debug_helper.rb +6 -2
- data/lib/action_view/helpers/form_helper.rb +354 -111
- data/lib/action_view/helpers/form_options_helper.rb +171 -109
- data/lib/action_view/helpers/form_tag_helper.rb +332 -76
- data/lib/action_view/helpers/javascript_helper.rb +35 -11
- data/lib/action_view/helpers/javascripts/controls.js +484 -354
- data/lib/action_view/helpers/javascripts/dragdrop.js +88 -58
- data/lib/action_view/helpers/javascripts/effects.js +396 -364
- data/lib/action_view/helpers/javascripts/prototype.js +2817 -1107
- data/lib/action_view/helpers/number_helper.rb +84 -60
- data/lib/action_view/helpers/prototype_helper.rb +419 -43
- data/lib/action_view/helpers/record_identification_helper.rb +20 -0
- data/lib/action_view/helpers/record_tag_helper.rb +59 -0
- data/lib/action_view/helpers/sanitize_helper.rb +223 -0
- data/lib/action_view/helpers/scriptaculous_helper.rb +63 -4
- data/lib/action_view/helpers/tag_helper.rb +69 -39
- data/lib/action_view/helpers/text_helper.rb +221 -148
- data/lib/action_view/helpers/url_helper.rb +283 -165
- data/lib/action_view/partials.rb +134 -62
- data/lib/action_view/template_error.rb +4 -12
- data/lib/actionpack.rb +1 -0
- data/test/abstract_unit.rb +21 -1
- data/test/action_view_test.rb +26 -0
- data/test/active_record_unit.rb +12 -20
- data/test/activerecord/active_record_store_test.rb +2 -2
- data/test/activerecord/render_partial_with_record_identification_test.rb +74 -0
- data/test/controller/action_pack_assertions_test.rb +21 -152
- data/test/controller/addresses_render_test.rb +2 -7
- data/test/controller/assert_select_test.rb +120 -14
- data/test/controller/base_test.rb +11 -13
- data/test/controller/caching_test.rb +125 -5
- data/test/controller/capture_test.rb +23 -16
- data/test/controller/cgi_test.rb +66 -391
- data/test/controller/components_test.rb +31 -42
- data/test/controller/content_type_test.rb +1 -1
- data/test/controller/cookie_test.rb +42 -14
- data/test/controller/deprecation/deprecated_base_methods_test.rb +1 -42
- data/test/controller/dispatcher_test.rb +123 -0
- data/test/controller/fake_models.rb +5 -0
- data/test/controller/filters_test.rb +44 -7
- data/test/controller/flash_test.rb +46 -2
- data/test/controller/fragment_store_setting_test.rb +10 -8
- data/test/controller/helper_test.rb +19 -2
- data/test/controller/html-scanner/document_test.rb +124 -0
- data/test/controller/html-scanner/node_test.rb +69 -0
- data/test/controller/html-scanner/sanitizer_test.rb +250 -0
- data/test/controller/html-scanner/tag_node_test.rb +239 -0
- data/test/controller/html-scanner/text_node_test.rb +51 -0
- data/test/controller/html-scanner/tokenizer_test.rb +125 -0
- data/test/controller/http_authentication_test.rb +54 -0
- data/test/controller/integration_test.rb +12 -26
- data/test/controller/layout_test.rb +64 -12
- data/test/controller/mime_responds_test.rb +193 -38
- data/test/controller/mime_type_test.rb +30 -8
- data/test/controller/new_render_test.rb +104 -22
- data/test/controller/polymorphic_routes_test.rb +98 -0
- data/test/controller/record_identifier_test.rb +103 -0
- data/test/controller/redirect_test.rb +120 -18
- data/test/controller/render_test.rb +195 -45
- data/test/controller/request_forgery_protection_test.rb +217 -0
- data/test/controller/request_test.rb +545 -27
- data/test/controller/rescue_test.rb +501 -0
- data/test/controller/resources_test.rb +258 -132
- data/test/controller/routing_test.rb +502 -106
- data/test/controller/selector_test.rb +5 -5
- data/test/controller/send_file_test.rb +17 -7
- data/test/controller/session/cookie_store_test.rb +246 -0
- data/test/controller/session/mem_cache_store_test.rb +182 -0
- data/test/controller/session_fixation_test.rb +8 -11
- data/test/controller/session_management_test.rb +7 -7
- data/test/controller/test_test.rb +150 -38
- data/test/controller/url_rewriter_test.rb +87 -12
- data/test/controller/verification_test.rb +11 -0
- data/test/controller/view_paths_test.rb +137 -0
- data/test/controller/webservice_test.rb +11 -75
- data/test/fixtures/addresses/{list.rhtml → list.erb} +0 -0
- data/test/fixtures/db_definitions/sqlite.sql +2 -1
- data/test/fixtures/developer.rb +2 -0
- data/test/fixtures/fun/games/{hello_world.rhtml → hello_world.erb} +0 -0
- data/test/fixtures/helpers/fun/pdf_helper.rb +1 -1
- data/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/test/fixtures/layouts/{builder.rxml → builder.builder} +0 -0
- data/test/fixtures/layouts/{standard.rhtml → standard.erb} +0 -0
- data/test/fixtures/layouts/{talk_from_action.rhtml → talk_from_action.erb} +0 -0
- data/test/fixtures/layouts/{yield.rhtml → yield.erb} +0 -0
- data/test/fixtures/multipart/binary_file +0 -0
- data/test/fixtures/multipart/bracketed_param +5 -0
- data/test/fixtures/override/test/hello_world.erb +1 -0
- data/test/fixtures/override2/layouts/test/sub.erb +1 -0
- data/test/fixtures/post_test/layouts/post.html.erb +1 -0
- data/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
- data/test/fixtures/post_test/post/index.html.erb +1 -0
- data/test/fixtures/post_test/post/index.iphone.erb +1 -0
- data/test/fixtures/post_test/super_post/index.html.erb +1 -0
- data/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
- data/test/fixtures/public/404.html +1 -0
- data/test/fixtures/public/500.html +1 -0
- data/test/fixtures/public/javascripts/application.js +0 -1
- data/test/fixtures/public/javascripts/bank.js +1 -0
- data/test/fixtures/public/javascripts/robber.js +1 -0
- data/test/fixtures/public/stylesheets/bank.css +1 -0
- data/test/fixtures/public/stylesheets/robber.css +1 -0
- data/test/fixtures/replies.yml +2 -0
- data/test/fixtures/reply.rb +2 -1
- data/test/fixtures/respond_to/{all_types_with_layout.rhtml → all_types_with_layout.html.erb} +0 -0
- data/test/fixtures/respond_to/{all_types_with_layout.rjs → all_types_with_layout.js.rjs} +0 -0
- data/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
- data/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
- data/test/fixtures/respond_to/{using_defaults.rhtml → using_defaults.html.erb} +0 -0
- data/test/fixtures/respond_to/{using_defaults.rjs → using_defaults.js.rjs} +0 -0
- data/test/fixtures/respond_to/{using_defaults.rxml → using_defaults.xml.builder} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rhtml → using_defaults_with_type_list.html.erb} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rjs → using_defaults_with_type_list.js.rjs} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rxml → using_defaults_with_type_list.xml.builder} +0 -0
- data/test/fixtures/scope/test/{modgreet.rhtml → modgreet.erb} +0 -0
- data/test/fixtures/test/{_customer.rhtml → _customer.erb} +0 -0
- data/test/fixtures/test/{_customer_greeting.rhtml → _customer_greeting.erb} +0 -0
- data/test/fixtures/test/_hash_greeting.erb +1 -0
- data/test/fixtures/test/_hash_object.erb +2 -0
- data/test/fixtures/test/{_hello.rxml → _hello.builder} +0 -0
- data/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/test/fixtures/test/_partial.erb +1 -0
- data/test/fixtures/test/_partial.html.erb +1 -0
- data/test/fixtures/test/_partial.js.erb +1 -0
- data/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
- data/test/fixtures/test/{_partial_only.rhtml → _partial_only.erb} +0 -0
- data/test/fixtures/test/{_person.rhtml → _person.erb} +0 -0
- data/test/fixtures/test/{action_talk_to_layout.rhtml → action_talk_to_layout.erb} +0 -0
- data/test/fixtures/test/{block_content_for.rhtml → block_content_for.erb} +0 -0
- data/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/test/fixtures/test/{capturing.rhtml → capturing.erb} +0 -0
- data/test/fixtures/test/{content_for.rhtml → content_for.erb} +0 -0
- data/test/fixtures/test/content_for_concatenated.erb +3 -0
- data/test/fixtures/test/content_for_with_parameter.erb +2 -0
- data/test/fixtures/test/dot.directory/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
- data/test/fixtures/test/{erb_content_for.rhtml → erb_content_for.erb} +0 -0
- data/test/fixtures/test/formatted_html_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.builder +1 -0
- data/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
- data/test/fixtures/test/{greeting.rhtml → greeting.erb} +0 -0
- data/test/fixtures/test/{hello.rxml → hello.builder} +0 -0
- data/test/fixtures/test/{hello_world.rxml → hello_world.builder} +0 -0
- data/test/fixtures/test/{hello_world.rhtml → hello_world.erb} +0 -0
- data/test/fixtures/test/{hello_world_container.rxml → hello_world_container.builder} +0 -0
- data/test/fixtures/test/{hello_world_with_layout_false.rhtml → hello_world_with_layout_false.erb} +0 -0
- data/test/fixtures/test/{hello_xml_world.rxml → hello_xml_world.builder} +0 -0
- data/test/fixtures/test/list.erb +1 -0
- data/test/fixtures/test/{non_erb_block_content_for.rxml → non_erb_block_content_for.builder} +0 -0
- data/test/fixtures/test/{potential_conflicts.rhtml → potential_conflicts.erb} +0 -0
- data/test/fixtures/test/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
- data/test/fixtures/test/{render_file_with_locals.rhtml → render_file_with_locals.erb} +0 -0
- data/test/fixtures/test/{render_to_string_test.rhtml → render_to_string_test.erb} +0 -0
- data/test/fixtures/test/{update_element_with_capture.rhtml → update_element_with_capture.erb} +0 -0
- data/test/fixtures/test/using_layout_around_block.html.erb +1 -0
- data/test/fixtures/topic.rb +1 -1
- data/test/template/active_record_helper_test.rb +67 -20
- data/test/template/asset_tag_helper_test.rb +222 -54
- data/test/template/atom_feed_helper_test.rb +101 -0
- data/test/template/benchmark_helper_test.rb +2 -2
- data/test/template/compiled_templates_test.rb +76 -32
- data/test/template/date_helper_test.rb +125 -9
- data/test/template/form_helper_test.rb +326 -33
- data/test/template/form_options_helper_test.rb +822 -15
- data/test/template/form_tag_helper_test.rb +96 -30
- data/test/template/javascript_helper_test.rb +61 -13
- data/test/template/number_helper_test.rb +12 -11
- data/test/template/prototype_helper_test.rb +185 -24
- data/test/template/sanitize_helper_test.rb +49 -0
- data/test/template/scriptaculous_helper_test.rb +9 -3
- data/test/template/tag_helper_test.rb +13 -2
- data/test/template/text_helper_test.rb +38 -52
- data/test/template/url_helper_test.rb +216 -46
- metadata +144 -116
- data/examples/.htaccess +0 -24
- data/examples/address_book/index.rhtml +0 -33
- data/examples/address_book/layout.rhtml +0 -8
- data/examples/address_book_controller.cgi +0 -9
- data/examples/address_book_controller.fcgi +0 -6
- data/examples/address_book_controller.rb +0 -52
- data/examples/address_book_controller.rbx +0 -4
- data/examples/benchmark.rb +0 -52
- data/examples/benchmark_with_ar.fcgi +0 -89
- data/examples/blog_controller.cgi +0 -53
- data/examples/debate/index.rhtml +0 -14
- data/examples/debate/new_topic.rhtml +0 -22
- data/examples/debate/topic.rhtml +0 -32
- data/examples/debate_controller.cgi +0 -57
- data/lib/action_controller/assertions/deprecated_assertions.rb +0 -228
- data/lib/action_controller/cgi_ext/cgi_ext.rb +0 -36
- data/lib/action_controller/cgi_ext/cgi_methods.rb +0 -211
- data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +0 -30
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +0 -95
- data/lib/action_controller/cgi_ext/session_performance_fix.rb +0 -30
- data/lib/action_controller/deprecated_dependencies.rb +0 -65
- data/lib/action_controller/deprecated_redirects.rb +0 -17
- data/lib/action_controller/deprecated_request_methods.rb +0 -34
- data/lib/action_controller/macros/auto_complete.rb +0 -53
- data/lib/action_controller/macros/in_place_editing.rb +0 -33
- data/lib/action_controller/pagination.rb +0 -408
- data/lib/action_controller/scaffolding.rb +0 -189
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -44
- data/lib/action_controller/templates/scaffolds/edit.rhtml +0 -7
- data/lib/action_controller/templates/scaffolds/layout.rhtml +0 -69
- data/lib/action_controller/templates/scaffolds/list.rhtml +0 -27
- data/lib/action_controller/templates/scaffolds/new.rhtml +0 -6
- data/lib/action_controller/templates/scaffolds/show.rhtml +0 -9
- data/lib/action_controller/vendor/xml_node.rb +0 -97
- data/lib/action_view/helpers/deprecated_helper.rb +0 -37
- data/lib/action_view/helpers/java_script_macros_helper.rb +0 -233
- data/lib/action_view/helpers/pagination_helper.rb +0 -86
- data/test/activerecord/active_record_assertions_test.rb +0 -92
- data/test/activerecord/pagination_test.rb +0 -165
- data/test/controller/deprecated_instance_variables_test.rb +0 -48
- data/test/controller/raw_post_test.rb +0 -68
- data/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_flash_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_headers_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_params_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_request_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_response_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_session_method.rhtml +0 -1
- data/test/fixtures/respond_to/layouts/standard.rhtml +0 -1
- data/test/fixtures/test/_hash_object.rhtml +0 -1
- data/test/fixtures/test/list.rhtml +0 -1
- data/test/template/deprecated_helper_test.rb +0 -36
- data/test/template/deprecated_instance_variables_test.rb +0 -43
- data/test/template/java_script_macros_helper_test.rb +0 -109
@@ -1,228 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
|
3
|
-
module ActionController #:nodoc:
|
4
|
-
module Assertions #:nodoc:
|
5
|
-
module DeprecatedAssertions #:nodoc:
|
6
|
-
def assert_success(message=nil) #:nodoc:
|
7
|
-
assert_response(:success, message)
|
8
|
-
end
|
9
|
-
deprecate :assert_success => "use assert_response(:success)"
|
10
|
-
|
11
|
-
def assert_redirect(message=nil) #:nodoc:
|
12
|
-
assert_response(:redirect, message)
|
13
|
-
end
|
14
|
-
deprecate :assert_redirect => "use assert_response(:redirect)"
|
15
|
-
|
16
|
-
def assert_rendered_file(expected=nil, message=nil) #:nodoc:
|
17
|
-
assert_template(expected, message)
|
18
|
-
end
|
19
|
-
deprecate :assert_rendered_file => :assert_template
|
20
|
-
|
21
|
-
# ensure that the session has an object with the specified name
|
22
|
-
def assert_session_has(key=nil, message=nil) #:nodoc:
|
23
|
-
msg = build_message(message, "<?> is not in the session <?>", key, @response.session)
|
24
|
-
assert_block(msg) { @response.has_session_object?(key) }
|
25
|
-
end
|
26
|
-
deprecate :assert_session_has => "use assert(@response.has_session_object?(key))"
|
27
|
-
|
28
|
-
# ensure that the session has no object with the specified name
|
29
|
-
def assert_session_has_no(key=nil, message=nil) #:nodoc:
|
30
|
-
msg = build_message(message, "<?> is in the session <?>", key, @response.session)
|
31
|
-
assert_block(msg) { !@response.has_session_object?(key) }
|
32
|
-
end
|
33
|
-
deprecate :assert_session_has_no => "use assert(!@response.has_session_object?(key))"
|
34
|
-
|
35
|
-
def assert_session_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
36
|
-
msg = build_message(message, "<?> expected in session['?'] but was <?>", expected, key, @response.session[key])
|
37
|
-
assert_block(msg) { expected == @response.session[key] }
|
38
|
-
end
|
39
|
-
deprecate :assert_session_equal => "use assert_equal(expected, @response[key])"
|
40
|
-
|
41
|
-
# -- cookie assertions ---------------------------------------------------
|
42
|
-
|
43
|
-
def assert_no_cookie(key = nil, message = nil) #:nodoc:
|
44
|
-
actual = @response.cookies[key]
|
45
|
-
msg = build_message(message, "<?> not expected in cookies['?']", actual, key)
|
46
|
-
assert_block(msg) { actual.nil? or actual.empty? }
|
47
|
-
end
|
48
|
-
deprecate :assert_no_cookie => "use assert(!@response.cookies.key?(key))"
|
49
|
-
|
50
|
-
def assert_cookie_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
51
|
-
actual = @response.cookies[key]
|
52
|
-
actual = actual.first if actual
|
53
|
-
msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, actual)
|
54
|
-
assert_block(msg) { expected == actual }
|
55
|
-
end
|
56
|
-
deprecate :assert_cookie_equal => "use assert(@response.cookies.key?(key))"
|
57
|
-
|
58
|
-
# -- flash assertions ---------------------------------------------------
|
59
|
-
|
60
|
-
# ensure that the flash has an object with the specified name
|
61
|
-
def assert_flash_has(key=nil, message=nil) #:nodoc:
|
62
|
-
msg = build_message(message, "<?> is not in the flash <?>", key, @response.flash)
|
63
|
-
assert_block(msg) { @response.has_flash_object?(key) }
|
64
|
-
end
|
65
|
-
deprecate :assert_flash_has => "use assert(@response.has_flash_object?(key))"
|
66
|
-
|
67
|
-
# ensure that the flash has no object with the specified name
|
68
|
-
def assert_flash_has_no(key=nil, message=nil) #:nodoc:
|
69
|
-
msg = build_message(message, "<?> is in the flash <?>", key, @response.flash)
|
70
|
-
assert_block(msg) { !@response.has_flash_object?(key) }
|
71
|
-
end
|
72
|
-
deprecate :assert_flash_has_no => "use assert(!@response.has_flash_object?(key))"
|
73
|
-
|
74
|
-
# ensure the flash exists
|
75
|
-
def assert_flash_exists(message=nil) #:nodoc:
|
76
|
-
msg = build_message(message, "the flash does not exist <?>", @response.session['flash'] )
|
77
|
-
assert_block(msg) { @response.has_flash? }
|
78
|
-
end
|
79
|
-
deprecate :assert_flash_exists => "use assert(@response.has_flash?)"
|
80
|
-
|
81
|
-
# ensure the flash does not exist
|
82
|
-
def assert_flash_not_exists(message=nil) #:nodoc:
|
83
|
-
msg = build_message(message, "the flash exists <?>", @response.flash)
|
84
|
-
assert_block(msg) { !@response.has_flash? }
|
85
|
-
end
|
86
|
-
deprecate :assert_flash_not_exists => "use assert(!@response.has_flash?)"
|
87
|
-
|
88
|
-
# ensure the flash is empty but existent
|
89
|
-
def assert_flash_empty(message=nil) #:nodoc:
|
90
|
-
msg = build_message(message, "the flash is not empty <?>", @response.flash)
|
91
|
-
assert_block(msg) { !@response.has_flash_with_contents? }
|
92
|
-
end
|
93
|
-
deprecate :assert_flash_empty => "use assert(!@response.has_flash_with_contents?)"
|
94
|
-
|
95
|
-
# ensure the flash is not empty
|
96
|
-
def assert_flash_not_empty(message=nil) #:nodoc:
|
97
|
-
msg = build_message(message, "the flash is empty")
|
98
|
-
assert_block(msg) { @response.has_flash_with_contents? }
|
99
|
-
end
|
100
|
-
deprecate :assert_flash_not_empty => "use assert(@response.has_flash_with_contents?)"
|
101
|
-
|
102
|
-
def assert_flash_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
103
|
-
msg = build_message(message, "<?> expected in flash['?'] but was <?>", expected, key, @response.flash[key])
|
104
|
-
assert_block(msg) { expected == @response.flash[key] }
|
105
|
-
end
|
106
|
-
deprecate :assert_flash_equal => "use assert_equal(expected, @response.flash[key])"
|
107
|
-
|
108
|
-
|
109
|
-
# ensure our redirection url is an exact match
|
110
|
-
def assert_redirect_url(url=nil, message=nil) #:nodoc:
|
111
|
-
assert_redirect(message)
|
112
|
-
msg = build_message(message, "<?> is not the redirected location <?>", url, @response.redirect_url)
|
113
|
-
assert_block(msg) { @response.redirect_url == url }
|
114
|
-
end
|
115
|
-
deprecate :assert_redirect_url => "use assert_equal(url, @response.redirect_url)"
|
116
|
-
|
117
|
-
# ensure our redirection url matches a pattern
|
118
|
-
def assert_redirect_url_match(pattern=nil, message=nil) #:nodoc:
|
119
|
-
assert_redirect(message)
|
120
|
-
msg = build_message(message, "<?> was not found in the location: <?>", pattern, @response.redirect_url)
|
121
|
-
assert_block(msg) { @response.redirect_url_match?(pattern) }
|
122
|
-
end
|
123
|
-
deprecate :assert_redirect_url_match => "use assert(@response.redirect_url_match?(pattern))"
|
124
|
-
|
125
|
-
|
126
|
-
# -- template assertions ------------------------------------------------
|
127
|
-
|
128
|
-
# ensure that a template object with the given name exists
|
129
|
-
def assert_template_has(key=nil, message=nil) #:nodoc:
|
130
|
-
msg = build_message(message, "<?> is not a template object", key )
|
131
|
-
assert_block(msg) { @response.has_template_object?(key) }
|
132
|
-
end
|
133
|
-
deprecate :assert_template_has => "use assert(@response.has_template_object?(key))"
|
134
|
-
|
135
|
-
# ensure that a template object with the given name does not exist
|
136
|
-
def assert_template_has_no(key=nil,message=nil) #:nodoc:
|
137
|
-
msg = build_message(message, "<?> is a template object <?>", key, @response.template_objects[key])
|
138
|
-
assert_block(msg) { !@response.has_template_object?(key) }
|
139
|
-
end
|
140
|
-
deprecate :assert_template_has_no => "use assert(!@response.has_template_object?(key))"
|
141
|
-
|
142
|
-
# ensures that the object assigned to the template on +key+ is equal to +expected+ object.
|
143
|
-
def assert_template_equal(expected = nil, key = nil, message = nil) #:nodoc:
|
144
|
-
msg = build_message(message, "<?> expected in assigns['?'] but was <?>", expected, key, @response.template.assigns[key.to_s])
|
145
|
-
assert_block(msg) { expected == @response.template.assigns[key.to_s] }
|
146
|
-
end
|
147
|
-
alias_method :assert_assigned_equal, :assert_template_equal
|
148
|
-
deprecate :assert_assigned_equal => "use assert_equal(expected, @response.template.assigns[key.to_s])"
|
149
|
-
deprecate :assert_template_equal => "use assert_equal(expected, @response.template.assigns[key.to_s])"
|
150
|
-
|
151
|
-
# Asserts that the template returns the +expected+ string or array based on the XPath +expression+.
|
152
|
-
# This will only work if the template rendered a valid XML document.
|
153
|
-
def assert_template_xpath_match(expression=nil, expected=nil, message=nil) #:nodoc:
|
154
|
-
xml, matches = REXML::Document.new(@response.body), []
|
155
|
-
xml.elements.each(expression) { |e| matches << e.text }
|
156
|
-
if matches.empty? then
|
157
|
-
msg = build_message(message, "<?> not found in document", expression)
|
158
|
-
flunk(msg)
|
159
|
-
return
|
160
|
-
elsif matches.length < 2 then
|
161
|
-
matches = matches.first
|
162
|
-
end
|
163
|
-
|
164
|
-
msg = build_message(message, "<?> found <?>, not <?>", expression, matches, expected)
|
165
|
-
assert_block(msg) { matches == expected }
|
166
|
-
end
|
167
|
-
deprecate :assert_template_xpath_match => "you should use assert_tag, instead"
|
168
|
-
|
169
|
-
# Assert the template object with the given name is an Active Record descendant and is valid.
|
170
|
-
def assert_valid_record(key = nil, message = nil) #:nodoc:
|
171
|
-
record = find_record_in_template(key)
|
172
|
-
msg = build_message(message, "Active Record is invalid <?>)", record.errors.full_messages)
|
173
|
-
assert_block(msg) { record.valid? }
|
174
|
-
end
|
175
|
-
deprecate :assert_valid_record => "use assert(assigns(key).valid?)"
|
176
|
-
|
177
|
-
# Assert the template object with the given name is an Active Record descendant and is invalid.
|
178
|
-
def assert_invalid_record(key = nil, message = nil) #:nodoc:
|
179
|
-
record = find_record_in_template(key)
|
180
|
-
msg = build_message(message, "Active Record is valid)")
|
181
|
-
assert_block(msg) { !record.valid? }
|
182
|
-
end
|
183
|
-
deprecate :assert_invalid_record => "use assert(!assigns(key).valid?)"
|
184
|
-
|
185
|
-
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are valid.
|
186
|
-
def assert_valid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
187
|
-
record = find_record_in_template(key)
|
188
|
-
record.send(:validate)
|
189
|
-
|
190
|
-
cols = glue_columns(columns)
|
191
|
-
cols.delete_if { |col| !record.errors.invalid?(col) }
|
192
|
-
msg = build_message(message, "Active Record has invalid columns <?>)", cols.join(",") )
|
193
|
-
assert_block(msg) { cols.empty? }
|
194
|
-
end
|
195
|
-
deprecate :assert_valid_column_on_record => "use assert(!record.errors.invalid?(column)) instead"
|
196
|
-
|
197
|
-
# Assert the template object with the given name is an Active Record descendant and the specified column(s) are invalid.
|
198
|
-
def assert_invalid_column_on_record(key = nil, columns = "", message = nil) #:nodoc:
|
199
|
-
record = find_record_in_template(key)
|
200
|
-
record.send(:validate)
|
201
|
-
|
202
|
-
cols = glue_columns(columns)
|
203
|
-
cols.delete_if { |col| record.errors.invalid?(col) }
|
204
|
-
msg = build_message(message, "Active Record has valid columns <?>)", cols.join(",") )
|
205
|
-
assert_block(msg) { cols.empty? }
|
206
|
-
end
|
207
|
-
deprecate :assert_invalid_column_on_record => "use assert(record.errors.invalid?(column)) instead"
|
208
|
-
|
209
|
-
private
|
210
|
-
def glue_columns(columns)
|
211
|
-
cols = []
|
212
|
-
cols << columns if columns.class == String
|
213
|
-
cols += columns if columns.class == Array
|
214
|
-
cols
|
215
|
-
end
|
216
|
-
|
217
|
-
def find_record_in_template(key = nil)
|
218
|
-
assert_not_nil assigns(key)
|
219
|
-
record = @response.template_objects[key]
|
220
|
-
|
221
|
-
assert_not_nil(record)
|
222
|
-
assert_kind_of ActiveRecord::Base, record
|
223
|
-
|
224
|
-
return record
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'cgi/session'
|
3
|
-
require 'cgi/session/pstore'
|
4
|
-
require 'action_controller/cgi_ext/cgi_methods'
|
5
|
-
|
6
|
-
# Wrapper around the CGIMethods that have been secluded to allow testing without
|
7
|
-
# an instantiated CGI object
|
8
|
-
class CGI #:nodoc:
|
9
|
-
class << self
|
10
|
-
alias :escapeHTML_fail_on_nil :escapeHTML
|
11
|
-
|
12
|
-
def escapeHTML(string)
|
13
|
-
escapeHTML_fail_on_nil(string) unless string.nil?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Returns a parameter hash including values from both the request (POST/GET)
|
18
|
-
# and the query string with the latter taking precedence.
|
19
|
-
def parameters
|
20
|
-
request_parameters.update(query_parameters)
|
21
|
-
end
|
22
|
-
|
23
|
-
def query_parameters
|
24
|
-
CGIMethods.parse_query_parameters(query_string)
|
25
|
-
end
|
26
|
-
|
27
|
-
def request_parameters
|
28
|
-
CGIMethods.parse_request_parameters(params, env_table)
|
29
|
-
end
|
30
|
-
|
31
|
-
def session(parameters = nil)
|
32
|
-
parameters = {} if parameters.nil?
|
33
|
-
parameters['database_manager'] = CGI::Session::PStore
|
34
|
-
CGI::Session.new(self, parameters)
|
35
|
-
end
|
36
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
require 'action_controller/vendor/xml_node'
|
3
|
-
require 'strscan'
|
4
|
-
|
5
|
-
# Static methods for parsing the query and request parameters that can be used in
|
6
|
-
# a CGI extension class or testing in isolation.
|
7
|
-
class CGIMethods #:nodoc:
|
8
|
-
class << self
|
9
|
-
# DEPRECATED: Use parse_form_encoded_parameters
|
10
|
-
def parse_query_parameters(query_string)
|
11
|
-
pairs = query_string.split('&').collect do |chunk|
|
12
|
-
next if chunk.empty?
|
13
|
-
key, value = chunk.split('=', 2)
|
14
|
-
next if key.empty?
|
15
|
-
value = (value.nil? || value.empty?) ? nil : CGI.unescape(value)
|
16
|
-
[ CGI.unescape(key), value ]
|
17
|
-
end.compact
|
18
|
-
|
19
|
-
FormEncodedPairParser.new(pairs).result
|
20
|
-
end
|
21
|
-
|
22
|
-
# DEPRECATED: Use parse_form_encoded_parameters
|
23
|
-
def parse_request_parameters(params)
|
24
|
-
parser = FormEncodedPairParser.new
|
25
|
-
|
26
|
-
params = params.dup
|
27
|
-
until params.empty?
|
28
|
-
for key, value in params
|
29
|
-
if key.blank?
|
30
|
-
params.delete key
|
31
|
-
elsif !key.include?('[')
|
32
|
-
# much faster to test for the most common case first (GET)
|
33
|
-
# and avoid the call to build_deep_hash
|
34
|
-
parser.result[key] = get_typed_value(value[0])
|
35
|
-
params.delete key
|
36
|
-
elsif value.is_a?(Array)
|
37
|
-
parser.parse(key, get_typed_value(value.shift))
|
38
|
-
params.delete key if value.empty?
|
39
|
-
else
|
40
|
-
raise TypeError, "Expected array, found #{value.inspect}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
parser.result
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse_formatted_request_parameters(mime_type, raw_post_data)
|
49
|
-
case strategy = ActionController::Base.param_parsers[mime_type]
|
50
|
-
when Proc
|
51
|
-
strategy.call(raw_post_data)
|
52
|
-
when :xml_simple
|
53
|
-
raw_post_data.blank? ? {} : Hash.from_xml(raw_post_data)
|
54
|
-
when :yaml
|
55
|
-
YAML.load(raw_post_data)
|
56
|
-
when :xml_node
|
57
|
-
node = XmlNode.from_xml(raw_post_data)
|
58
|
-
{ node.node_name => node }
|
59
|
-
end
|
60
|
-
rescue Exception => e # YAML, XML or Ruby code block errors
|
61
|
-
{ "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace,
|
62
|
-
"raw_post_data" => raw_post_data, "format" => mime_type }
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
def get_typed_value(value)
|
67
|
-
case value
|
68
|
-
when String
|
69
|
-
value
|
70
|
-
when NilClass
|
71
|
-
''
|
72
|
-
when Array
|
73
|
-
value.map { |v| get_typed_value(v) }
|
74
|
-
else
|
75
|
-
# Uploaded file provides content type and filename.
|
76
|
-
if value.respond_to?(:content_type) &&
|
77
|
-
!value.content_type.blank? &&
|
78
|
-
!value.original_filename.blank?
|
79
|
-
unless value.respond_to?(:full_original_filename)
|
80
|
-
class << value
|
81
|
-
alias_method :full_original_filename, :original_filename
|
82
|
-
|
83
|
-
# Take the basename of the upload's original filename.
|
84
|
-
# This handles the full Windows paths given by Internet Explorer
|
85
|
-
# (and perhaps other broken user agents) without affecting
|
86
|
-
# those which give the lone filename.
|
87
|
-
# The Windows regexp is adapted from Perl's File::Basename.
|
88
|
-
def original_filename
|
89
|
-
if md = /^(?:.*[:\\\/])?(.*)/m.match(full_original_filename)
|
90
|
-
md.captures.first
|
91
|
-
else
|
92
|
-
File.basename full_original_filename
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Return the same value after overriding original_filename.
|
99
|
-
value
|
100
|
-
|
101
|
-
# Multipart values may have content type, but no filename.
|
102
|
-
elsif value.respond_to?(:read)
|
103
|
-
result = value.read
|
104
|
-
value.rewind
|
105
|
-
result
|
106
|
-
|
107
|
-
# Unknown value, neither string nor multipart.
|
108
|
-
else
|
109
|
-
raise "Unknown form value: #{value.inspect}"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
class FormEncodedPairParser < StringScanner #:nodoc:
|
116
|
-
attr_reader :top, :parent, :result
|
117
|
-
|
118
|
-
def initialize(pairs = [])
|
119
|
-
super('')
|
120
|
-
@result = {}
|
121
|
-
pairs.each { |key, value| parse(key, value) }
|
122
|
-
end
|
123
|
-
|
124
|
-
KEY_REGEXP = %r{([^\[\]=&]+)}
|
125
|
-
BRACKETED_KEY_REGEXP = %r{\[([^\[\]=&]+)\]}
|
126
|
-
|
127
|
-
# Parse the query string
|
128
|
-
def parse(key, value)
|
129
|
-
self.string = key
|
130
|
-
@top, @parent = result, nil
|
131
|
-
|
132
|
-
# First scan the bare key
|
133
|
-
key = scan(KEY_REGEXP) or return
|
134
|
-
key = post_key_check(key)
|
135
|
-
|
136
|
-
# Then scan as many nestings as present
|
137
|
-
until eos?
|
138
|
-
r = scan(BRACKETED_KEY_REGEXP) or return
|
139
|
-
key = self[1]
|
140
|
-
key = post_key_check(key)
|
141
|
-
end
|
142
|
-
|
143
|
-
bind(key, value)
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
# After we see a key, we must look ahead to determine our next action. Cases:
|
148
|
-
#
|
149
|
-
# [] follows the key. Then the value must be an array.
|
150
|
-
# = follows the key. (A value comes next)
|
151
|
-
# & or the end of string follows the key. Then the key is a flag.
|
152
|
-
# otherwise, a hash follows the key.
|
153
|
-
def post_key_check(key)
|
154
|
-
if scan(/\[\]/) # a[b][] indicates that b is an array
|
155
|
-
container(key, Array)
|
156
|
-
nil
|
157
|
-
elsif check(/\[[^\]]/) # a[b] indicates that a is a hash
|
158
|
-
container(key, Hash)
|
159
|
-
nil
|
160
|
-
else # End of key? We do nothing.
|
161
|
-
key
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
# Add a container to the stack.
|
166
|
-
#
|
167
|
-
def container(key, klass)
|
168
|
-
type_conflict! klass, top[key] if top.is_a?(Hash) && top.key?(key) && ! top[key].is_a?(klass)
|
169
|
-
value = bind(key, klass.new)
|
170
|
-
type_conflict! klass, value unless value.is_a?(klass)
|
171
|
-
push(value)
|
172
|
-
end
|
173
|
-
|
174
|
-
# Push a value onto the 'stack', which is actually only the top 2 items.
|
175
|
-
def push(value)
|
176
|
-
@parent, @top = @top, value
|
177
|
-
end
|
178
|
-
|
179
|
-
# Bind a key (which may be nil for items in an array) to the provided value.
|
180
|
-
def bind(key, value)
|
181
|
-
if top.is_a? Array
|
182
|
-
if key
|
183
|
-
if top[-1].is_a?(Hash) && ! top[-1].key?(key)
|
184
|
-
top[-1][key] = value
|
185
|
-
else
|
186
|
-
top << {key => value}.with_indifferent_access
|
187
|
-
push top.last
|
188
|
-
end
|
189
|
-
else
|
190
|
-
top << value
|
191
|
-
end
|
192
|
-
elsif top.is_a? Hash
|
193
|
-
key = CGI.unescape(key)
|
194
|
-
parent << (@top = {}) if top.key?(key) && parent.is_a?(Array)
|
195
|
-
return top[key] ||= value
|
196
|
-
else
|
197
|
-
raise ArgumentError, "Don't know what to do: top is #{top.inspect}"
|
198
|
-
end
|
199
|
-
|
200
|
-
return value
|
201
|
-
end
|
202
|
-
|
203
|
-
def type_conflict!(klass, value)
|
204
|
-
raise TypeError,
|
205
|
-
"Conflicting types for parameter containers. " +
|
206
|
-
"Expected an instance of #{klass}, but found an instance of #{value.class}. " +
|
207
|
-
"This can be caused by passing Array and Hash based paramters qs[]=value&qs[key]=value. "
|
208
|
-
end
|
209
|
-
|
210
|
-
end
|
211
|
-
end
|