eactionpack 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/MIT-LICENSE +21 -0
- data/README +469 -0
- data/RUNNING_UNIT_TESTS +24 -0
- data/Rakefile +146 -0
- data/install.rb +30 -0
- data/lib/action_controller.rb +79 -0
- data/lib/action_controller/assertions.rb +69 -0
- data/lib/action_controller/assertions/dom_assertions.rb +39 -0
- data/lib/action_controller/assertions/model_assertions.rb +20 -0
- data/lib/action_controller/assertions/response_assertions.rb +172 -0
- data/lib/action_controller/assertions/routing_assertions.rb +146 -0
- data/lib/action_controller/assertions/selector_assertions.rb +491 -0
- data/lib/action_controller/assertions/tag_assertions.rb +130 -0
- data/lib/action_controller/base.rb +1288 -0
- data/lib/action_controller/benchmarking.rb +94 -0
- data/lib/action_controller/caching.rb +72 -0
- data/lib/action_controller/caching/actions.rb +144 -0
- data/lib/action_controller/caching/fragments.rb +138 -0
- data/lib/action_controller/caching/pages.rb +154 -0
- data/lib/action_controller/caching/sql_cache.rb +18 -0
- data/lib/action_controller/caching/sweeping.rb +97 -0
- data/lib/action_controller/cgi_ext.rb +16 -0
- data/lib/action_controller/cgi_ext/cookie.rb +110 -0
- 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 +24 -0
- data/lib/action_controller/cgi_process.rb +223 -0
- data/lib/action_controller/components.rb +166 -0
- data/lib/action_controller/cookies.rb +96 -0
- data/lib/action_controller/dispatcher.rb +162 -0
- data/lib/action_controller/filters.rb +642 -0
- data/lib/action_controller/flash.rb +172 -0
- data/lib/action_controller/headers.rb +31 -0
- data/lib/action_controller/helpers.rb +221 -0
- data/lib/action_controller/http_authentication.rb +124 -0
- data/lib/action_controller/integration.rb +634 -0
- data/lib/action_controller/layout.rb +309 -0
- data/lib/action_controller/mime_responds.rb +173 -0
- data/lib/action_controller/mime_type.rb +186 -0
- data/lib/action_controller/mime_types.rb +20 -0
- data/lib/action_controller/polymorphic_routes.rb +191 -0
- data/lib/action_controller/record_identifier.rb +102 -0
- data/lib/action_controller/request.rb +764 -0
- data/lib/action_controller/request_forgery_protection.rb +140 -0
- data/lib/action_controller/request_profiler.rb +169 -0
- data/lib/action_controller/rescue.rb +258 -0
- data/lib/action_controller/resources.rb +572 -0
- data/lib/action_controller/response.rb +76 -0
- data/lib/action_controller/routing.rb +387 -0
- data/lib/action_controller/routing/builder.rb +203 -0
- data/lib/action_controller/routing/optimisations.rb +120 -0
- data/lib/action_controller/routing/recognition_optimisation.rb +162 -0
- data/lib/action_controller/routing/route.rb +240 -0
- data/lib/action_controller/routing/route_set.rb +436 -0
- data/lib/action_controller/routing/routing_ext.rb +46 -0
- data/lib/action_controller/routing/segments.rb +283 -0
- data/lib/action_controller/session/active_record_store.rb +340 -0
- data/lib/action_controller/session/cookie_store.rb +166 -0
- data/lib/action_controller/session/drb_server.rb +32 -0
- data/lib/action_controller/session/drb_store.rb +35 -0
- data/lib/action_controller/session/mem_cache_store.rb +98 -0
- data/lib/action_controller/session_management.rb +158 -0
- data/lib/action_controller/status_codes.rb +88 -0
- data/lib/action_controller/streaming.rb +155 -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 +83 -0
- data/lib/action_controller/test_process.rb +526 -0
- data/lib/action_controller/url_rewriter.rb +142 -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 +44 -0
- data/lib/action_view/base.rb +335 -0
- data/lib/action_view/helpers/active_record_helper.rb +276 -0
- data/lib/action_view/helpers/asset_tag_helper.rb +599 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +143 -0
- data/lib/action_view/helpers/benchmark_helper.rb +33 -0
- data/lib/action_view/helpers/cache_helper.rb +40 -0
- data/lib/action_view/helpers/capture_helper.rb +161 -0
- data/lib/action_view/helpers/date_helper.rb +711 -0
- data/lib/action_view/helpers/debug_helper.rb +31 -0
- data/lib/action_view/helpers/form_helper.rb +767 -0
- data/lib/action_view/helpers/form_options_helper.rb +458 -0
- data/lib/action_view/helpers/form_tag_helper.rb +458 -0
- data/lib/action_view/helpers/javascript_helper.rb +148 -0
- data/lib/action_view/helpers/number_helper.rb +186 -0
- 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 +229 -0
- data/lib/action_view/helpers/tag_helper.rb +134 -0
- data/lib/action_view/helpers/text_helper.rb +507 -0
- data/lib/action_view/helpers/url_helper.rb +573 -0
- data/lib/action_view/inline_template.rb +20 -0
- data/lib/action_view/partial_template.rb +70 -0
- data/lib/action_view/partials.rb +158 -0
- data/lib/action_view/template.rb +125 -0
- data/lib/action_view/template_error.rb +110 -0
- data/lib/action_view/template_finder.rb +176 -0
- data/lib/action_view/template_handler.rb +34 -0
- data/lib/action_view/template_handlers/builder.rb +27 -0
- data/lib/action_view/template_handlers/compilable.rb +128 -0
- data/lib/action_view/template_handlers/erb.rb +56 -0
- data/lib/action_view/test_case.rb +58 -0
- data/lib/actionpack.rb +1 -0
- data/test/abstract_unit.rb +36 -0
- data/test/active_record_unit.rb +105 -0
- data/test/activerecord/active_record_store_test.rb +141 -0
- data/test/activerecord/render_partial_with_record_identification_test.rb +191 -0
- data/test/adv_attr_test.rb +20 -0
- data/test/controller/action_pack_assertions_test.rb +543 -0
- data/test/controller/addresses_render_test.rb +43 -0
- data/test/controller/assert_select_test.rb +331 -0
- data/test/controller/base_test.rb +219 -0
- data/test/controller/benchmark_test.rb +32 -0
- data/test/controller/caching_test.rb +581 -0
- data/test/controller/capture_test.rb +89 -0
- data/test/controller/cgi_test.rb +116 -0
- data/test/controller/components_test.rb +140 -0
- data/test/controller/content_type_test.rb +139 -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 +146 -0
- data/test/controller/custom_handler_test.rb +45 -0
- data/test/controller/deprecation/deprecated_base_methods_test.rb +37 -0
- data/test/controller/dispatcher_test.rb +105 -0
- data/test/controller/fake_controllers.rb +33 -0
- data/test/controller/fake_models.rb +11 -0
- data/test/controller/filter_params_test.rb +49 -0
- data/test/controller/filters_test.rb +881 -0
- data/test/controller/flash_test.rb +146 -0
- data/test/controller/header_test.rb +14 -0
- data/test/controller/helper_test.rb +210 -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 +269 -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_authentication_test.rb +54 -0
- data/test/controller/integration_test.rb +252 -0
- data/test/controller/integration_upload_test.rb +43 -0
- data/test/controller/layout_test.rb +255 -0
- data/test/controller/mime_responds_test.rb +514 -0
- data/test/controller/mime_type_test.rb +84 -0
- data/test/controller/new_render_test.rb +843 -0
- data/test/controller/polymorphic_routes_test.rb +174 -0
- data/test/controller/record_identifier_test.rb +139 -0
- data/test/controller/redirect_test.rb +289 -0
- data/test/controller/render_test.rb +484 -0
- data/test/controller/request_forgery_protection_test.rb +305 -0
- data/test/controller/request_test.rb +928 -0
- data/test/controller/rescue_test.rb +517 -0
- data/test/controller/resources_test.rb +873 -0
- data/test/controller/routing_test.rb +2464 -0
- data/test/controller/selector_test.rb +628 -0
- data/test/controller/send_file_test.rb +138 -0
- data/test/controller/session/cookie_store_test.rb +258 -0
- data/test/controller/session/mem_cache_store_test.rb +181 -0
- data/test/controller/session_fixation_test.rb +89 -0
- data/test/controller/session_management_test.rb +178 -0
- data/test/controller/test_test.rb +695 -0
- data/test/controller/url_rewriter_test.rb +310 -0
- data/test/controller/verification_test.rb +270 -0
- data/test/controller/view_paths_test.rb +140 -0
- data/test/controller/webservice_test.rb +229 -0
- data/test/fixtures/addresses/list.erb +1 -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_js.js.erb +1 -0
- data/test/fixtures/content_type/render_default_for_rhtml.rhtml +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_projects.yml +13 -0
- data/test/fixtures/fun/games/hello_world.erb +1 -0
- data/test/fixtures/functional_caching/_partial.erb +3 -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/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/alt/hello.rhtml +1 -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/block_with_layout.erb +3 -0
- data/test/fixtures/layouts/builder.builder +3 -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/yield.erb +2 -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/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/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/public/404.html +1 -0
- data/test/fixtures/public/500.html +1 -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/robber.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/version.1.0.css +1 -0
- data/test/fixtures/replies.yml +15 -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/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/shared.html.erb +1 -0
- data/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
- data/test/fixtures/test/_customer.erb +1 -0
- data/test/fixtures/test/_customer_counter.erb +1 -0
- data/test/fixtures/test/_customer_greeting.erb +1 -0
- data/test/fixtures/test/_form.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_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.erb +1 -0
- data/test/fixtures/test/_person.erb +2 -0
- data/test/fixtures/test/_raise.html.erb +1 -0
- data/test/fixtures/test/action_talk_to_layout.erb +2 -0
- data/test/fixtures/test/block_content_for.erb +2 -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/dot.directory/render_file_with_ivar.erb +1 -0
- data/test/fixtures/test/enum_rjs_test.rjs +6 -0
- data/test/fixtures/test/erb_content_for.erb +2 -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.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/list.erb +1 -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_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_to_string_test.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/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_test.rb +268 -0
- data/test/template/asset_tag_helper_test.rb +514 -0
- data/test/template/atom_feed_helper_test.rb +179 -0
- data/test/template/benchmark_helper_test.rb +60 -0
- data/test/template/date_helper_test.rb +1791 -0
- data/test/template/deprecated_erb_variable_test.rb +9 -0
- data/test/template/erb_util_test.rb +24 -0
- data/test/template/form_helper_test.rb +885 -0
- data/test/template/form_options_helper_test.rb +1333 -0
- data/test/template/form_tag_helper_test.rb +272 -0
- data/test/template/javascript_helper_test.rb +73 -0
- data/test/template/number_helper_test.rb +97 -0
- data/test/template/record_tag_helper_test.rb +54 -0
- data/test/template/sanitize_helper_test.rb +48 -0
- data/test/template/tag_helper_test.rb +77 -0
- data/test/template/template_finder_test.rb +73 -0
- data/test/template/template_object_test.rb +95 -0
- data/test/template/test_test.rb +56 -0
- data/test/template/text_helper_test.rb +367 -0
- data/test/template/url_helper_test.rb +544 -0
- data/test/testing_sandbox.rb +15 -0
- metadata +469 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
require 'abstract_unit'
|
|
2
|
+
require 'controller/fake_models'
|
|
3
|
+
|
|
4
|
+
module Fun
|
|
5
|
+
class GamesController < ActionController::Base
|
|
6
|
+
def hello_world
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# FIXME: crashes Ruby 1.9
|
|
13
|
+
class TestController < ActionController::Base
|
|
14
|
+
layout :determine_layout
|
|
15
|
+
|
|
16
|
+
def hello_world
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def render_hello_world
|
|
20
|
+
render :template => "test/hello_world"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def render_hello_world_with_forward_slash
|
|
24
|
+
render :template => "/test/hello_world"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def render_template_in_top_directory
|
|
28
|
+
render :template => 'shared'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def render_template_in_top_directory_with_slash
|
|
32
|
+
render :template => '/shared'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def render_hello_world_from_variable
|
|
36
|
+
@person = "david"
|
|
37
|
+
render :text => "hello #{@person}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def render_action_hello_world
|
|
41
|
+
render :action => "hello_world"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def render_action_hello_world_with_symbol
|
|
45
|
+
render :action => :hello_world
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def render_text_hello_world
|
|
49
|
+
render :text => "hello world"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def render_json_hello_world
|
|
53
|
+
render :json => {:hello => 'world'}.to_json
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def render_json_hello_world_with_callback
|
|
57
|
+
render :json => {:hello => 'world'}.to_json, :callback => 'alert'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def render_json_with_custom_content_type
|
|
61
|
+
render :json => {:hello => 'world'}.to_json, :content_type => 'text/javascript'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def render_symbol_json
|
|
65
|
+
render :json => {:hello => 'world'}.to_json
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def render_custom_code
|
|
69
|
+
render :text => "hello world", :status => 404
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def render_text_with_nil
|
|
73
|
+
render :text => nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def render_text_with_false
|
|
77
|
+
render :text => false
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def render_nothing_with_appendix
|
|
81
|
+
render :text => "appended"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def render_invalid_args
|
|
85
|
+
render("test/hello")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def render_xml_hello
|
|
89
|
+
@name = "David"
|
|
90
|
+
render :template => "test/hello"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def render_xml_with_custom_content_type
|
|
94
|
+
render :xml => "<blah/>", :content_type => "application/atomsvc+xml"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def render_line_offset
|
|
98
|
+
begin
|
|
99
|
+
render :inline => '<% raise %>', :locals => {:foo => 'bar'}
|
|
100
|
+
rescue RuntimeError => exc
|
|
101
|
+
end
|
|
102
|
+
line = exc.backtrace.first
|
|
103
|
+
render :text => line
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def heading
|
|
107
|
+
head :ok
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def greeting
|
|
111
|
+
# let's just rely on the template
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def layout_test
|
|
115
|
+
render :action => "hello_world"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def builder_layout_test
|
|
119
|
+
render :action => "hello"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def builder_partial_test
|
|
123
|
+
render :action => "hello_world_container"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def partials_list
|
|
127
|
+
@test_unchanged = 'hello'
|
|
128
|
+
@customers = [ Customer.new("david"), Customer.new("mary") ]
|
|
129
|
+
render :action => "list"
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def partial_only
|
|
133
|
+
render :partial => true
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def hello_in_a_string
|
|
137
|
+
@customers = [ Customer.new("david"), Customer.new("mary") ]
|
|
138
|
+
render :text => "How's there? " + render_to_string(:template => "test/list")
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def accessing_params_in_template
|
|
142
|
+
render :inline => "Hello: <%= params[:name] %>"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def accessing_local_assigns_in_inline_template
|
|
146
|
+
name = params[:local_name]
|
|
147
|
+
render :inline => "<%= 'Goodbye, ' + local_name %>",
|
|
148
|
+
:locals => { :local_name => name }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def formatted_html_erb
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def formatted_xml_erb
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def render_to_string_test
|
|
158
|
+
@foo = render_to_string :inline => "this is a test"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def partial
|
|
162
|
+
render :partial => 'partial'
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def partial_dot_html
|
|
166
|
+
render :partial => 'partial.html.erb'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def default_render
|
|
170
|
+
if @alternate_default_render
|
|
171
|
+
@alternate_default_render.call
|
|
172
|
+
else
|
|
173
|
+
render
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def render_alternate_default
|
|
178
|
+
# For this test, the method "default_render" is overridden:
|
|
179
|
+
@alternate_default_render = lambda {
|
|
180
|
+
render :update do |page|
|
|
181
|
+
page.replace :foo, :partial => 'partial'
|
|
182
|
+
end
|
|
183
|
+
}
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def rescue_action(e) raise end
|
|
187
|
+
|
|
188
|
+
private
|
|
189
|
+
def determine_layout
|
|
190
|
+
case action_name
|
|
191
|
+
when "layout_test"; "layouts/standard"
|
|
192
|
+
when "builder_layout_test"; "layouts/builder"
|
|
193
|
+
when "render_symbol_json"; "layouts/standard" # to make sure layouts don't interfere
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
TestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
|
199
|
+
Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
|
200
|
+
|
|
201
|
+
class RenderTest < Test::Unit::TestCase
|
|
202
|
+
def setup
|
|
203
|
+
@request = ActionController::TestRequest.new
|
|
204
|
+
@response = ActionController::TestResponse.new
|
|
205
|
+
@controller = TestController.new
|
|
206
|
+
|
|
207
|
+
@request.host = "www.nextangle.com"
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_simple_show
|
|
211
|
+
get :hello_world
|
|
212
|
+
assert_response 200
|
|
213
|
+
assert_template "test/hello_world"
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_render
|
|
217
|
+
get :render_hello_world
|
|
218
|
+
assert_template "test/hello_world"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_line_offset
|
|
222
|
+
get :render_line_offset
|
|
223
|
+
line = @response.body
|
|
224
|
+
assert(line =~ %r{:(\d+):})
|
|
225
|
+
assert_equal "1", $1
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def test_render_with_forward_slash
|
|
229
|
+
get :render_hello_world_with_forward_slash
|
|
230
|
+
assert_template "test/hello_world"
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def test_render_in_top_directory
|
|
234
|
+
get :render_template_in_top_directory
|
|
235
|
+
assert_template "shared"
|
|
236
|
+
assert_equal "Elastica", @response.body
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def test_render_in_top_directory_with_slash
|
|
240
|
+
get :render_template_in_top_directory_with_slash
|
|
241
|
+
assert_template "shared"
|
|
242
|
+
assert_equal "Elastica", @response.body
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def test_render_from_variable
|
|
246
|
+
get :render_hello_world_from_variable
|
|
247
|
+
assert_equal "hello david", @response.body
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def test_render_action
|
|
251
|
+
get :render_action_hello_world
|
|
252
|
+
assert_template "test/hello_world"
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def test_render_action_with_symbol
|
|
256
|
+
get :render_action_hello_world_with_symbol
|
|
257
|
+
assert_template "test/hello_world"
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def test_render_text
|
|
261
|
+
get :render_text_hello_world
|
|
262
|
+
assert_equal "hello world", @response.body
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def test_render_json
|
|
266
|
+
get :render_json_hello_world
|
|
267
|
+
assert_equal '{"hello": "world"}', @response.body
|
|
268
|
+
assert_equal 'application/json', @response.content_type
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def test_render_json_with_callback
|
|
272
|
+
get :render_json_hello_world_with_callback
|
|
273
|
+
assert_equal 'alert({"hello": "world"})', @response.body
|
|
274
|
+
assert_equal 'application/json', @response.content_type
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def test_render_json_with_custom_content_type
|
|
278
|
+
get :render_json_with_custom_content_type
|
|
279
|
+
assert_equal '{"hello": "world"}', @response.body
|
|
280
|
+
assert_equal 'text/javascript', @response.content_type
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def test_render_symbol_json
|
|
284
|
+
get :render_symbol_json
|
|
285
|
+
assert_equal '{"hello": "world"}', @response.body
|
|
286
|
+
assert_equal 'application/json', @response.content_type
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def test_render_custom_code
|
|
290
|
+
get :render_custom_code
|
|
291
|
+
assert_response 404
|
|
292
|
+
assert_equal 'hello world', @response.body
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def test_render_text_with_nil
|
|
296
|
+
get :render_text_with_nil
|
|
297
|
+
assert_response 200
|
|
298
|
+
assert_equal '', @response.body
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def test_render_text_with_false
|
|
302
|
+
get :render_text_with_false
|
|
303
|
+
assert_equal 'false', @response.body
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_render_nothing_with_appendix
|
|
307
|
+
get :render_nothing_with_appendix
|
|
308
|
+
assert_response 200
|
|
309
|
+
assert_equal 'appended', @response.body
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def test_attempt_to_render_with_invalid_arguments
|
|
313
|
+
assert_raises(ActionController::RenderError) { get :render_invalid_args }
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def test_attempt_to_access_object_method
|
|
317
|
+
assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def test_private_methods
|
|
321
|
+
assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def test_render_xml
|
|
325
|
+
get :render_xml_hello
|
|
326
|
+
assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
|
|
327
|
+
assert_equal "application/xml", @response.content_type
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def test_render_xml_with_default
|
|
331
|
+
get :greeting
|
|
332
|
+
assert_equal "<p>This is grand!</p>\n", @response.body
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def test_render_xml_with_partial
|
|
336
|
+
get :builder_partial_test
|
|
337
|
+
assert_equal "<test>\n <hello/>\n</test>\n", @response.body
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def test_layout_rendering
|
|
341
|
+
get :layout_test
|
|
342
|
+
assert_equal "<html>Hello world!</html>", @response.body
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def test_render_xml_with_layouts
|
|
346
|
+
get :builder_layout_test
|
|
347
|
+
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# def test_partials_list
|
|
351
|
+
# get :partials_list
|
|
352
|
+
# assert_equal "goodbyeHello: davidHello: marygoodbye\n", process_request.body
|
|
353
|
+
# end
|
|
354
|
+
|
|
355
|
+
def test_partial_only
|
|
356
|
+
get :partial_only
|
|
357
|
+
assert_equal "only partial", @response.body
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def test_render_to_string
|
|
361
|
+
get :hello_in_a_string
|
|
362
|
+
assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def test_render_to_string_resets_assigns
|
|
366
|
+
get :render_to_string_test
|
|
367
|
+
assert_equal "The value of foo is: ::this is a test::\n", @response.body
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def test_nested_rendering
|
|
371
|
+
@controller = Fun::GamesController.new
|
|
372
|
+
get :hello_world
|
|
373
|
+
assert_equal "Living in a nested world", @response.body
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def test_accessing_params_in_template
|
|
377
|
+
get :accessing_params_in_template, :name => "David"
|
|
378
|
+
assert_equal "Hello: David", @response.body
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def test_accessing_local_assigns_in_inline_template
|
|
382
|
+
get :accessing_local_assigns_in_inline_template, :local_name => "Local David"
|
|
383
|
+
assert_equal "Goodbye, Local David", @response.body
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
def test_render_200_should_set_etag
|
|
387
|
+
get :render_hello_world_from_variable
|
|
388
|
+
assert_equal etag_for("hello david"), @response.headers['ETag']
|
|
389
|
+
assert_equal "private, max-age=0, must-revalidate", @response.headers['Cache-Control']
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def test_render_against_etag_request_should_304_when_match
|
|
393
|
+
@request.headers["HTTP_IF_NONE_MATCH"] = etag_for("hello david")
|
|
394
|
+
get :render_hello_world_from_variable
|
|
395
|
+
assert_equal "304 Not Modified", @response.headers['Status']
|
|
396
|
+
assert @response.body.empty?
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def test_render_against_etag_request_should_200_when_no_match
|
|
400
|
+
@request.headers["HTTP_IF_NONE_MATCH"] = etag_for("hello somewhere else")
|
|
401
|
+
get :render_hello_world_from_variable
|
|
402
|
+
assert_equal "200 OK", @response.headers['Status']
|
|
403
|
+
assert !@response.body.empty?
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def test_render_with_etag
|
|
407
|
+
get :render_hello_world_from_variable
|
|
408
|
+
expected_etag = etag_for('hello david')
|
|
409
|
+
assert_equal expected_etag, @response.headers['ETag']
|
|
410
|
+
|
|
411
|
+
@request.headers["HTTP_IF_NONE_MATCH"] = expected_etag
|
|
412
|
+
get :render_hello_world_from_variable
|
|
413
|
+
assert_equal "304 Not Modified", @response.headers['Status']
|
|
414
|
+
|
|
415
|
+
@request.headers["HTTP_IF_NONE_MATCH"] = "\"diftag\""
|
|
416
|
+
get :render_hello_world_from_variable
|
|
417
|
+
assert_equal "200 OK", @response.headers['Status']
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
def render_with_404_shouldnt_have_etag
|
|
421
|
+
get :render_custom_code
|
|
422
|
+
assert_nil @response.headers['ETag']
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def test_etag_should_not_be_changed_when_already_set
|
|
426
|
+
expected_etag = etag_for("hello somewhere else")
|
|
427
|
+
@response.headers["ETag"] = expected_etag
|
|
428
|
+
get :render_hello_world_from_variable
|
|
429
|
+
assert_equal expected_etag, @response.headers['ETag']
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
def test_etag_should_govern_renders_with_layouts_too
|
|
433
|
+
get :builder_layout_test
|
|
434
|
+
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
|
|
435
|
+
assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag']
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
def test_should_render_formatted_template
|
|
439
|
+
get :formatted_html_erb
|
|
440
|
+
assert_equal 'formatted html erb', @response.body
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def test_should_render_formatted_xml_erb_template
|
|
444
|
+
get :formatted_xml_erb, :format => :xml
|
|
445
|
+
assert_equal '<test>passed formatted xml erb</test>', @response.body
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def test_should_render_formatted_html_erb_template
|
|
449
|
+
get :formatted_xml_erb
|
|
450
|
+
assert_equal '<test>passed formatted html erb</test>', @response.body
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
def test_should_render_formatted_html_erb_template_with_faulty_accepts_header
|
|
454
|
+
@request.env["HTTP_ACCEPT"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*"
|
|
455
|
+
get :formatted_xml_erb
|
|
456
|
+
assert_equal '<test>passed formatted html erb</test>', @response.body
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
def test_should_render_html_formatted_partial
|
|
460
|
+
get :partial
|
|
461
|
+
assert_equal 'partial html', @response.body
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def test_should_render_html_partial_with_dot
|
|
465
|
+
get :partial_dot_html
|
|
466
|
+
assert_equal 'partial html', @response.body
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def test_should_render_js_partial
|
|
470
|
+
xhr :get, :partial, :format => 'js'
|
|
471
|
+
assert_equal 'partial js', @response.body
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def test_should_render_xml_but_keep_custom_content_type
|
|
475
|
+
get :render_xml_with_custom_content_type
|
|
476
|
+
assert_equal "application/atomsvc+xml", @response.content_type
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
protected
|
|
480
|
+
|
|
481
|
+
def etag_for(text)
|
|
482
|
+
%("#{Digest::MD5.hexdigest(text)}")
|
|
483
|
+
end
|
|
484
|
+
end
|