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
@@ -37,6 +37,8 @@ class VerificationTest < Test::Unit::TestCase
|
|
37
37
|
verify :only => :guarded_one_for_named_route_test, :params => "one",
|
38
38
|
:redirect_to => :foo_url
|
39
39
|
|
40
|
+
verify :only => :no_default_action, :params => "santa"
|
41
|
+
|
40
42
|
def guarded_one
|
41
43
|
render :text => "#{params[:one]}"
|
42
44
|
end
|
@@ -89,6 +91,10 @@ class VerificationTest < Test::Unit::TestCase
|
|
89
91
|
render :text => "Was a post!"
|
90
92
|
end
|
91
93
|
|
94
|
+
def no_default_action
|
95
|
+
# Will never run
|
96
|
+
end
|
97
|
+
|
92
98
|
protected
|
93
99
|
def rescue_action(e) raise end
|
94
100
|
|
@@ -229,6 +235,11 @@ class VerificationTest < Test::Unit::TestCase
|
|
229
235
|
assert_equal "Was a post!", @response.body
|
230
236
|
end
|
231
237
|
|
238
|
+
def test_default_failure_should_be_a_bad_request
|
239
|
+
post :no_default_action
|
240
|
+
assert_response :bad_request
|
241
|
+
end
|
242
|
+
|
232
243
|
def test_guarded_post_and_calls_render_fails_and_sets_allow_header
|
233
244
|
get :must_be_post
|
234
245
|
assert_response 405
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
+
|
3
|
+
class ViewLoadPathsTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
6
|
+
|
7
|
+
ActionController::Base.view_paths = [ LOAD_PATH_ROOT ]
|
8
|
+
|
9
|
+
class TestController < ActionController::Base
|
10
|
+
def self.controller_path() "test" end
|
11
|
+
def rescue_action(e) raise end
|
12
|
+
|
13
|
+
before_filter :add_view_path, :only => :hello_world_at_request_time
|
14
|
+
|
15
|
+
def hello_world() end
|
16
|
+
def hello_world_at_request_time() render(:action => 'hello_world') end
|
17
|
+
private
|
18
|
+
def add_view_path
|
19
|
+
self.class.view_paths.unshift "#{LOAD_PATH_ROOT}/override"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Test::SubController < ActionController::Base
|
24
|
+
layout 'test/sub'
|
25
|
+
def hello_world; render(:template => 'test/hello_world'); end
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup
|
29
|
+
TestController.view_paths = nil
|
30
|
+
ActionView::Base.cache_template_extensions = false
|
31
|
+
@controller = TestController.new
|
32
|
+
@request = ActionController::TestRequest.new
|
33
|
+
@response = ActionController::TestResponse.new
|
34
|
+
|
35
|
+
# Track the last warning.
|
36
|
+
@old_behavior = ActiveSupport::Deprecation.behavior
|
37
|
+
@last_message = nil
|
38
|
+
ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message }
|
39
|
+
end
|
40
|
+
|
41
|
+
def teardown
|
42
|
+
ActiveSupport::Deprecation.behavior = @old_behavior
|
43
|
+
ActionView::Base.cache_template_extensions = true
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_template_load_path_was_set_correctly
|
47
|
+
assert_equal [ LOAD_PATH_ROOT ], @controller.view_paths
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_controller_appends_view_path_correctly
|
51
|
+
TestController.append_view_path 'foo'
|
52
|
+
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
53
|
+
|
54
|
+
TestController.append_view_path(%w(bar baz))
|
55
|
+
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_controller_prepends_view_path_correctly
|
59
|
+
TestController.prepend_view_path 'baz'
|
60
|
+
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
61
|
+
|
62
|
+
TestController.prepend_view_path(%w(foo bar))
|
63
|
+
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_template_appends_view_path_correctly
|
67
|
+
@controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller)
|
68
|
+
class_view_paths = TestController.view_paths
|
69
|
+
|
70
|
+
@controller.append_view_path 'foo'
|
71
|
+
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
72
|
+
|
73
|
+
@controller.append_view_path(%w(bar baz))
|
74
|
+
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
75
|
+
assert_equal class_view_paths, TestController.view_paths
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_template_prepends_view_path_correctly
|
79
|
+
@controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller)
|
80
|
+
class_view_paths = TestController.view_paths
|
81
|
+
|
82
|
+
@controller.prepend_view_path 'baz'
|
83
|
+
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
84
|
+
|
85
|
+
@controller.prepend_view_path(%w(foo bar))
|
86
|
+
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
87
|
+
assert_equal class_view_paths, TestController.view_paths
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_view_paths
|
91
|
+
get :hello_world
|
92
|
+
assert_response :success
|
93
|
+
assert_equal "Hello world!", @response.body
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_view_paths_override
|
97
|
+
TestController.view_paths.unshift "#{LOAD_PATH_ROOT}/override"
|
98
|
+
get :hello_world
|
99
|
+
assert_response :success
|
100
|
+
assert_equal "Hello overridden world!", @response.body
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_view_paths_override_for_layouts_in_controllers_with_a_module
|
104
|
+
@controller = Test::SubController.new
|
105
|
+
Test::SubController.view_paths = [ "#{LOAD_PATH_ROOT}/override", LOAD_PATH_ROOT, "#{LOAD_PATH_ROOT}/override2" ]
|
106
|
+
get :hello_world
|
107
|
+
assert_response :success
|
108
|
+
assert_equal "layout: Hello overridden world!", @response.body
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_view_paths_override_at_request_time
|
112
|
+
get :hello_world_at_request_time
|
113
|
+
assert_response :success
|
114
|
+
assert_equal "Hello overridden world!", @response.body
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_inheritance
|
118
|
+
original_load_paths = ActionController::Base.view_paths
|
119
|
+
|
120
|
+
self.class.class_eval %{
|
121
|
+
class A < ActionController::Base; end
|
122
|
+
class B < A; end
|
123
|
+
class C < ActionController::Base; end
|
124
|
+
}
|
125
|
+
|
126
|
+
A.view_paths = [ 'a/path' ]
|
127
|
+
|
128
|
+
assert_equal [ 'a/path' ], A.view_paths
|
129
|
+
assert_equal A.view_paths, B.view_paths
|
130
|
+
assert_equal original_load_paths, C.view_paths
|
131
|
+
|
132
|
+
C.view_paths = []
|
133
|
+
assert_nothing_raised { C.view_paths << 'c/path' }
|
134
|
+
assert_equal ['c/path'], C.view_paths
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -1,20 +1,16 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
-
require 'stringio'
|
3
2
|
|
4
3
|
class WebServiceTest < Test::Unit::TestCase
|
5
|
-
|
6
4
|
class MockCGI < CGI #:nodoc:
|
7
|
-
attr_accessor :
|
5
|
+
attr_accessor :stdoutput, :env_table
|
8
6
|
|
9
|
-
def initialize(env, data = '')
|
7
|
+
def initialize(env, data = '')
|
10
8
|
self.env_table = env
|
11
|
-
self.stdinput = StringIO.new(data)
|
12
9
|
self.stdoutput = StringIO.new
|
13
|
-
super()
|
10
|
+
super(nil, StringIO.new(data))
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
17
|
-
|
18
14
|
class TestController < ActionController::Base
|
19
15
|
session :off
|
20
16
|
|
@@ -40,10 +36,13 @@ class WebServiceTest < Test::Unit::TestCase
|
|
40
36
|
|
41
37
|
def setup
|
42
38
|
@controller = TestController.new
|
43
|
-
ActionController::Base.param_parsers.
|
44
|
-
ActionController::Base.param_parsers[Mime::XML] = :xml_node
|
39
|
+
@default_param_parsers = ActionController::Base.param_parsers.dup
|
45
40
|
end
|
46
|
-
|
41
|
+
|
42
|
+
def teardown
|
43
|
+
ActionController::Base.param_parsers = @default_param_parsers
|
44
|
+
end
|
45
|
+
|
47
46
|
def test_check_parameters
|
48
47
|
process('GET')
|
49
48
|
assert_equal '', @controller.response.body
|
@@ -54,7 +53,7 @@ class WebServiceTest < Test::Unit::TestCase
|
|
54
53
|
|
55
54
|
assert_equal 'entry', @controller.response.body
|
56
55
|
assert @controller.params.has_key?(:entry)
|
57
|
-
assert_equal 'content...', @controller.params["entry"]
|
56
|
+
assert_equal 'content...', @controller.params["entry"]['summary']
|
58
57
|
assert_equal 'true', @controller.params["entry"]['attributed']
|
59
58
|
end
|
60
59
|
|
@@ -63,7 +62,7 @@ class WebServiceTest < Test::Unit::TestCase
|
|
63
62
|
|
64
63
|
assert_equal 'entry', @controller.response.body
|
65
64
|
assert @controller.params.has_key?(:entry)
|
66
|
-
assert_equal 'content...', @controller.params["entry"]
|
65
|
+
assert_equal 'content...', @controller.params["entry"]['summary']
|
67
66
|
assert_equal 'true', @controller.params["entry"]['attributed']
|
68
67
|
end
|
69
68
|
|
@@ -98,15 +97,6 @@ class WebServiceTest < Test::Unit::TestCase
|
|
98
97
|
assert_nothing_raised { process('POST', 'application/xml', "") }
|
99
98
|
assert_equal "", @controller.response.body
|
100
99
|
end
|
101
|
-
|
102
|
-
def test_deprecated_request_methods
|
103
|
-
process('POST', 'application/x-yaml')
|
104
|
-
assert_equal Mime::YAML, @controller.request.content_type
|
105
|
-
assert_equal true, @controller.request.post?
|
106
|
-
assert_equal :yaml, @controller.request.post_format
|
107
|
-
assert_equal true, @controller.request.yaml_post?
|
108
|
-
assert_equal false, @controller.request.xml_post?
|
109
|
-
end
|
110
100
|
|
111
101
|
def test_dasherized_keys_as_xml
|
112
102
|
ActionController::Base.param_parsers[Mime::XML] = :xml_simple
|
@@ -192,57 +182,3 @@ class WebServiceTest < Test::Unit::TestCase
|
|
192
182
|
end
|
193
183
|
|
194
184
|
end
|
195
|
-
|
196
|
-
|
197
|
-
class XmlNodeTest < Test::Unit::TestCase
|
198
|
-
def test_all
|
199
|
-
xn = XmlNode.from_xml(%{<?xml version="1.0" encoding="UTF-8"?>
|
200
|
-
<response success='true'>
|
201
|
-
<page title='Ajax Summit' id='1133' email_address='ry87ib@backpackit.com'>
|
202
|
-
<description>With O'Reilly and Adaptive Path</description>
|
203
|
-
<notes>
|
204
|
-
<note title='Hotel' id='1020' created_at='2005-05-14 16:41:11'>
|
205
|
-
Staying at the Savoy
|
206
|
-
</note>
|
207
|
-
</notes>
|
208
|
-
<tags>
|
209
|
-
<tag name='Technology' id='4' />
|
210
|
-
<tag name='Travel' id='5' />
|
211
|
-
</tags>
|
212
|
-
</page>
|
213
|
-
</response>
|
214
|
-
}
|
215
|
-
)
|
216
|
-
assert_equal 'UTF-8', xn.node.document.encoding
|
217
|
-
assert_equal '1.0', xn.node.document.version
|
218
|
-
assert_equal 'true', xn['success']
|
219
|
-
assert_equal 'response', xn.node_name
|
220
|
-
assert_equal 'Ajax Summit', xn.page['title']
|
221
|
-
assert_equal '1133', xn.page['id']
|
222
|
-
assert_equal "With O'Reilly and Adaptive Path", xn.page.description.node_value
|
223
|
-
assert_equal nil, xn.nonexistent
|
224
|
-
assert_equal "Staying at the Savoy", xn.page.notes.note.node_value.strip
|
225
|
-
assert_equal 'Technology', xn.page.tags.tag[0]['name']
|
226
|
-
assert_equal 'Travel', xn.page.tags.tag[1][:name]
|
227
|
-
matches = xn.xpath('//@id').map{ |id| id.to_i }
|
228
|
-
assert_equal [4, 5, 1020, 1133], matches.sort
|
229
|
-
matches = xn.xpath('//tag').map{ |tag| tag['name'] }
|
230
|
-
assert_equal ['Technology', 'Travel'], matches.sort
|
231
|
-
assert_equal "Ajax Summit", xn.page['title']
|
232
|
-
xn.page['title'] = 'Ajax Summit V2'
|
233
|
-
assert_equal "Ajax Summit V2", xn.page['title']
|
234
|
-
assert_equal "Staying at the Savoy", xn.page.notes.note.node_value.strip
|
235
|
-
xn.page.notes.note.node_value = "Staying at the Ritz"
|
236
|
-
assert_equal "Staying at the Ritz", xn.page.notes.note.node_value.strip
|
237
|
-
assert_equal '5', xn.page.tags.tag[1][:id]
|
238
|
-
xn.page.tags.tag[1]['id'] = '7'
|
239
|
-
assert_equal '7', xn.page.tags.tag[1]['id']
|
240
|
-
end
|
241
|
-
|
242
|
-
|
243
|
-
def test_small_entry
|
244
|
-
node = XmlNode.from_xml('<entry>hi</entry>')
|
245
|
-
assert_equal 'hi', node.node_value
|
246
|
-
end
|
247
|
-
|
248
|
-
end
|
File without changes
|
data/test/fixtures/developer.rb
CHANGED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
alt/hello.rhtml
|
@@ -0,0 +1 @@
|
|
1
|
+
multiple_extensions.html.erb <%= yield %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello overridden world!
|
@@ -0,0 +1 @@
|
|
1
|
+
layout: <%= yield %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<html><div id="html"><%= yield %></div></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<html><div id="super_iphone"><%= yield %></div></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello Firefox
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello iPhone
|
@@ -0,0 +1 @@
|
|
1
|
+
Super Firefox
|
@@ -0,0 +1 @@
|
|
1
|
+
Super iPhone
|
@@ -0,0 +1 @@
|
|
1
|
+
404 error fixture
|
@@ -0,0 +1 @@
|
|
1
|
+
500 error fixture
|
@@ -1 +0,0 @@
|
|
1
|
-
# Test file for javascript_include_tag
|
@@ -0,0 +1 @@
|
|
1
|
+
// bank js
|
@@ -0,0 +1 @@
|
|
1
|
+
// robber js
|
@@ -0,0 +1 @@
|
|
1
|
+
/* bank.css */
|
@@ -0,0 +1 @@
|
|
1
|
+
/* robber.css */
|
data/test/fixtures/replies.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
witty_retort:
|
2
2
|
id: 1
|
3
3
|
topic_id: 1
|
4
|
+
developer_id: 1
|
4
5
|
content: Birdman is better!
|
5
6
|
created_at: <%= 6.hours.ago.to_s(:db) %>
|
6
7
|
updated_at: nil
|
@@ -8,6 +9,7 @@ witty_retort:
|
|
8
9
|
another:
|
9
10
|
id: 2
|
10
11
|
topic_id: 2
|
12
|
+
developer_id: 1
|
11
13
|
content: Nuh uh!
|
12
14
|
created_at: <%= 1.hour.ago.to_s(:db) %>
|
13
15
|
updated_at: nil
|
data/test/fixtures/reply.rb
CHANGED
data/test/fixtures/respond_to/{all_types_with_layout.rhtml → all_types_with_layout.html.erb}
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Mobile
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello future from <%= @type -%>!
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello iPhone future from <%= @type -%>!
|
@@ -0,0 +1 @@
|
|
1
|
+
<html><div id="html_missing"><%= yield %></div></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<html><div id="html"><%= yield %></div></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<html><div id="iphone"><%= yield %></div></html>
|
File without changes
|