actionpack-2.3.17-rack-upgrade 2.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5250 -0
- data/MIT-LICENSE +21 -0
- data/README +409 -0
- data/RUNNING_UNIT_TESTS +24 -0
- data/Rakefile +158 -0
- data/install.rb +30 -0
- data/lib/action_controller.rb +113 -0
- data/lib/action_controller/assertions/dom_assertions.rb +55 -0
- data/lib/action_controller/assertions/model_assertions.rb +21 -0
- data/lib/action_controller/assertions/response_assertions.rb +169 -0
- data/lib/action_controller/assertions/routing_assertions.rb +146 -0
- data/lib/action_controller/assertions/selector_assertions.rb +638 -0
- data/lib/action_controller/assertions/tag_assertions.rb +127 -0
- data/lib/action_controller/base.rb +1425 -0
- data/lib/action_controller/benchmarking.rb +107 -0
- data/lib/action_controller/caching.rb +71 -0
- data/lib/action_controller/caching/actions.rb +177 -0
- data/lib/action_controller/caching/fragments.rb +120 -0
- data/lib/action_controller/caching/pages.rb +152 -0
- data/lib/action_controller/caching/sweeper.rb +45 -0
- data/lib/action_controller/caching/sweeping.rb +55 -0
- data/lib/action_controller/cgi_ext.rb +15 -0
- data/lib/action_controller/cgi_ext/cookie.rb +112 -0
- data/lib/action_controller/cgi_ext/query_extension.rb +22 -0
- data/lib/action_controller/cgi_ext/stdinput.rb +24 -0
- data/lib/action_controller/cgi_process.rb +77 -0
- data/lib/action_controller/cookies.rb +197 -0
- data/lib/action_controller/dispatcher.rb +133 -0
- data/lib/action_controller/failsafe.rb +87 -0
- data/lib/action_controller/filters.rb +680 -0
- data/lib/action_controller/flash.rb +213 -0
- data/lib/action_controller/headers.rb +33 -0
- data/lib/action_controller/helpers.rb +225 -0
- data/lib/action_controller/http_authentication.rb +309 -0
- data/lib/action_controller/integration.rb +708 -0
- data/lib/action_controller/layout.rb +286 -0
- data/lib/action_controller/middleware_stack.rb +119 -0
- data/lib/action_controller/middlewares.rb +14 -0
- data/lib/action_controller/mime_responds.rb +193 -0
- data/lib/action_controller/mime_type.rb +212 -0
- data/lib/action_controller/mime_types.rb +21 -0
- data/lib/action_controller/params_parser.rb +77 -0
- data/lib/action_controller/performance_test.rb +15 -0
- data/lib/action_controller/polymorphic_routes.rb +189 -0
- data/lib/action_controller/rack_lint_patch.rb +36 -0
- data/lib/action_controller/record_identifier.rb +104 -0
- data/lib/action_controller/reloader.rb +54 -0
- data/lib/action_controller/request.rb +518 -0
- data/lib/action_controller/request_forgery_protection.rb +116 -0
- data/lib/action_controller/rescue.rb +183 -0
- data/lib/action_controller/resources.rb +682 -0
- data/lib/action_controller/response.rb +237 -0
- data/lib/action_controller/routing.rb +388 -0
- data/lib/action_controller/routing/builder.rb +197 -0
- data/lib/action_controller/routing/optimisations.rb +130 -0
- data/lib/action_controller/routing/recognition_optimisation.rb +167 -0
- data/lib/action_controller/routing/route.rb +265 -0
- data/lib/action_controller/routing/route_set.rb +503 -0
- data/lib/action_controller/routing/routing_ext.rb +49 -0
- data/lib/action_controller/routing/segments.rb +343 -0
- data/lib/action_controller/session/abstract_store.rb +276 -0
- data/lib/action_controller/session/cookie_store.rb +240 -0
- data/lib/action_controller/session/mem_cache_store.rb +60 -0
- data/lib/action_controller/session_management.rb +54 -0
- data/lib/action_controller/status_codes.rb +88 -0
- data/lib/action_controller/streaming.rb +181 -0
- data/lib/action_controller/string_coercion.rb +29 -0
- data/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
- data/lib/action_controller/templates/rescues/_trace.erb +26 -0
- data/lib/action_controller/templates/rescues/diagnostics.erb +11 -0
- data/lib/action_controller/templates/rescues/layout.erb +29 -0
- data/lib/action_controller/templates/rescues/missing_template.erb +2 -0
- data/lib/action_controller/templates/rescues/routing_error.erb +10 -0
- data/lib/action_controller/templates/rescues/template_error.erb +21 -0
- data/lib/action_controller/templates/rescues/unknown_action.erb +2 -0
- data/lib/action_controller/test_case.rb +209 -0
- data/lib/action_controller/test_process.rb +580 -0
- data/lib/action_controller/translation.rb +13 -0
- data/lib/action_controller/uploaded_file.rb +44 -0
- data/lib/action_controller/url_rewriter.rb +229 -0
- data/lib/action_controller/vendor/html-scanner.rb +16 -0
- data/lib/action_controller/vendor/html-scanner/html/document.rb +68 -0
- data/lib/action_controller/vendor/html-scanner/html/node.rb +537 -0
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +828 -0
- data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
- data/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
- data/lib/action_controller/verification.rb +130 -0
- data/lib/action_pack.rb +24 -0
- data/lib/action_pack/version.rb +9 -0
- data/lib/action_view.rb +58 -0
- data/lib/action_view/base.rb +362 -0
- data/lib/action_view/helpers.rb +61 -0
- data/lib/action_view/helpers/active_record_helper.rb +305 -0
- data/lib/action_view/helpers/asset_tag_helper.rb +695 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +198 -0
- data/lib/action_view/helpers/benchmark_helper.rb +54 -0
- data/lib/action_view/helpers/cache_helper.rb +39 -0
- data/lib/action_view/helpers/capture_helper.rb +136 -0
- data/lib/action_view/helpers/csrf_helper.rb +14 -0
- data/lib/action_view/helpers/date_helper.rb +989 -0
- data/lib/action_view/helpers/debug_helper.rb +38 -0
- data/lib/action_view/helpers/form_helper.rb +1118 -0
- data/lib/action_view/helpers/form_options_helper.rb +599 -0
- data/lib/action_view/helpers/form_tag_helper.rb +490 -0
- data/lib/action_view/helpers/javascript_helper.rb +208 -0
- data/lib/action_view/helpers/number_helper.rb +308 -0
- data/lib/action_view/helpers/prototype_helper.rb +1305 -0
- data/lib/action_view/helpers/raw_output_helper.rb +9 -0
- data/lib/action_view/helpers/record_identification_helper.rb +20 -0
- data/lib/action_view/helpers/record_tag_helper.rb +58 -0
- data/lib/action_view/helpers/sanitize_helper.rb +251 -0
- data/lib/action_view/helpers/scriptaculous_helper.rb +226 -0
- data/lib/action_view/helpers/tag_helper.rb +151 -0
- data/lib/action_view/helpers/text_helper.rb +597 -0
- data/lib/action_view/helpers/translation_helper.rb +67 -0
- data/lib/action_view/helpers/url_helper.rb +637 -0
- data/lib/action_view/inline_template.rb +19 -0
- data/lib/action_view/locale/en.yml +117 -0
- data/lib/action_view/partials.rb +241 -0
- data/lib/action_view/paths.rb +77 -0
- data/lib/action_view/reloadable_template.rb +117 -0
- data/lib/action_view/renderable.rb +109 -0
- data/lib/action_view/renderable_partial.rb +53 -0
- data/lib/action_view/template.rb +252 -0
- data/lib/action_view/template_error.rb +99 -0
- data/lib/action_view/template_handler.rb +34 -0
- data/lib/action_view/template_handlers.rb +48 -0
- data/lib/action_view/template_handlers/builder.rb +17 -0
- data/lib/action_view/template_handlers/erb.rb +25 -0
- data/lib/action_view/template_handlers/rjs.rb +13 -0
- data/lib/action_view/test_case.rb +162 -0
- data/lib/actionpack.rb +2 -0
- data/test/abstract_unit.rb +78 -0
- data/test/active_record_unit.rb +104 -0
- data/test/activerecord/active_record_store_test.rb +221 -0
- data/test/activerecord/render_partial_with_record_identification_test.rb +188 -0
- data/test/adv_attr_test.rb +20 -0
- data/test/controller/action_pack_assertions_test.rb +545 -0
- data/test/controller/addresses_render_test.rb +37 -0
- data/test/controller/assert_select_test.rb +735 -0
- data/test/controller/base_test.rb +217 -0
- data/test/controller/benchmark_test.rb +32 -0
- data/test/controller/caching_test.rb +743 -0
- data/test/controller/capture_test.rb +66 -0
- data/test/controller/content_type_test.rb +178 -0
- data/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
- data/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
- data/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
- data/test/controller/cookie_test.rb +208 -0
- data/test/controller/deprecation/deprecated_base_methods_test.rb +32 -0
- data/test/controller/dispatcher_test.rb +144 -0
- data/test/controller/dom_assertions_test.rb +53 -0
- data/test/controller/failsafe_test.rb +60 -0
- data/test/controller/fake_controllers.rb +33 -0
- data/test/controller/fake_models.rb +19 -0
- data/test/controller/filter_params_test.rb +52 -0
- data/test/controller/filters_test.rb +885 -0
- data/test/controller/flash_test.rb +174 -0
- data/test/controller/header_test.rb +14 -0
- data/test/controller/helper_test.rb +224 -0
- data/test/controller/html-scanner/cdata_node_test.rb +15 -0
- data/test/controller/html-scanner/document_test.rb +148 -0
- data/test/controller/html-scanner/node_test.rb +89 -0
- data/test/controller/html-scanner/sanitizer_test.rb +281 -0
- data/test/controller/html-scanner/tag_node_test.rb +238 -0
- data/test/controller/html-scanner/text_node_test.rb +50 -0
- data/test/controller/html-scanner/tokenizer_test.rb +131 -0
- data/test/controller/http_basic_authentication_test.rb +113 -0
- data/test/controller/http_digest_authentication_test.rb +254 -0
- data/test/controller/integration_test.rb +526 -0
- data/test/controller/layout_test.rb +215 -0
- data/test/controller/localized_templates_test.rb +24 -0
- data/test/controller/logging_test.rb +46 -0
- data/test/controller/middleware_stack_test.rb +90 -0
- data/test/controller/mime_responds_test.rb +536 -0
- data/test/controller/mime_type_test.rb +93 -0
- data/test/controller/output_escaping_test.rb +19 -0
- data/test/controller/polymorphic_routes_test.rb +297 -0
- data/test/controller/rack_test.rb +308 -0
- data/test/controller/record_identifier_test.rb +139 -0
- data/test/controller/redirect_test.rb +285 -0
- data/test/controller/reloader_test.rb +125 -0
- data/test/controller/render_test.rb +1783 -0
- data/test/controller/request/json_params_parsing_test.rb +65 -0
- data/test/controller/request/multipart_params_parsing_test.rb +177 -0
- data/test/controller/request/query_string_parsing_test.rb +129 -0
- data/test/controller/request/test_request_test.rb +35 -0
- data/test/controller/request/url_encoded_params_parsing_test.rb +146 -0
- data/test/controller/request/xml_params_parsing_test.rb +103 -0
- data/test/controller/request_forgery_protection_test.rb +233 -0
- data/test/controller/request_test.rb +398 -0
- data/test/controller/rescue_test.rb +541 -0
- data/test/controller/resources_test.rb +1393 -0
- data/test/controller/routing_test.rb +2592 -0
- data/test/controller/selector_test.rb +628 -0
- data/test/controller/send_file_test.rb +171 -0
- data/test/controller/session/abstract_store_test.rb +64 -0
- data/test/controller/session/cookie_store_test.rb +354 -0
- data/test/controller/session/mem_cache_store_test.rb +187 -0
- data/test/controller/session/test_session_test.rb +58 -0
- data/test/controller/test_test.rb +700 -0
- data/test/controller/translation_test.rb +26 -0
- data/test/controller/url_rewriter_test.rb +395 -0
- data/test/controller/verification_test.rb +270 -0
- data/test/controller/view_paths_test.rb +141 -0
- data/test/controller/webservice_test.rb +273 -0
- data/test/fixtures/_top_level_partial.html.erb +1 -0
- data/test/fixtures/_top_level_partial_only.erb +1 -0
- data/test/fixtures/addresses/list.erb +1 -0
- data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
- data/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
- data/test/fixtures/companies.yml +24 -0
- data/test/fixtures/company.rb +10 -0
- data/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
- data/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
- data/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
- data/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
- data/test/fixtures/customers/_customer.html.erb +1 -0
- data/test/fixtures/db_definitions/sqlite.sql +49 -0
- data/test/fixtures/developer.rb +9 -0
- data/test/fixtures/developers.yml +21 -0
- data/test/fixtures/developers/_developer.erb +1 -0
- data/test/fixtures/developers_projects.yml +13 -0
- data/test/fixtures/failsafe/500.html +1 -0
- data/test/fixtures/fun/games/_game.erb +1 -0
- data/test/fixtures/fun/games/hello_world.erb +1 -0
- data/test/fixtures/fun/serious/games/_game.erb +1 -0
- data/test/fixtures/functional_caching/_partial.erb +3 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +6 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
- data/test/fixtures/functional_caching/fragment_cached.html.erb +2 -0
- data/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
- data/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
- data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +1 -0
- data/test/fixtures/good_customers/_good_customer.html.erb +1 -0
- data/test/fixtures/helpers/abc_helper.rb +5 -0
- data/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
- data/test/fixtures/layout_tests/abs_path_layout.rhtml +1 -0
- data/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
- data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
- data/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
- data/test/fixtures/layout_tests/views/hello.rhtml +1 -0
- data/test/fixtures/layouts/_column.html.erb +2 -0
- data/test/fixtures/layouts/block_with_layout.erb +3 -0
- data/test/fixtures/layouts/builder.builder +3 -0
- data/test/fixtures/layouts/default_html.html.erb +1 -0
- data/test/fixtures/layouts/partial_with_layout.erb +3 -0
- data/test/fixtures/layouts/standard.erb +1 -0
- data/test/fixtures/layouts/talk_from_action.erb +2 -0
- data/test/fixtures/layouts/xhr.html.erb +2 -0
- data/test/fixtures/layouts/yield.erb +2 -0
- data/test/fixtures/localized/hello_world.de.html +1 -0
- data/test/fixtures/localized/hello_world.en.html +1 -0
- data/test/fixtures/mascot.rb +3 -0
- data/test/fixtures/mascots.yml +4 -0
- data/test/fixtures/mascots/_mascot.html.erb +1 -0
- data/test/fixtures/multipart/binary_file +0 -0
- data/test/fixtures/multipart/boundary_problem_file +10 -0
- data/test/fixtures/multipart/bracketed_param +5 -0
- data/test/fixtures/multipart/empty +10 -0
- data/test/fixtures/multipart/hello.txt +1 -0
- data/test/fixtures/multipart/large_text_file +10 -0
- data/test/fixtures/multipart/mixed_files +0 -0
- data/test/fixtures/multipart/mona_lisa.jpg +0 -0
- data/test/fixtures/multipart/none +9 -0
- data/test/fixtures/multipart/single_parameter +5 -0
- data/test/fixtures/multipart/text_file +10 -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/project.rb +3 -0
- data/test/fixtures/projects.yml +7 -0
- data/test/fixtures/projects/_project.erb +1 -0
- data/test/fixtures/public/404.html +1 -0
- data/test/fixtures/public/500.da.html +1 -0
- data/test/fixtures/public/500.html +1 -0
- data/test/fixtures/public/absolute/test.css +23 -0
- data/test/fixtures/public/absolute/test.js +63 -0
- data/test/fixtures/public/images/rails.png +0 -0
- data/test/fixtures/public/javascripts/application.js +1 -0
- data/test/fixtures/public/javascripts/bank.js +1 -0
- data/test/fixtures/public/javascripts/controls.js +1 -0
- data/test/fixtures/public/javascripts/dragdrop.js +1 -0
- data/test/fixtures/public/javascripts/effects.js +1 -0
- data/test/fixtures/public/javascripts/prototype.js +1 -0
- data/test/fixtures/public/javascripts/robber.js +1 -0
- data/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
- data/test/fixtures/public/javascripts/version.1.0.js +1 -0
- data/test/fixtures/public/stylesheets/bank.css +1 -0
- data/test/fixtures/public/stylesheets/robber.css +1 -0
- data/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
- data/test/fixtures/public/stylesheets/version.1.0.css +1 -0
- data/test/fixtures/quiz/questions/_question.html.erb +1 -0
- data/test/fixtures/replies.yml +15 -0
- data/test/fixtures/replies/_reply.erb +1 -0
- data/test/fixtures/reply.rb +7 -0
- data/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
- data/test/fixtures/respond_to/all_types_with_layout.js.rjs +1 -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.html.erb +1 -0
- data/test/fixtures/respond_to/using_defaults.js.rjs +1 -0
- data/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
- data/test/fixtures/scope/test/modgreet.erb +1 -0
- data/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +10 -0
- data/test/fixtures/shared.html.erb +1 -0
- data/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
- data/test/fixtures/test/_counter.html.erb +1 -0
- data/test/fixtures/test/_customer.erb +1 -0
- data/test/fixtures/test/_customer_counter.erb +1 -0
- data/test/fixtures/test/_customer_counter_with_as.erb +1 -0
- data/test/fixtures/test/_customer_greeting.erb +1 -0
- data/test/fixtures/test/_customer_with_var.erb +1 -0
- data/test/fixtures/test/_form.erb +1 -0
- data/test/fixtures/test/_from_helper.erb +1 -0
- data/test/fixtures/test/_hash_greeting.erb +1 -0
- data/test/fixtures/test/_hash_object.erb +2 -0
- data/test/fixtures/test/_hello.builder +1 -0
- data/test/fixtures/test/_labelling_form.erb +1 -0
- data/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
- data/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/test/fixtures/test/_local_inspector.html.erb +1 -0
- data/test/fixtures/test/_one.html.erb +1 -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.erb +1 -0
- data/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
- data/test/fixtures/test/_person.erb +2 -0
- data/test/fixtures/test/_raise.html.erb +1 -0
- data/test/fixtures/test/_two.html.erb +1 -0
- data/test/fixtures/test/_utf8_partial.html.erb +1 -0
- data/test/fixtures/test/_utf8_partial_magic.html.erb +2 -0
- data/test/fixtures/test/action_talk_to_layout.erb +2 -0
- data/test/fixtures/test/array_translation.erb +1 -0
- data/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/test/fixtures/test/capturing.erb +4 -0
- data/test/fixtures/test/content_for.erb +2 -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/delete_with_js.rjs +2 -0
- data/test/fixtures/test/dont_pick_me +1 -0
- data/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/test/fixtures/test/enum_rjs_test.rjs +6 -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.erb +1 -0
- data/test/fixtures/test/greeting.js.rjs +1 -0
- data/test/fixtures/test/hello.builder +4 -0
- 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.erb~ +1 -0
- data/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
- data/test/fixtures/test/hello_world_container.builder +3 -0
- data/test/fixtures/test/hello_world_from_rxml.builder +4 -0
- data/test/fixtures/test/hello_world_with_layout_false.erb +1 -0
- data/test/fixtures/test/hello_xml_world.builder +11 -0
- data/test/fixtures/test/hyphen-ated.erb +1 -0
- data/test/fixtures/test/implicit_content_type.atom.builder +2 -0
- data/test/fixtures/test/list.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/nested_layout.erb +3 -0
- data/test/fixtures/test/non_erb_block_content_for.builder +4 -0
- data/test/fixtures/test/potential_conflicts.erb +4 -0
- data/test/fixtures/test/render_explicit_html_template.js.rjs +1 -0
- data/test/fixtures/test/render_file_from_template.html.erb +1 -0
- data/test/fixtures/test/render_file_with_ivar.erb +1 -0
- data/test/fixtures/test/render_file_with_locals.erb +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/render_to_string_test.erb +1 -0
- data/test/fixtures/test/scoped_array_translation.erb +1 -0
- data/test/fixtures/test/sub_template_raise.html.erb +1 -0
- data/test/fixtures/test/template.erb +1 -0
- data/test/fixtures/test/translation.erb +1 -0
- data/test/fixtures/test/update_element_with_capture.erb +9 -0
- data/test/fixtures/test/using_layout_around_block.html.erb +1 -0
- data/test/fixtures/test/using_layout_around_block_with_args.html.erb +1 -0
- data/test/fixtures/test/utf8.html.erb +4 -0
- data/test/fixtures/test/utf8_magic.html.erb +5 -0
- data/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +5 -0
- data/test/fixtures/topic.rb +3 -0
- data/test/fixtures/topics.yml +22 -0
- data/test/fixtures/topics/_topic.html.erb +1 -0
- data/test/template/active_record_helper_i18n_test.rb +51 -0
- data/test/template/active_record_helper_test.rb +302 -0
- data/test/template/asset_tag_helper_test.rb +770 -0
- data/test/template/atom_feed_helper_test.rb +315 -0
- data/test/template/benchmark_helper_test.rb +86 -0
- data/test/template/compiled_templates_test.rb +204 -0
- data/test/template/date_helper_i18n_test.rb +121 -0
- data/test/template/date_helper_test.rb +2603 -0
- data/test/template/erb_util_test.rb +36 -0
- data/test/template/form_helper_test.rb +1447 -0
- data/test/template/form_options_helper_i18n_test.rb +27 -0
- data/test/template/form_options_helper_test.rb +811 -0
- data/test/template/form_tag_helper_test.rb +356 -0
- data/test/template/javascript_helper_test.rb +106 -0
- data/test/template/number_helper_i18n_test.rb +69 -0
- data/test/template/number_helper_test.rb +132 -0
- data/test/template/prototype_helper_test.rb +639 -0
- data/test/template/raw_output_helper_test.rb +21 -0
- data/test/template/record_tag_helper_test.rb +58 -0
- data/test/template/render_test.rb +329 -0
- data/test/template/sanitize_helper_test.rb +57 -0
- data/test/template/scriptaculous_helper_test.rb +90 -0
- data/test/template/tag_helper_test.rb +98 -0
- data/test/template/template_test.rb +32 -0
- data/test/template/test_test.rb +54 -0
- data/test/template/text_helper_test.rb +601 -0
- data/test/template/translation_helper_test.rb +95 -0
- data/test/template/url_helper_test.rb +641 -0
- data/test/testing_sandbox.rb +15 -0
- data/test/view/test_case_test.rb +176 -0
- metadata +519 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class Address
|
4
|
+
def Address.count(conditions = nil, join = nil)
|
5
|
+
nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def Address.find_all(arg1, arg2, arg3, arg4)
|
9
|
+
[]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find(*args)
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class AddressesTestController < ActionController::Base
|
18
|
+
def self.controller_name; "addresses"; end
|
19
|
+
def self.controller_path; "addresses"; end
|
20
|
+
end
|
21
|
+
|
22
|
+
class AddressesTest < ActionController::TestCase
|
23
|
+
tests AddressesTestController
|
24
|
+
|
25
|
+
def setup
|
26
|
+
# enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
|
27
|
+
# a more accurate simulation of what happens in "real life".
|
28
|
+
@controller.logger = Logger.new(nil)
|
29
|
+
|
30
|
+
@request.host = "www.nextangle.com"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_list
|
34
|
+
get :list
|
35
|
+
assert_equal "We only need to get this far!", @response.body.chomp
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,735 @@
|
|
1
|
+
# encoding: us-ascii
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
|
4
|
+
# Under MIT and/or CC By license.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'abstract_unit'
|
8
|
+
require 'controller/fake_controllers'
|
9
|
+
|
10
|
+
|
11
|
+
unless defined?(ActionMailer)
|
12
|
+
begin
|
13
|
+
$:.unshift("#{File.dirname(__FILE__)}/../../../actionmailer/lib")
|
14
|
+
require 'action_mailer'
|
15
|
+
rescue LoadError => e
|
16
|
+
raise unless e.message =~ /action_mailer/
|
17
|
+
require 'rubygems'
|
18
|
+
gem 'actionmailer'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
ActionMailer::Base.template_root = FIXTURE_LOAD_PATH
|
23
|
+
|
24
|
+
class AssertSelectTest < ActionController::TestCase
|
25
|
+
Assertion = ActiveSupport::TestCase::Assertion
|
26
|
+
|
27
|
+
class AssertSelectMailer < ActionMailer::Base
|
28
|
+
def test(html)
|
29
|
+
recipients "test <test@test.host>"
|
30
|
+
from "test@test.host"
|
31
|
+
subject "Test e-mail"
|
32
|
+
part :content_type=>"text/html", :body=>html
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class AssertSelectController < ActionController::Base
|
37
|
+
def response_with=(content)
|
38
|
+
@content = content
|
39
|
+
end
|
40
|
+
|
41
|
+
def response_with(&block)
|
42
|
+
@update = block
|
43
|
+
end
|
44
|
+
|
45
|
+
def html()
|
46
|
+
render :text=>@content, :layout=>false, :content_type=>Mime::HTML
|
47
|
+
@content = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def rjs()
|
51
|
+
render :update do |page|
|
52
|
+
@update.call page
|
53
|
+
end
|
54
|
+
@update = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def xml()
|
58
|
+
render :text=>@content, :layout=>false, :content_type=>Mime::XML
|
59
|
+
@content = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def rescue_action(e)
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
tests AssertSelectController
|
68
|
+
|
69
|
+
def setup
|
70
|
+
ActionMailer::Base.delivery_method = :test
|
71
|
+
ActionMailer::Base.perform_deliveries = true
|
72
|
+
ActionMailer::Base.deliveries = []
|
73
|
+
end
|
74
|
+
|
75
|
+
def teardown
|
76
|
+
ActionMailer::Base.deliveries.clear
|
77
|
+
end
|
78
|
+
|
79
|
+
def assert_failure(message, &block)
|
80
|
+
e = assert_raise(Assertion, &block)
|
81
|
+
assert_match(message, e.message) if Regexp === message
|
82
|
+
assert_equal(message, e.message) if String === message
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Test assert select.
|
87
|
+
#
|
88
|
+
|
89
|
+
def test_assert_select
|
90
|
+
render_html %Q{<div id="1"></div><div id="2"></div>}
|
91
|
+
assert_select "div", 2
|
92
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) { assert_select "div", 3 }
|
93
|
+
assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" }
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_equality_true_false
|
97
|
+
render_html %Q{<div id="1"></div><div id="2"></div>}
|
98
|
+
assert_nothing_raised { assert_select "div" }
|
99
|
+
assert_raise(Assertion) { assert_select "p" }
|
100
|
+
assert_nothing_raised { assert_select "div", true }
|
101
|
+
assert_raise(Assertion) { assert_select "p", true }
|
102
|
+
assert_raise(Assertion) { assert_select "div", false }
|
103
|
+
assert_nothing_raised { assert_select "p", false }
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_equality_string_and_regexp
|
107
|
+
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
108
|
+
assert_nothing_raised { assert_select "div", "foo" }
|
109
|
+
assert_raise(Assertion) { assert_select "div", "bar" }
|
110
|
+
assert_nothing_raised { assert_select "div", :text=>"foo" }
|
111
|
+
assert_raise(Assertion) { assert_select "div", :text=>"bar" }
|
112
|
+
assert_nothing_raised { assert_select "div", /(foo|bar)/ }
|
113
|
+
assert_raise(Assertion) { assert_select "div", /foobar/ }
|
114
|
+
assert_nothing_raised { assert_select "div", :text=>/(foo|bar)/ }
|
115
|
+
assert_raise(Assertion) { assert_select "div", :text=>/foobar/ }
|
116
|
+
assert_raise(Assertion) { assert_select "p", :text=>/foobar/ }
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_equality_of_html
|
120
|
+
render_html %Q{<p>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</p>}
|
121
|
+
text = "\"This is not a big problem,\" he said."
|
122
|
+
html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said."
|
123
|
+
assert_nothing_raised { assert_select "p", text }
|
124
|
+
assert_raise(Assertion) { assert_select "p", html }
|
125
|
+
assert_nothing_raised { assert_select "p", :html=>html }
|
126
|
+
assert_raise(Assertion) { assert_select "p", :html=>text }
|
127
|
+
# No stripping for pre.
|
128
|
+
render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>}
|
129
|
+
text = "\n\"This is not a big problem,\" he said.\n"
|
130
|
+
html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n"
|
131
|
+
assert_nothing_raised { assert_select "pre", text }
|
132
|
+
assert_raise(Assertion) { assert_select "pre", html }
|
133
|
+
assert_nothing_raised { assert_select "pre", :html=>html }
|
134
|
+
assert_raise(Assertion) { assert_select "pre", :html=>text }
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_counts
|
138
|
+
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
139
|
+
assert_nothing_raised { assert_select "div", 2 }
|
140
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
141
|
+
assert_select "div", 3
|
142
|
+
end
|
143
|
+
assert_nothing_raised { assert_select "div", 1..2 }
|
144
|
+
assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do
|
145
|
+
assert_select "div", 3..4
|
146
|
+
end
|
147
|
+
assert_nothing_raised { assert_select "div", :count=>2 }
|
148
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
149
|
+
assert_select "div", :count=>3
|
150
|
+
end
|
151
|
+
assert_nothing_raised { assert_select "div", :minimum=>1 }
|
152
|
+
assert_nothing_raised { assert_select "div", :minimum=>2 }
|
153
|
+
assert_failure(/Expected at least 3 elements matching \"div\", found 2/) do
|
154
|
+
assert_select "div", :minimum=>3
|
155
|
+
end
|
156
|
+
assert_nothing_raised { assert_select "div", :maximum=>2 }
|
157
|
+
assert_nothing_raised { assert_select "div", :maximum=>3 }
|
158
|
+
assert_failure(/Expected at most 1 element matching \"div\", found 2/) do
|
159
|
+
assert_select "div", :maximum=>1
|
160
|
+
end
|
161
|
+
assert_nothing_raised { assert_select "div", :minimum=>1, :maximum=>2 }
|
162
|
+
assert_failure(/Expected between 3 and 4 elements matching \"div\", found 2/) do
|
163
|
+
assert_select "div", :minimum=>3, :maximum=>4
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_substitution_values
|
168
|
+
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
169
|
+
assert_select "div#?", /\d+/ do |elements|
|
170
|
+
assert_equal 2, elements.size
|
171
|
+
end
|
172
|
+
assert_select "div" do
|
173
|
+
assert_select "div#?", /\d+/ do |elements|
|
174
|
+
assert_equal 2, elements.size
|
175
|
+
assert_select "#1"
|
176
|
+
assert_select "#2"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_nested_assert_select
|
182
|
+
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
183
|
+
assert_select "div" do |elements|
|
184
|
+
assert_equal 2, elements.size
|
185
|
+
assert_select elements[0], "#1"
|
186
|
+
assert_select elements[1], "#2"
|
187
|
+
end
|
188
|
+
assert_select "div" do
|
189
|
+
assert_select "div" do |elements|
|
190
|
+
assert_equal 2, elements.size
|
191
|
+
# Testing in a group is one thing
|
192
|
+
assert_select "#1,#2"
|
193
|
+
# Testing individually is another.
|
194
|
+
assert_select "#1"
|
195
|
+
assert_select "#2"
|
196
|
+
assert_select "#3", false
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
assert_failure(/Expected at least 1 element matching \"#4\", found 0\./) do
|
201
|
+
assert_select "div" do
|
202
|
+
assert_select "#4"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_assert_select_text_match
|
208
|
+
render_html %Q{<div id="1"><span>foo</span></div><div id="2"><span>bar</span></div>}
|
209
|
+
assert_select "div" do
|
210
|
+
assert_nothing_raised { assert_select "div", "foo" }
|
211
|
+
assert_nothing_raised { assert_select "div", "bar" }
|
212
|
+
assert_nothing_raised { assert_select "div", /\w*/ }
|
213
|
+
assert_nothing_raised { assert_select "div", :text => /\w*/, :count=>2 }
|
214
|
+
assert_raise(Assertion) { assert_select "div", :text=>"foo", :count=>2 }
|
215
|
+
assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" }
|
216
|
+
assert_nothing_raised { assert_select "div", :html=>"<span>bar</span>" }
|
217
|
+
assert_nothing_raised { assert_select "div", :html=>/\w*/ }
|
218
|
+
assert_nothing_raised { assert_select "div", :html=>/\w*/, :count=>2 }
|
219
|
+
assert_raise(Assertion) { assert_select "div", :html=>"<span>foo</span>", :count=>2 }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# With single result.
|
224
|
+
def test_assert_select_from_rjs_with_single_result
|
225
|
+
render_rjs do |page|
|
226
|
+
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
227
|
+
end
|
228
|
+
assert_select "div" do |elements|
|
229
|
+
assert elements.size == 2
|
230
|
+
assert_select "#1"
|
231
|
+
assert_select "#2"
|
232
|
+
end
|
233
|
+
assert_select "div#?", /\d+/ do |elements|
|
234
|
+
assert_select "#1"
|
235
|
+
assert_select "#2"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# With multiple results.
|
240
|
+
def test_assert_select_from_rjs_with_multiple_results
|
241
|
+
render_rjs do |page|
|
242
|
+
page.replace_html "test", "<div id=\"1\">foo</div>"
|
243
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
244
|
+
end
|
245
|
+
assert_select "div" do |elements|
|
246
|
+
assert elements.size == 2
|
247
|
+
assert_select "#1"
|
248
|
+
assert_select "#2"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments
|
253
|
+
render_rjs do |page|
|
254
|
+
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
|
255
|
+
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
|
256
|
+
end
|
257
|
+
assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"}
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_elect_with_xml_namespace_attributes
|
261
|
+
render_html %Q{<link xlink:href="http://nowhere.com"></link>}
|
262
|
+
assert_nothing_raised { assert_select "link[xlink:href=http://nowhere.com]" }
|
263
|
+
end
|
264
|
+
|
265
|
+
#
|
266
|
+
# Test css_select.
|
267
|
+
#
|
268
|
+
|
269
|
+
def test_css_select
|
270
|
+
render_html %Q{<div id="1"></div><div id="2"></div>}
|
271
|
+
assert_equal 2, css_select("div").size
|
272
|
+
assert_equal 0, css_select("p").size
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_nested_css_select
|
276
|
+
render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
|
277
|
+
assert_select "div#?", /\d+/ do |elements|
|
278
|
+
assert_equal 1, css_select(elements[0], "div").size
|
279
|
+
assert_equal 1, css_select(elements[1], "div").size
|
280
|
+
end
|
281
|
+
assert_select "div" do
|
282
|
+
assert_equal 2, css_select("div").size
|
283
|
+
css_select("div").each do |element|
|
284
|
+
# Testing as a group is one thing
|
285
|
+
assert !css_select("#1,#2").empty?
|
286
|
+
# Testing individually is another
|
287
|
+
assert !css_select("#1").empty?
|
288
|
+
assert !css_select("#2").empty?
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# With one result.
|
294
|
+
def test_css_select_from_rjs_with_single_result
|
295
|
+
render_rjs do |page|
|
296
|
+
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
297
|
+
end
|
298
|
+
assert_equal 2, css_select("div").size
|
299
|
+
assert_equal 1, css_select("#1").size
|
300
|
+
assert_equal 1, css_select("#2").size
|
301
|
+
end
|
302
|
+
|
303
|
+
# With multiple results.
|
304
|
+
def test_css_select_from_rjs_with_multiple_results
|
305
|
+
render_rjs do |page|
|
306
|
+
page.replace_html "test", "<div id=\"1\">foo</div>"
|
307
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
308
|
+
end
|
309
|
+
|
310
|
+
assert_equal 2, css_select("div").size
|
311
|
+
assert_equal 1, css_select("#1").size
|
312
|
+
assert_equal 1, css_select("#2").size
|
313
|
+
end
|
314
|
+
|
315
|
+
#
|
316
|
+
# Test assert_select_rjs.
|
317
|
+
#
|
318
|
+
|
319
|
+
# Test that we can pick up all statements in the result.
|
320
|
+
def test_assert_select_rjs_picks_up_all_statements
|
321
|
+
render_rjs do |page|
|
322
|
+
page.replace "test", "<div id=\"1\">foo</div>"
|
323
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
324
|
+
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
325
|
+
end
|
326
|
+
|
327
|
+
found = false
|
328
|
+
assert_select_rjs do
|
329
|
+
assert_select "#1"
|
330
|
+
assert_select "#2"
|
331
|
+
assert_select "#3"
|
332
|
+
found = true
|
333
|
+
end
|
334
|
+
assert found
|
335
|
+
end
|
336
|
+
|
337
|
+
# Test that we fail if there is nothing to pick.
|
338
|
+
def test_assert_select_rjs_fails_if_nothing_to_pick
|
339
|
+
render_rjs { }
|
340
|
+
assert_raise(Assertion) { assert_select_rjs }
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_assert_select_rjs_with_unicode
|
344
|
+
# Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly.
|
345
|
+
render_rjs do |page|
|
346
|
+
page.replace "test", "<div id=\"1\">\343\203\201\343\202\261\343\203\203\343\203\210</div>"
|
347
|
+
end
|
348
|
+
assert_select_rjs do
|
349
|
+
str = "#1"
|
350
|
+
assert_select str, :text => "\343\203\201\343\202\261\343\203\203\343\203\210"
|
351
|
+
assert_select str, "\343\203\201\343\202\261\343\203\203\343\203\210"
|
352
|
+
if str.respond_to?(:force_encoding)
|
353
|
+
str.force_encoding(Encoding::UTF_8)
|
354
|
+
assert_select str, /\343\203\201..\343\203\210/u
|
355
|
+
assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u }
|
356
|
+
else
|
357
|
+
assert_select str, Regexp.new("\343\203\201..\343\203\210",0,'U')
|
358
|
+
assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210",0,'U') }
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_assert_select_rjs_with_id
|
364
|
+
# Test that we can pick up all statements in the result.
|
365
|
+
render_rjs do |page|
|
366
|
+
page.replace "test1", "<div id=\"1\">foo</div>"
|
367
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
368
|
+
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
369
|
+
end
|
370
|
+
assert_select_rjs "test1" do
|
371
|
+
assert_select "div", 1
|
372
|
+
assert_select "#1"
|
373
|
+
end
|
374
|
+
assert_select_rjs "test2" do
|
375
|
+
assert_select "div", 1
|
376
|
+
assert_select "#2"
|
377
|
+
end
|
378
|
+
assert_select_rjs "test3" do
|
379
|
+
assert_select "div", 1
|
380
|
+
assert_select "#3"
|
381
|
+
end
|
382
|
+
assert_raise(Assertion) { assert_select_rjs "test4" }
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_assert_select_rjs_for_replace
|
386
|
+
render_rjs do |page|
|
387
|
+
page.replace "test1", "<div id=\"1\">foo</div>"
|
388
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
389
|
+
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
390
|
+
end
|
391
|
+
# Replace.
|
392
|
+
assert_select_rjs :replace do
|
393
|
+
assert_select "div", 1
|
394
|
+
assert_select "#1"
|
395
|
+
end
|
396
|
+
assert_select_rjs :replace, "test1" do
|
397
|
+
assert_select "div", 1
|
398
|
+
assert_select "#1"
|
399
|
+
end
|
400
|
+
assert_raise(Assertion) { assert_select_rjs :replace, "test2" }
|
401
|
+
# Replace HTML.
|
402
|
+
assert_select_rjs :replace_html do
|
403
|
+
assert_select "div", 1
|
404
|
+
assert_select "#2"
|
405
|
+
end
|
406
|
+
assert_select_rjs :replace_html, "test2" do
|
407
|
+
assert_select "div", 1
|
408
|
+
assert_select "#2"
|
409
|
+
end
|
410
|
+
assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
|
411
|
+
end
|
412
|
+
|
413
|
+
def test_assert_select_rjs_for_chained_replace
|
414
|
+
render_rjs do |page|
|
415
|
+
page['test1'].replace "<div id=\"1\">foo</div>"
|
416
|
+
page['test2'].replace_html "<div id=\"2\">foo</div>"
|
417
|
+
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
418
|
+
end
|
419
|
+
# Replace.
|
420
|
+
assert_select_rjs :chained_replace do
|
421
|
+
assert_select "div", 1
|
422
|
+
assert_select "#1"
|
423
|
+
end
|
424
|
+
assert_select_rjs :chained_replace, "test1" do
|
425
|
+
assert_select "div", 1
|
426
|
+
assert_select "#1"
|
427
|
+
end
|
428
|
+
assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" }
|
429
|
+
# Replace HTML.
|
430
|
+
assert_select_rjs :chained_replace_html do
|
431
|
+
assert_select "div", 1
|
432
|
+
assert_select "#2"
|
433
|
+
end
|
434
|
+
assert_select_rjs :chained_replace_html, "test2" do
|
435
|
+
assert_select "div", 1
|
436
|
+
assert_select "#2"
|
437
|
+
end
|
438
|
+
assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
|
439
|
+
end
|
440
|
+
|
441
|
+
# Simple remove
|
442
|
+
def test_assert_select_rjs_for_remove
|
443
|
+
render_rjs do |page|
|
444
|
+
page.remove "test1"
|
445
|
+
end
|
446
|
+
|
447
|
+
assert_select_rjs :remove, "test1"
|
448
|
+
end
|
449
|
+
|
450
|
+
def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails
|
451
|
+
render_rjs do |page|
|
452
|
+
page.remove "test_with_typo"
|
453
|
+
end
|
454
|
+
|
455
|
+
assert_select_rjs :remove, "test1"
|
456
|
+
|
457
|
+
rescue Assertion
|
458
|
+
assert_equal "No RJS statement that removes 'test1' was rendered.", $!.message
|
459
|
+
end
|
460
|
+
|
461
|
+
def test_assert_select_rjs_for_remove_ignores_block
|
462
|
+
render_rjs do |page|
|
463
|
+
page.remove "test1"
|
464
|
+
end
|
465
|
+
|
466
|
+
assert_nothing_raised do
|
467
|
+
assert_select_rjs :remove, "test1" do
|
468
|
+
assert_select "p"
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
# Simple show
|
474
|
+
def test_assert_select_rjs_for_show
|
475
|
+
render_rjs do |page|
|
476
|
+
page.show "test1"
|
477
|
+
end
|
478
|
+
|
479
|
+
assert_select_rjs :show, "test1"
|
480
|
+
end
|
481
|
+
|
482
|
+
def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails
|
483
|
+
render_rjs do |page|
|
484
|
+
page.show "test_with_typo"
|
485
|
+
end
|
486
|
+
|
487
|
+
assert_select_rjs :show, "test1"
|
488
|
+
|
489
|
+
rescue Assertion
|
490
|
+
assert_equal "No RJS statement that shows 'test1' was rendered.", $!.message
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_assert_select_rjs_for_show_ignores_block
|
494
|
+
render_rjs do |page|
|
495
|
+
page.show "test1"
|
496
|
+
end
|
497
|
+
|
498
|
+
assert_nothing_raised do
|
499
|
+
assert_select_rjs :show, "test1" do
|
500
|
+
assert_select "p"
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
# Simple hide
|
506
|
+
def test_assert_select_rjs_for_hide
|
507
|
+
render_rjs do |page|
|
508
|
+
page.hide "test1"
|
509
|
+
end
|
510
|
+
|
511
|
+
assert_select_rjs :hide, "test1"
|
512
|
+
end
|
513
|
+
|
514
|
+
def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails
|
515
|
+
render_rjs do |page|
|
516
|
+
page.hide "test_with_typo"
|
517
|
+
end
|
518
|
+
|
519
|
+
assert_select_rjs :hide, "test1"
|
520
|
+
|
521
|
+
rescue Assertion
|
522
|
+
assert_equal "No RJS statement that hides 'test1' was rendered.", $!.message
|
523
|
+
end
|
524
|
+
|
525
|
+
def test_assert_select_rjs_for_hide_ignores_block
|
526
|
+
render_rjs do |page|
|
527
|
+
page.hide "test1"
|
528
|
+
end
|
529
|
+
|
530
|
+
assert_nothing_raised do
|
531
|
+
assert_select_rjs :hide, "test1" do
|
532
|
+
assert_select "p"
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
# Simple toggle
|
538
|
+
def test_assert_select_rjs_for_toggle
|
539
|
+
render_rjs do |page|
|
540
|
+
page.toggle "test1"
|
541
|
+
end
|
542
|
+
|
543
|
+
assert_select_rjs :toggle, "test1"
|
544
|
+
end
|
545
|
+
|
546
|
+
def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails
|
547
|
+
render_rjs do |page|
|
548
|
+
page.toggle "test_with_typo"
|
549
|
+
end
|
550
|
+
|
551
|
+
assert_select_rjs :toggle, "test1"
|
552
|
+
|
553
|
+
rescue Assertion
|
554
|
+
assert_equal "No RJS statement that toggles 'test1' was rendered.", $!.message
|
555
|
+
end
|
556
|
+
|
557
|
+
def test_assert_select_rjs_for_toggle_ignores_block
|
558
|
+
render_rjs do |page|
|
559
|
+
page.toggle "test1"
|
560
|
+
end
|
561
|
+
|
562
|
+
assert_nothing_raised do
|
563
|
+
assert_select_rjs :toggle, "test1" do
|
564
|
+
assert_select "p"
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
# Non-positioned insert.
|
570
|
+
def test_assert_select_rjs_for_nonpositioned_insert
|
571
|
+
render_rjs do |page|
|
572
|
+
page.replace "test1", "<div id=\"1\">foo</div>"
|
573
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
574
|
+
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
575
|
+
end
|
576
|
+
assert_select_rjs :insert_html do
|
577
|
+
assert_select "div", 1
|
578
|
+
assert_select "#3"
|
579
|
+
end
|
580
|
+
assert_select_rjs :insert_html, "test3" do
|
581
|
+
assert_select "div", 1
|
582
|
+
assert_select "#3"
|
583
|
+
end
|
584
|
+
assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" }
|
585
|
+
end
|
586
|
+
|
587
|
+
# Positioned insert.
|
588
|
+
def test_assert_select_rjs_for_positioned_insert
|
589
|
+
render_rjs do |page|
|
590
|
+
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
|
591
|
+
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
|
592
|
+
page.insert_html :before, "test3", "<div id=\"3\">foo</div>"
|
593
|
+
page.insert_html :after, "test4", "<div id=\"4\">foo</div>"
|
594
|
+
end
|
595
|
+
assert_select_rjs :insert, :top do
|
596
|
+
assert_select "div", 1
|
597
|
+
assert_select "#1"
|
598
|
+
end
|
599
|
+
assert_select_rjs :insert, :bottom do
|
600
|
+
assert_select "div", 1
|
601
|
+
assert_select "#2"
|
602
|
+
end
|
603
|
+
assert_select_rjs :insert, :before do
|
604
|
+
assert_select "div", 1
|
605
|
+
assert_select "#3"
|
606
|
+
end
|
607
|
+
assert_select_rjs :insert, :after do
|
608
|
+
assert_select "div", 1
|
609
|
+
assert_select "#4"
|
610
|
+
end
|
611
|
+
assert_select_rjs :insert_html do
|
612
|
+
assert_select "div", 4
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
def test_assert_select_rjs_raise_errors
|
617
|
+
assert_raise(ArgumentError) { assert_select_rjs(:destroy) }
|
618
|
+
assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) }
|
619
|
+
end
|
620
|
+
|
621
|
+
# Simple selection from a single result.
|
622
|
+
def test_nested_assert_select_rjs_with_single_result
|
623
|
+
render_rjs do |page|
|
624
|
+
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
625
|
+
end
|
626
|
+
|
627
|
+
assert_select_rjs "test" do |elements|
|
628
|
+
assert_equal 2, elements.size
|
629
|
+
assert_select "#1"
|
630
|
+
assert_select "#2"
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
# Deal with two results.
|
635
|
+
def test_nested_assert_select_rjs_with_two_results
|
636
|
+
render_rjs do |page|
|
637
|
+
page.replace_html "test", "<div id=\"1\">foo</div>"
|
638
|
+
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
639
|
+
end
|
640
|
+
|
641
|
+
assert_select_rjs "test" do |elements|
|
642
|
+
assert_equal 1, elements.size
|
643
|
+
assert_select "#1"
|
644
|
+
end
|
645
|
+
|
646
|
+
assert_select_rjs "test2" do |elements|
|
647
|
+
assert_equal 1, elements.size
|
648
|
+
assert_select "#2"
|
649
|
+
end
|
650
|
+
end
|
651
|
+
|
652
|
+
def test_feed_item_encoded
|
653
|
+
render_xml <<-EOF
|
654
|
+
<rss version="2.0">
|
655
|
+
<channel>
|
656
|
+
<item>
|
657
|
+
<description>
|
658
|
+
<![CDATA[
|
659
|
+
<p>Test 1</p>
|
660
|
+
]]>
|
661
|
+
</description>
|
662
|
+
</item>
|
663
|
+
<item>
|
664
|
+
<description>
|
665
|
+
<![CDATA[
|
666
|
+
<p>Test 2</p>
|
667
|
+
]]>
|
668
|
+
</description>
|
669
|
+
</item>
|
670
|
+
</channel>
|
671
|
+
</rss>
|
672
|
+
EOF
|
673
|
+
assert_select "channel item description" do
|
674
|
+
# Test element regardless of wrapper.
|
675
|
+
assert_select_encoded do
|
676
|
+
assert_select "p", :count=>2, :text=>/Test/
|
677
|
+
end
|
678
|
+
# Test through encoded wrapper.
|
679
|
+
assert_select_encoded do
|
680
|
+
assert_select "encoded p", :count=>2, :text=>/Test/
|
681
|
+
end
|
682
|
+
# Use :root instead (recommended)
|
683
|
+
assert_select_encoded do
|
684
|
+
assert_select ":root p", :count=>2, :text=>/Test/
|
685
|
+
end
|
686
|
+
# Test individually.
|
687
|
+
assert_select "description" do |elements|
|
688
|
+
assert_select_encoded elements[0] do
|
689
|
+
assert_select "p", "Test 1"
|
690
|
+
end
|
691
|
+
assert_select_encoded elements[1] do
|
692
|
+
assert_select "p", "Test 2"
|
693
|
+
end
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
# Test that we only un-encode element itself.
|
698
|
+
assert_select "channel item" do
|
699
|
+
assert_select_encoded do
|
700
|
+
assert_select "p", 0
|
701
|
+
end
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
#
|
706
|
+
# Test assert_select_email
|
707
|
+
#
|
708
|
+
|
709
|
+
def test_assert_select_email
|
710
|
+
assert_raise(Assertion) { assert_select_email {} }
|
711
|
+
AssertSelectMailer.deliver_test "<div><p>foo</p><p>bar</p></div>"
|
712
|
+
assert_select_email do
|
713
|
+
assert_select "div:root" do
|
714
|
+
assert_select "p:first-child", "foo"
|
715
|
+
assert_select "p:last-child", "bar"
|
716
|
+
end
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
protected
|
721
|
+
def render_html(html)
|
722
|
+
@controller.response_with = html
|
723
|
+
get :html
|
724
|
+
end
|
725
|
+
|
726
|
+
def render_rjs(&block)
|
727
|
+
@controller.response_with &block
|
728
|
+
get :rjs
|
729
|
+
end
|
730
|
+
|
731
|
+
def render_xml(xml)
|
732
|
+
@controller.response_with = xml
|
733
|
+
get :xml
|
734
|
+
end
|
735
|
+
end
|