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
@@ -7,10 +7,10 @@ class ActionPackAssertionsController < ActionController::Base
|
|
7
7
|
def nothing() head :ok end
|
8
8
|
|
9
9
|
# a standard template
|
10
|
-
def hello_world() render "test/hello_world"; end
|
10
|
+
def hello_world() render :template => "test/hello_world"; end
|
11
11
|
|
12
12
|
# a standard template
|
13
|
-
def hello_xml_world() render "test/hello_xml_world"; end
|
13
|
+
def hello_xml_world() render :template => "test/hello_xml_world"; end
|
14
14
|
|
15
15
|
# a redirect to an internal location
|
16
16
|
def redirect_internal() redirect_to "/nothing"; end
|
@@ -26,7 +26,7 @@ class ActionPackAssertionsController < ActionController::Base
|
|
26
26
|
def redirect_to_named_route() redirect_to route_one_url end
|
27
27
|
|
28
28
|
# a redirect to an external location
|
29
|
-
def redirect_external()
|
29
|
+
def redirect_external() redirect_to "http://www.rubyonrails.org"; end
|
30
30
|
|
31
31
|
# a 404
|
32
32
|
def response404() head '404 AWOL' end
|
@@ -40,13 +40,13 @@ class ActionPackAssertionsController < ActionController::Base
|
|
40
40
|
# putting stuff in the flash
|
41
41
|
def flash_me
|
42
42
|
flash['hello'] = 'my name is inigo montoya...'
|
43
|
-
|
43
|
+
render :text => "Inconceivable!"
|
44
44
|
end
|
45
45
|
|
46
46
|
# we have a flash, but nothing is in it
|
47
47
|
def flash_me_naked
|
48
48
|
flash.clear
|
49
|
-
|
49
|
+
render :text => "wow!"
|
50
50
|
end
|
51
51
|
|
52
52
|
# assign some template instance variables
|
@@ -56,11 +56,11 @@ class ActionPackAssertionsController < ActionController::Base
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def render_based_on_parameters
|
59
|
-
|
59
|
+
render :text => "Mr. #{params[:name]}"
|
60
60
|
end
|
61
61
|
|
62
62
|
def render_url
|
63
|
-
|
63
|
+
render :text => "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>"
|
64
64
|
end
|
65
65
|
|
66
66
|
def render_text_with_custom_content_type
|
@@ -70,19 +70,19 @@ class ActionPackAssertionsController < ActionController::Base
|
|
70
70
|
# puts something in the session
|
71
71
|
def session_stuffing
|
72
72
|
session['xmas'] = 'turkey'
|
73
|
-
|
73
|
+
render :text => "ho ho ho"
|
74
74
|
end
|
75
75
|
|
76
76
|
# raises exception on get requests
|
77
77
|
def raise_on_get
|
78
78
|
raise "get" if request.get?
|
79
|
-
|
79
|
+
render :text => "request method: #{request.env['REQUEST_METHOD']}"
|
80
80
|
end
|
81
81
|
|
82
82
|
# raises exception on post requests
|
83
83
|
def raise_on_post
|
84
84
|
raise "post" if request.post?
|
85
|
-
|
85
|
+
render :text => "request method: #{request.env['REQUEST_METHOD']}"
|
86
86
|
end
|
87
87
|
|
88
88
|
def get_valid_record
|
@@ -141,7 +141,7 @@ module Admin
|
|
141
141
|
def redirect_to_fellow_controller
|
142
142
|
redirect_to :controller => 'user'
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
def redirect_to_top_level_named_route
|
146
146
|
redirect_to top_level_url(:id => "foo")
|
147
147
|
end
|
@@ -154,8 +154,7 @@ end
|
|
154
154
|
# tell the controller where to find its templates but start from parent
|
155
155
|
# directory of test_request_response to simulate the behaviour of a
|
156
156
|
# production environment
|
157
|
-
ActionPackAssertionsController.
|
158
|
-
|
157
|
+
ActionPackAssertionsController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
159
158
|
|
160
159
|
# a test case to exercise the new capabilities TestRequest & TestResponse
|
161
160
|
class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
@@ -178,13 +177,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
178
177
|
assert_tag :content => "/action_pack_assertions/flash_me"
|
179
178
|
end
|
180
179
|
|
181
|
-
# test the session assertion to make sure something is there.
|
182
|
-
def test_assert_session_has
|
183
|
-
process :session_stuffing
|
184
|
-
assert_deprecated_assertion { assert_session_has 'xmas' }
|
185
|
-
assert_deprecated_assertion { assert_session_has_no 'halloween' }
|
186
|
-
end
|
187
|
-
|
188
180
|
# test the get method, make sure the request really was a get
|
189
181
|
def test_get
|
190
182
|
assert_raise(RuntimeError) { get :raise_on_get }
|
@@ -212,49 +204,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
212
204
|
# assert_equal @response.body, 'request method: GET'
|
213
205
|
# end
|
214
206
|
|
215
|
-
# test the assertion of goodies in the template
|
216
|
-
def test_assert_template_has
|
217
|
-
process :assign_this
|
218
|
-
assert_deprecated_assertion { assert_template_has 'howdy' }
|
219
|
-
end
|
220
|
-
|
221
|
-
# test the assertion for goodies that shouldn't exist in the template
|
222
|
-
def test_assert_template_has_no
|
223
|
-
process :nothing
|
224
|
-
assert_deprecated_assertion { assert_template_has_no 'maple syrup' }
|
225
|
-
assert_deprecated_assertion { assert_template_has_no 'howdy' }
|
226
|
-
end
|
227
|
-
|
228
|
-
# test the redirection assertions
|
229
|
-
def test_assert_redirect
|
230
|
-
process :redirect_internal
|
231
|
-
assert_deprecated_assertion { assert_redirect }
|
232
|
-
end
|
233
|
-
|
234
|
-
# test the redirect url string
|
235
|
-
def test_assert_redirect_url
|
236
|
-
process :redirect_external
|
237
|
-
assert_deprecated_assertion do
|
238
|
-
assert_redirect_url 'http://www.rubyonrails.org'
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
# test the redirection pattern matching on a string
|
243
|
-
def test_assert_redirect_url_match_string
|
244
|
-
process :redirect_external
|
245
|
-
assert_deprecated_assertion do
|
246
|
-
assert_redirect_url_match 'rails.org'
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
# test the redirection pattern matching on a pattern
|
251
|
-
def test_assert_redirect_url_match_pattern
|
252
|
-
process :redirect_external
|
253
|
-
assert_deprecated_assertion do
|
254
|
-
assert_redirect_url_match /ruby/
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
207
|
# test the redirection to a named route
|
259
208
|
def test_assert_redirect_to_named_route
|
260
209
|
with_routing do |set|
|
@@ -262,7 +211,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
262
211
|
map.route_one 'route_one', :controller => 'action_pack_assertions', :action => 'nothing'
|
263
212
|
map.connect ':controller/:action/:id'
|
264
213
|
end
|
265
|
-
set.
|
214
|
+
set.install_helpers
|
266
215
|
|
267
216
|
process :redirect_to_named_route
|
268
217
|
assert_redirected_to 'http://test.host/route_one'
|
@@ -306,7 +255,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
306
255
|
assert_redirected_to admin_inner_module_path
|
307
256
|
end
|
308
257
|
end
|
309
|
-
|
258
|
+
|
310
259
|
def test_assert_redirected_to_top_level_named_route_from_nested_controller
|
311
260
|
with_routing do |set|
|
312
261
|
set.draw do |map|
|
@@ -320,47 +269,8 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
320
269
|
end
|
321
270
|
end
|
322
271
|
|
323
|
-
# test the flash-based assertions with something is in the flash
|
324
|
-
def test_flash_assertions_full
|
325
|
-
process :flash_me
|
326
|
-
assert @response.has_flash_with_contents?
|
327
|
-
assert_deprecated_assertion { assert_flash_exists }
|
328
|
-
assert_deprecated_assertion { assert_flash_not_empty }
|
329
|
-
assert_deprecated_assertion { assert_flash_has 'hello' }
|
330
|
-
assert_deprecated_assertion { assert_flash_has_no 'stds' }
|
331
|
-
end
|
332
|
-
|
333
|
-
# test the flash-based assertions with no flash at all
|
334
|
-
def test_flash_assertions_negative
|
335
|
-
process :nothing
|
336
|
-
assert_deprecated_assertion { assert_flash_empty }
|
337
|
-
assert_deprecated_assertion { assert_flash_has_no 'hello' }
|
338
|
-
assert_deprecated_assertion { assert_flash_has_no 'qwerty' }
|
339
|
-
end
|
340
|
-
|
341
|
-
# test the assert_rendered_file
|
342
|
-
def test_assert_rendered_file
|
343
|
-
assert_deprecated(/render/) { process :hello_world }
|
344
|
-
assert_deprecated_assertion { assert_rendered_file 'test/hello_world' }
|
345
|
-
assert_deprecated_assertion { assert_rendered_file 'hello_world' }
|
346
|
-
end
|
347
|
-
|
348
|
-
# test the assert_success assertion
|
349
|
-
def test_assert_success
|
350
|
-
process :nothing
|
351
|
-
assert_deprecated_assertion { assert_success }
|
352
|
-
end
|
353
|
-
|
354
272
|
# -- standard request/response object testing --------------------------------
|
355
273
|
|
356
|
-
# ensure our session is working properly
|
357
|
-
def test_session_objects
|
358
|
-
process :session_stuffing
|
359
|
-
assert @response.has_session_object?('xmas')
|
360
|
-
assert_deprecated_assertion { assert_session_equal 'turkey', 'xmas' }
|
361
|
-
assert !@response.has_session_object?('easter')
|
362
|
-
end
|
363
|
-
|
364
274
|
# make sure that the template objects exist
|
365
275
|
def test_template_objects_alive
|
366
276
|
process :assign_this
|
@@ -374,11 +284,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
374
284
|
assert_nil @response.template_objects['howdy']
|
375
285
|
end
|
376
286
|
|
377
|
-
def test_assigned_equal
|
378
|
-
process :assign_this
|
379
|
-
assert_deprecated_assertion { assert_assigned_equal "ho", :howdy }
|
380
|
-
end
|
381
|
-
|
382
287
|
# check the empty flashing
|
383
288
|
def test_flash_me_naked
|
384
289
|
process :flash_me_naked
|
@@ -402,20 +307,12 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
402
307
|
assert_nil @response.flash['hello']
|
403
308
|
end
|
404
309
|
|
405
|
-
# examine that the flash objects are what we expect
|
406
|
-
def test_flash_equals
|
407
|
-
process :flash_me
|
408
|
-
assert_deprecated_assertion do
|
409
|
-
assert_flash_equal 'my name is inigo montoya...', 'hello'
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
310
|
# check if we were rendered by a file-based template?
|
414
311
|
def test_rendered_action
|
415
312
|
process :nothing
|
416
313
|
assert !@response.rendered_with_file?
|
417
314
|
|
418
|
-
|
315
|
+
process :hello_world
|
419
316
|
assert @response.rendered_with_file?
|
420
317
|
assert 'hello_world', @response.rendered_file
|
421
318
|
end
|
@@ -492,29 +389,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
492
389
|
assert_equal "Mr. David", @response.body
|
493
390
|
end
|
494
391
|
|
495
|
-
def test_assert_template_xpath_match_no_matches
|
496
|
-
assert_deprecated(/render/) { process :hello_xml_world }
|
497
|
-
assert_raises Test::Unit::AssertionFailedError do
|
498
|
-
assert_deprecated_assertion do
|
499
|
-
assert_template_xpath_match('/no/such/node/in/document')
|
500
|
-
end
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
def test_simple_one_element_xpath_match
|
505
|
-
assert_deprecated(/render/) { process :hello_xml_world }
|
506
|
-
assert_deprecated_assertion do
|
507
|
-
assert_template_xpath_match('//title', "Hello World")
|
508
|
-
end
|
509
|
-
end
|
510
|
-
|
511
|
-
def test_array_of_elements_in_xpath_match
|
512
|
-
assert_deprecated(/render/) { process :hello_xml_world }
|
513
|
-
assert_deprecated_assertion do
|
514
|
-
assert_template_xpath_match('//p', %w( abes monks wiseguys ))
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
392
|
def test_follow_redirect
|
519
393
|
process :redirect_to_action
|
520
394
|
assert_redirected_to :action => "flash_me"
|
@@ -591,11 +465,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
591
465
|
rescue Test::Unit::AssertionFailedError => e
|
592
466
|
end
|
593
467
|
end
|
594
|
-
|
595
|
-
protected
|
596
|
-
def assert_deprecated_assertion(&block)
|
597
|
-
assert_deprecated(/assert/, &block)
|
598
|
-
end
|
599
468
|
end
|
600
469
|
|
601
470
|
class ActionPackHeaderTest < Test::Unit::TestCase
|
@@ -605,19 +474,19 @@ class ActionPackHeaderTest < Test::Unit::TestCase
|
|
605
474
|
end
|
606
475
|
|
607
476
|
def test_rendering_xml_sets_content_type
|
608
|
-
|
609
|
-
assert_equal('application/xml; charset=utf-8', @
|
477
|
+
process :hello_xml_world
|
478
|
+
assert_equal('application/xml; charset=utf-8', @response.headers['type'])
|
610
479
|
end
|
611
480
|
|
612
481
|
def test_rendering_xml_respects_content_type
|
613
|
-
@response.headers['
|
614
|
-
|
615
|
-
assert_equal('application/pdf; charset=utf-8', @
|
482
|
+
@response.headers['type'] = 'application/pdf'
|
483
|
+
process :hello_xml_world
|
484
|
+
assert_equal('application/pdf; charset=utf-8', @response.headers['type'])
|
616
485
|
end
|
617
486
|
|
618
487
|
|
619
488
|
def test_render_text_with_custom_content_type
|
620
489
|
get :render_text_with_custom_content_type
|
621
|
-
assert_equal 'application/rss+xml; charset=utf-8', @response.headers['
|
490
|
+
assert_equal 'application/rss+xml; charset=utf-8', @response.headers['type']
|
622
491
|
end
|
623
492
|
end
|
@@ -16,13 +16,11 @@ class Address
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class AddressesTestController < ActionController::Base
|
19
|
-
scaffold :address
|
20
|
-
|
21
19
|
def self.controller_name; "addresses"; end
|
22
20
|
def self.controller_path; "addresses"; end
|
23
21
|
end
|
24
22
|
|
25
|
-
AddressesTestController.
|
23
|
+
AddressesTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
26
24
|
|
27
25
|
class AddressesTest < Test::Unit::TestCase
|
28
26
|
def setup
|
@@ -39,10 +37,7 @@ class AddressesTest < Test::Unit::TestCase
|
|
39
37
|
end
|
40
38
|
|
41
39
|
def test_list
|
42
|
-
|
43
|
-
ActiveSupport::Deprecation.silence do
|
44
|
-
get :list
|
45
|
-
end
|
40
|
+
get :list
|
46
41
|
assert_equal "We only need to get this far!", @response.body.chomp
|
47
42
|
end
|
48
43
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Under MIT and/or CC By license.
|
4
4
|
#++
|
5
5
|
|
6
|
-
require File.dirname(__FILE__)
|
7
|
-
require File.dirname(__FILE__)
|
6
|
+
require "#{File.dirname(__FILE__)}/../abstract_unit"
|
7
|
+
require "#{File.dirname(__FILE__)}/fake_controllers"
|
8
8
|
|
9
9
|
|
10
10
|
unless defined?(ActionMailer)
|
@@ -73,7 +73,12 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
73
73
|
def teardown
|
74
74
|
ActionMailer::Base.deliveries.clear
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
|
+
def assert_failure(message, &block)
|
78
|
+
e = assert_raises(AssertionFailedError, &block)
|
79
|
+
assert_match(message, e.message) if Regexp === message
|
80
|
+
assert_equal(message, e.message) if String === message
|
81
|
+
end
|
77
82
|
|
78
83
|
#
|
79
84
|
# Test assert select.
|
@@ -82,8 +87,8 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
82
87
|
def test_assert_select
|
83
88
|
render_html %Q{<div id="1"></div><div id="2"></div>}
|
84
89
|
assert_select "div", 2
|
85
|
-
|
86
|
-
|
90
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) { assert_select "div", 3 }
|
91
|
+
assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" }
|
87
92
|
end
|
88
93
|
|
89
94
|
|
@@ -131,22 +136,34 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
131
136
|
end
|
132
137
|
|
133
138
|
|
134
|
-
def
|
139
|
+
def test_counts
|
135
140
|
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
136
141
|
assert_nothing_raised { assert_select "div", 2 }
|
137
|
-
|
142
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
143
|
+
assert_select "div", 3
|
144
|
+
end
|
138
145
|
assert_nothing_raised { assert_select "div", 1..2 }
|
139
|
-
|
146
|
+
assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do
|
147
|
+
assert_select "div", 3..4
|
148
|
+
end
|
140
149
|
assert_nothing_raised { assert_select "div", :count=>2 }
|
141
|
-
|
150
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
151
|
+
assert_select "div", :count=>3
|
152
|
+
end
|
142
153
|
assert_nothing_raised { assert_select "div", :minimum=>1 }
|
143
154
|
assert_nothing_raised { assert_select "div", :minimum=>2 }
|
144
|
-
|
155
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
156
|
+
assert_select "div", :minimum=>3
|
157
|
+
end
|
145
158
|
assert_nothing_raised { assert_select "div", :maximum=>2 }
|
146
159
|
assert_nothing_raised { assert_select "div", :maximum=>3 }
|
147
|
-
|
160
|
+
assert_failure(/Expected at most 1 element matching \"div\", found 2/) do
|
161
|
+
assert_select "div", :maximum=>1
|
162
|
+
end
|
148
163
|
assert_nothing_raised { assert_select "div", :minimum=>1, :maximum=>2 }
|
149
|
-
|
164
|
+
assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do
|
165
|
+
assert_select "div", :minimum=>3, :maximum=>4
|
166
|
+
end
|
150
167
|
end
|
151
168
|
|
152
169
|
|
@@ -183,6 +200,12 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
183
200
|
assert_select "#3", false
|
184
201
|
end
|
185
202
|
end
|
203
|
+
|
204
|
+
assert_failure(/Expected at least 1 element matching \"#4\", found 0\./) do
|
205
|
+
assert_select "div" do
|
206
|
+
assert_select "#4"
|
207
|
+
end
|
208
|
+
end
|
186
209
|
end
|
187
210
|
|
188
211
|
|
@@ -408,6 +431,90 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
408
431
|
assert_raises(AssertionFailedError) { assert_select_rjs :replace_html, "test1" }
|
409
432
|
end
|
410
433
|
|
434
|
+
# Simple remove
|
435
|
+
def test_assert_select_rjs_for_remove
|
436
|
+
render_rjs do |page|
|
437
|
+
page.remove "test1"
|
438
|
+
end
|
439
|
+
|
440
|
+
assert_select_rjs :remove, "test1"
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_assert_select_rjs_for_remove_ignores_block
|
444
|
+
render_rjs do |page|
|
445
|
+
page.remove "test1"
|
446
|
+
end
|
447
|
+
|
448
|
+
assert_nothing_raised do
|
449
|
+
assert_select_rjs :remove, "test1" do
|
450
|
+
assert_select "p"
|
451
|
+
end
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
# Simple show
|
456
|
+
def test_assert_select_rjs_for_show
|
457
|
+
render_rjs do |page|
|
458
|
+
page.show "test1"
|
459
|
+
end
|
460
|
+
|
461
|
+
assert_select_rjs :show, "test1"
|
462
|
+
end
|
463
|
+
|
464
|
+
def test_assert_select_rjs_for_show_ignores_block
|
465
|
+
render_rjs do |page|
|
466
|
+
page.show "test1"
|
467
|
+
end
|
468
|
+
|
469
|
+
assert_nothing_raised do
|
470
|
+
assert_select_rjs :show, "test1" do
|
471
|
+
assert_select "p"
|
472
|
+
end
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
# Simple hide
|
477
|
+
def test_assert_select_rjs_for_hide
|
478
|
+
render_rjs do |page|
|
479
|
+
page.hide "test1"
|
480
|
+
end
|
481
|
+
|
482
|
+
assert_select_rjs :hide, "test1"
|
483
|
+
end
|
484
|
+
|
485
|
+
def test_assert_select_rjs_for_hide_ignores_block
|
486
|
+
render_rjs do |page|
|
487
|
+
page.hide "test1"
|
488
|
+
end
|
489
|
+
|
490
|
+
assert_nothing_raised do
|
491
|
+
assert_select_rjs :hide, "test1" do
|
492
|
+
assert_select "p"
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
# Simple toggle
|
498
|
+
def test_assert_select_rjs_for_toggle
|
499
|
+
render_rjs do |page|
|
500
|
+
page.toggle "test1"
|
501
|
+
end
|
502
|
+
|
503
|
+
assert_select_rjs :toggle, "test1"
|
504
|
+
end
|
505
|
+
|
506
|
+
def test_assert_select_rjs_for_toggle_ignores_block
|
507
|
+
render_rjs do |page|
|
508
|
+
page.toggle "test1"
|
509
|
+
end
|
510
|
+
|
511
|
+
assert_nothing_raised do
|
512
|
+
assert_select_rjs :toggle, "test1" do
|
513
|
+
assert_select "p"
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
411
518
|
# Non-positioned insert.
|
412
519
|
def test_assert_select_rjs_for_nonpositioned_insert
|
413
520
|
render_rjs do |page|
|
@@ -454,8 +561,7 @@ class AssertSelectTest < Test::Unit::TestCase
|
|
454
561
|
assert_select "div", 4
|
455
562
|
end
|
456
563
|
end
|
457
|
-
|
458
|
-
|
564
|
+
|
459
565
|
# Simple selection from a single result.
|
460
566
|
def test_nested_assert_select_rjs_with_single_result
|
461
567
|
render_rjs do |page|
|