actionpack 1.13.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +1400 -20
- data/MIT-LICENSE +1 -1
- data/README +5 -5
- data/RUNNING_UNIT_TESTS +4 -5
- data/Rakefile +5 -6
- data/install.rb +2 -2
- data/lib/action_controller.rb +11 -15
- data/lib/action_controller/assertions.rb +12 -25
- data/lib/action_controller/assertions/dom_assertions.rb +18 -4
- data/lib/action_controller/assertions/model_assertions.rb +8 -1
- data/lib/action_controller/assertions/response_assertions.rb +35 -12
- data/lib/action_controller/assertions/routing_assertions.rb +56 -12
- data/lib/action_controller/assertions/selector_assertions.rb +105 -38
- data/lib/action_controller/assertions/tag_assertions.rb +28 -15
- data/lib/action_controller/base.rb +318 -250
- data/lib/action_controller/benchmarking.rb +33 -29
- data/lib/action_controller/caching.rb +130 -64
- data/lib/action_controller/cgi_ext.rb +16 -0
- data/lib/action_controller/cgi_ext/{cookie_performance_fix.rb → cookie.rb} +25 -40
- data/lib/action_controller/cgi_ext/query_extension.rb +22 -0
- data/lib/action_controller/cgi_ext/session.rb +73 -0
- data/lib/action_controller/cgi_ext/stdinput.rb +23 -0
- data/lib/action_controller/cgi_process.rb +34 -57
- data/lib/action_controller/components.rb +19 -36
- data/lib/action_controller/cookies.rb +10 -9
- data/lib/action_controller/dispatcher.rb +195 -0
- data/lib/action_controller/filters.rb +35 -34
- data/lib/action_controller/flash.rb +30 -35
- data/lib/action_controller/helpers.rb +121 -47
- data/lib/action_controller/http_authentication.rb +126 -0
- data/lib/action_controller/integration.rb +105 -101
- data/lib/action_controller/layout.rb +59 -47
- data/lib/action_controller/mime_responds.rb +57 -68
- data/lib/action_controller/mime_type.rb +43 -80
- data/lib/action_controller/mime_types.rb +20 -0
- data/lib/action_controller/polymorphic_routes.rb +88 -0
- data/lib/action_controller/record_identifier.rb +91 -0
- data/lib/action_controller/request.rb +553 -88
- data/lib/action_controller/request_forgery_protection.rb +126 -0
- data/lib/action_controller/request_profiler.rb +138 -0
- data/lib/action_controller/rescue.rb +185 -69
- data/lib/action_controller/resources.rb +211 -172
- data/lib/action_controller/response.rb +49 -8
- data/lib/action_controller/routing.rb +359 -236
- data/lib/action_controller/routing_optimisation.rb +119 -0
- data/lib/action_controller/session/active_record_store.rb +3 -2
- data/lib/action_controller/session/cookie_store.rb +161 -0
- data/lib/action_controller/session/mem_cache_store.rb +9 -16
- data/lib/action_controller/session_management.rb +17 -8
- data/lib/action_controller/streaming.rb +6 -3
- data/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
- data/lib/action_controller/templates/rescues/{_trace.rhtml → _trace.erb} +0 -0
- data/lib/action_controller/templates/rescues/{diagnostics.rhtml → diagnostics.erb} +2 -2
- data/lib/action_controller/templates/rescues/{layout.rhtml → layout.erb} +0 -0
- data/lib/action_controller/templates/rescues/{missing_template.rhtml → missing_template.erb} +0 -0
- data/lib/action_controller/templates/rescues/{routing_error.rhtml → routing_error.erb} +0 -0
- data/lib/action_controller/templates/rescues/{template_error.rhtml → template_error.erb} +2 -2
- data/lib/action_controller/templates/rescues/{unknown_action.rhtml → unknown_action.erb} +0 -0
- data/lib/action_controller/test_case.rb +53 -0
- data/lib/action_controller/test_process.rb +59 -46
- data/lib/action_controller/url_rewriter.rb +48 -24
- data/lib/action_controller/vendor/html-scanner/html/document.rb +7 -4
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +11 -6
- data/lib/action_controller/verification.rb +27 -21
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +4 -4
- data/lib/action_view.rb +2 -3
- data/lib/action_view/base.rb +218 -63
- data/lib/action_view/compiled_templates.rb +1 -2
- data/lib/action_view/helpers/active_record_helper.rb +35 -17
- data/lib/action_view/helpers/asset_tag_helper.rb +395 -87
- data/lib/action_view/helpers/atom_feed_helper.rb +111 -0
- data/lib/action_view/helpers/benchmark_helper.rb +12 -5
- data/lib/action_view/helpers/cache_helper.rb +29 -0
- data/lib/action_view/helpers/capture_helper.rb +97 -63
- data/lib/action_view/helpers/date_helper.rb +295 -35
- data/lib/action_view/helpers/debug_helper.rb +6 -2
- data/lib/action_view/helpers/form_helper.rb +354 -111
- data/lib/action_view/helpers/form_options_helper.rb +171 -109
- data/lib/action_view/helpers/form_tag_helper.rb +332 -76
- data/lib/action_view/helpers/javascript_helper.rb +35 -11
- data/lib/action_view/helpers/javascripts/controls.js +484 -354
- data/lib/action_view/helpers/javascripts/dragdrop.js +88 -58
- data/lib/action_view/helpers/javascripts/effects.js +396 -364
- data/lib/action_view/helpers/javascripts/prototype.js +2817 -1107
- data/lib/action_view/helpers/number_helper.rb +84 -60
- data/lib/action_view/helpers/prototype_helper.rb +419 -43
- data/lib/action_view/helpers/record_identification_helper.rb +20 -0
- data/lib/action_view/helpers/record_tag_helper.rb +59 -0
- data/lib/action_view/helpers/sanitize_helper.rb +223 -0
- data/lib/action_view/helpers/scriptaculous_helper.rb +63 -4
- data/lib/action_view/helpers/tag_helper.rb +69 -39
- data/lib/action_view/helpers/text_helper.rb +221 -148
- data/lib/action_view/helpers/url_helper.rb +283 -165
- data/lib/action_view/partials.rb +134 -62
- data/lib/action_view/template_error.rb +4 -12
- data/lib/actionpack.rb +1 -0
- data/test/abstract_unit.rb +21 -1
- data/test/action_view_test.rb +26 -0
- data/test/active_record_unit.rb +12 -20
- data/test/activerecord/active_record_store_test.rb +2 -2
- data/test/activerecord/render_partial_with_record_identification_test.rb +74 -0
- data/test/controller/action_pack_assertions_test.rb +21 -152
- data/test/controller/addresses_render_test.rb +2 -7
- data/test/controller/assert_select_test.rb +120 -14
- data/test/controller/base_test.rb +11 -13
- data/test/controller/caching_test.rb +125 -5
- data/test/controller/capture_test.rb +23 -16
- data/test/controller/cgi_test.rb +66 -391
- data/test/controller/components_test.rb +31 -42
- data/test/controller/content_type_test.rb +1 -1
- data/test/controller/cookie_test.rb +42 -14
- data/test/controller/deprecation/deprecated_base_methods_test.rb +1 -42
- data/test/controller/dispatcher_test.rb +123 -0
- data/test/controller/fake_models.rb +5 -0
- data/test/controller/filters_test.rb +44 -7
- data/test/controller/flash_test.rb +46 -2
- data/test/controller/fragment_store_setting_test.rb +10 -8
- data/test/controller/helper_test.rb +19 -2
- data/test/controller/html-scanner/document_test.rb +124 -0
- data/test/controller/html-scanner/node_test.rb +69 -0
- data/test/controller/html-scanner/sanitizer_test.rb +250 -0
- data/test/controller/html-scanner/tag_node_test.rb +239 -0
- data/test/controller/html-scanner/text_node_test.rb +51 -0
- data/test/controller/html-scanner/tokenizer_test.rb +125 -0
- data/test/controller/http_authentication_test.rb +54 -0
- data/test/controller/integration_test.rb +12 -26
- data/test/controller/layout_test.rb +64 -12
- data/test/controller/mime_responds_test.rb +193 -38
- data/test/controller/mime_type_test.rb +30 -8
- data/test/controller/new_render_test.rb +104 -22
- data/test/controller/polymorphic_routes_test.rb +98 -0
- data/test/controller/record_identifier_test.rb +103 -0
- data/test/controller/redirect_test.rb +120 -18
- data/test/controller/render_test.rb +195 -45
- data/test/controller/request_forgery_protection_test.rb +217 -0
- data/test/controller/request_test.rb +545 -27
- data/test/controller/rescue_test.rb +501 -0
- data/test/controller/resources_test.rb +258 -132
- data/test/controller/routing_test.rb +502 -106
- data/test/controller/selector_test.rb +5 -5
- data/test/controller/send_file_test.rb +17 -7
- data/test/controller/session/cookie_store_test.rb +246 -0
- data/test/controller/session/mem_cache_store_test.rb +182 -0
- data/test/controller/session_fixation_test.rb +8 -11
- data/test/controller/session_management_test.rb +7 -7
- data/test/controller/test_test.rb +150 -38
- data/test/controller/url_rewriter_test.rb +87 -12
- data/test/controller/verification_test.rb +11 -0
- data/test/controller/view_paths_test.rb +137 -0
- data/test/controller/webservice_test.rb +11 -75
- data/test/fixtures/addresses/{list.rhtml → list.erb} +0 -0
- data/test/fixtures/db_definitions/sqlite.sql +2 -1
- data/test/fixtures/developer.rb +2 -0
- data/test/fixtures/fun/games/{hello_world.rhtml → hello_world.erb} +0 -0
- data/test/fixtures/helpers/fun/pdf_helper.rb +1 -1
- data/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/test/fixtures/layouts/{builder.rxml → builder.builder} +0 -0
- data/test/fixtures/layouts/{standard.rhtml → standard.erb} +0 -0
- data/test/fixtures/layouts/{talk_from_action.rhtml → talk_from_action.erb} +0 -0
- data/test/fixtures/layouts/{yield.rhtml → yield.erb} +0 -0
- data/test/fixtures/multipart/binary_file +0 -0
- data/test/fixtures/multipart/bracketed_param +5 -0
- data/test/fixtures/override/test/hello_world.erb +1 -0
- data/test/fixtures/override2/layouts/test/sub.erb +1 -0
- data/test/fixtures/post_test/layouts/post.html.erb +1 -0
- data/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
- data/test/fixtures/post_test/post/index.html.erb +1 -0
- data/test/fixtures/post_test/post/index.iphone.erb +1 -0
- data/test/fixtures/post_test/super_post/index.html.erb +1 -0
- data/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
- data/test/fixtures/public/404.html +1 -0
- data/test/fixtures/public/500.html +1 -0
- data/test/fixtures/public/javascripts/application.js +0 -1
- data/test/fixtures/public/javascripts/bank.js +1 -0
- data/test/fixtures/public/javascripts/robber.js +1 -0
- data/test/fixtures/public/stylesheets/bank.css +1 -0
- data/test/fixtures/public/stylesheets/robber.css +1 -0
- data/test/fixtures/replies.yml +2 -0
- data/test/fixtures/reply.rb +2 -1
- data/test/fixtures/respond_to/{all_types_with_layout.rhtml → all_types_with_layout.html.erb} +0 -0
- data/test/fixtures/respond_to/{all_types_with_layout.rjs → all_types_with_layout.js.rjs} +0 -0
- data/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
- data/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
- data/test/fixtures/respond_to/{using_defaults.rhtml → using_defaults.html.erb} +0 -0
- data/test/fixtures/respond_to/{using_defaults.rjs → using_defaults.js.rjs} +0 -0
- data/test/fixtures/respond_to/{using_defaults.rxml → using_defaults.xml.builder} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rhtml → using_defaults_with_type_list.html.erb} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rjs → using_defaults_with_type_list.js.rjs} +0 -0
- data/test/fixtures/respond_to/{using_defaults_with_type_list.rxml → using_defaults_with_type_list.xml.builder} +0 -0
- data/test/fixtures/scope/test/{modgreet.rhtml → modgreet.erb} +0 -0
- data/test/fixtures/test/{_customer.rhtml → _customer.erb} +0 -0
- data/test/fixtures/test/{_customer_greeting.rhtml → _customer_greeting.erb} +0 -0
- data/test/fixtures/test/_hash_greeting.erb +1 -0
- data/test/fixtures/test/_hash_object.erb +2 -0
- data/test/fixtures/test/{_hello.rxml → _hello.builder} +0 -0
- data/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/test/fixtures/test/_partial.erb +1 -0
- data/test/fixtures/test/_partial.html.erb +1 -0
- data/test/fixtures/test/_partial.js.erb +1 -0
- data/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
- data/test/fixtures/test/{_partial_only.rhtml → _partial_only.erb} +0 -0
- data/test/fixtures/test/{_person.rhtml → _person.erb} +0 -0
- data/test/fixtures/test/{action_talk_to_layout.rhtml → action_talk_to_layout.erb} +0 -0
- data/test/fixtures/test/{block_content_for.rhtml → block_content_for.erb} +0 -0
- data/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/test/fixtures/test/{capturing.rhtml → capturing.erb} +0 -0
- data/test/fixtures/test/{content_for.rhtml → content_for.erb} +0 -0
- data/test/fixtures/test/content_for_concatenated.erb +3 -0
- data/test/fixtures/test/content_for_with_parameter.erb +2 -0
- data/test/fixtures/test/dot.directory/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
- data/test/fixtures/test/{erb_content_for.rhtml → erb_content_for.erb} +0 -0
- data/test/fixtures/test/formatted_html_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.builder +1 -0
- data/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
- data/test/fixtures/test/{greeting.rhtml → greeting.erb} +0 -0
- data/test/fixtures/test/{hello.rxml → hello.builder} +0 -0
- data/test/fixtures/test/{hello_world.rxml → hello_world.builder} +0 -0
- data/test/fixtures/test/{hello_world.rhtml → hello_world.erb} +0 -0
- data/test/fixtures/test/{hello_world_container.rxml → hello_world_container.builder} +0 -0
- data/test/fixtures/test/{hello_world_with_layout_false.rhtml → hello_world_with_layout_false.erb} +0 -0
- data/test/fixtures/test/{hello_xml_world.rxml → hello_xml_world.builder} +0 -0
- data/test/fixtures/test/list.erb +1 -0
- data/test/fixtures/test/{non_erb_block_content_for.rxml → non_erb_block_content_for.builder} +0 -0
- data/test/fixtures/test/{potential_conflicts.rhtml → potential_conflicts.erb} +0 -0
- data/test/fixtures/test/{render_file_with_ivar.rhtml → render_file_with_ivar.erb} +0 -0
- data/test/fixtures/test/{render_file_with_locals.rhtml → render_file_with_locals.erb} +0 -0
- data/test/fixtures/test/{render_to_string_test.rhtml → render_to_string_test.erb} +0 -0
- data/test/fixtures/test/{update_element_with_capture.rhtml → update_element_with_capture.erb} +0 -0
- data/test/fixtures/test/using_layout_around_block.html.erb +1 -0
- data/test/fixtures/topic.rb +1 -1
- data/test/template/active_record_helper_test.rb +67 -20
- data/test/template/asset_tag_helper_test.rb +222 -54
- data/test/template/atom_feed_helper_test.rb +101 -0
- data/test/template/benchmark_helper_test.rb +2 -2
- data/test/template/compiled_templates_test.rb +76 -32
- data/test/template/date_helper_test.rb +125 -9
- data/test/template/form_helper_test.rb +326 -33
- data/test/template/form_options_helper_test.rb +822 -15
- data/test/template/form_tag_helper_test.rb +96 -30
- data/test/template/javascript_helper_test.rb +61 -13
- data/test/template/number_helper_test.rb +12 -11
- data/test/template/prototype_helper_test.rb +185 -24
- data/test/template/sanitize_helper_test.rb +49 -0
- data/test/template/scriptaculous_helper_test.rb +9 -3
- data/test/template/tag_helper_test.rb +13 -2
- data/test/template/text_helper_test.rb +38 -52
- data/test/template/url_helper_test.rb +216 -46
- metadata +144 -116
- data/examples/.htaccess +0 -24
- data/examples/address_book/index.rhtml +0 -33
- data/examples/address_book/layout.rhtml +0 -8
- data/examples/address_book_controller.cgi +0 -9
- data/examples/address_book_controller.fcgi +0 -6
- data/examples/address_book_controller.rb +0 -52
- data/examples/address_book_controller.rbx +0 -4
- data/examples/benchmark.rb +0 -52
- data/examples/benchmark_with_ar.fcgi +0 -89
- data/examples/blog_controller.cgi +0 -53
- data/examples/debate/index.rhtml +0 -14
- data/examples/debate/new_topic.rhtml +0 -22
- data/examples/debate/topic.rhtml +0 -32
- data/examples/debate_controller.cgi +0 -57
- data/lib/action_controller/assertions/deprecated_assertions.rb +0 -228
- data/lib/action_controller/cgi_ext/cgi_ext.rb +0 -36
- data/lib/action_controller/cgi_ext/cgi_methods.rb +0 -211
- data/lib/action_controller/cgi_ext/pstore_performance_fix.rb +0 -30
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +0 -95
- data/lib/action_controller/cgi_ext/session_performance_fix.rb +0 -30
- data/lib/action_controller/deprecated_dependencies.rb +0 -65
- data/lib/action_controller/deprecated_redirects.rb +0 -17
- data/lib/action_controller/deprecated_request_methods.rb +0 -34
- data/lib/action_controller/macros/auto_complete.rb +0 -53
- data/lib/action_controller/macros/in_place_editing.rb +0 -33
- data/lib/action_controller/pagination.rb +0 -408
- data/lib/action_controller/scaffolding.rb +0 -189
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -44
- data/lib/action_controller/templates/scaffolds/edit.rhtml +0 -7
- data/lib/action_controller/templates/scaffolds/layout.rhtml +0 -69
- data/lib/action_controller/templates/scaffolds/list.rhtml +0 -27
- data/lib/action_controller/templates/scaffolds/new.rhtml +0 -6
- data/lib/action_controller/templates/scaffolds/show.rhtml +0 -9
- data/lib/action_controller/vendor/xml_node.rb +0 -97
- data/lib/action_view/helpers/deprecated_helper.rb +0 -37
- data/lib/action_view/helpers/java_script_macros_helper.rb +0 -233
- data/lib/action_view/helpers/pagination_helper.rb +0 -86
- data/test/activerecord/active_record_assertions_test.rb +0 -92
- data/test/activerecord/pagination_test.rb +0 -165
- data/test/controller/deprecated_instance_variables_test.rb +0 -48
- data/test/controller/raw_post_test.rb +0 -68
- data/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_flash_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_headers_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_params_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_request_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_response_method.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml +0 -1
- data/test/fixtures/deprecated_instance_variables/_session_method.rhtml +0 -1
- data/test/fixtures/respond_to/layouts/standard.rhtml +0 -1
- data/test/fixtures/test/_hash_object.rhtml +0 -1
- data/test/fixtures/test/list.rhtml +0 -1
- data/test/template/deprecated_helper_test.rb +0 -36
- data/test/template/deprecated_instance_variables_test.rb +0 -43
- data/test/template/java_script_macros_helper_test.rb +0 -109
@@ -1,6 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
+
require File.dirname(__FILE__) + '/fake_models'
|
2
3
|
|
3
|
-
|
4
|
+
class CustomersController < ActionController::Base
|
5
|
+
end
|
4
6
|
|
5
7
|
module Fun
|
6
8
|
class GamesController < ActionController::Base
|
@@ -60,12 +62,12 @@ class NewRenderTestController < ActionController::Base
|
|
60
62
|
|
61
63
|
def render_file_with_instance_variables
|
62
64
|
@secret = 'in the sauce'
|
63
|
-
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.
|
65
|
+
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')
|
64
66
|
render :file => path
|
65
67
|
end
|
66
68
|
|
67
69
|
def render_file_with_locals
|
68
|
-
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.
|
70
|
+
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')
|
69
71
|
render :file => path, :locals => {:secret => 'in the sauce'}
|
70
72
|
end
|
71
73
|
|
@@ -150,15 +152,27 @@ class NewRenderTestController < ActionController::Base
|
|
150
152
|
def partial_with_hash_object
|
151
153
|
render :partial => "hash_object", :object => {:first_name => "Sam"}
|
152
154
|
end
|
153
|
-
|
155
|
+
|
156
|
+
def partial_hash_collection
|
157
|
+
render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ]
|
158
|
+
end
|
159
|
+
|
160
|
+
def partial_hash_collection_with_locals
|
161
|
+
render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" }
|
162
|
+
end
|
163
|
+
|
154
164
|
def partial_with_implicit_local_assignment
|
155
165
|
@customer = Customer.new("Marcel")
|
156
166
|
render :partial => "customer"
|
157
167
|
end
|
158
168
|
|
169
|
+
def missing_partial
|
170
|
+
render :partial => 'thisFileIsntHere'
|
171
|
+
end
|
172
|
+
|
159
173
|
def hello_in_a_string
|
160
174
|
@customers = [ Customer.new("david"), Customer.new("mary") ]
|
161
|
-
render :text => "How's there?
|
175
|
+
render :text => "How's there? " << render_to_string(:template => "test/list")
|
162
176
|
end
|
163
177
|
|
164
178
|
def render_to_string_with_assigns
|
@@ -197,7 +211,7 @@ class NewRenderTestController < ActionController::Base
|
|
197
211
|
end
|
198
212
|
|
199
213
|
def render_with_explicit_template
|
200
|
-
render "test/hello_world"
|
214
|
+
render :template => "test/hello_world"
|
201
215
|
end
|
202
216
|
|
203
217
|
def double_render
|
@@ -227,11 +241,11 @@ class NewRenderTestController < ActionController::Base
|
|
227
241
|
end
|
228
242
|
|
229
243
|
def hello_world_from_rxml_using_action
|
230
|
-
render :action => "hello_world.
|
244
|
+
render :action => "hello_world.builder"
|
231
245
|
end
|
232
246
|
|
233
247
|
def hello_world_from_rxml_using_template
|
234
|
-
render :template => "test/hello_world.
|
248
|
+
render :template => "test/hello_world.builder"
|
235
249
|
end
|
236
250
|
|
237
251
|
def head_with_location_header
|
@@ -258,6 +272,25 @@ class NewRenderTestController < ActionController::Base
|
|
258
272
|
head :forbidden, :x_custom_header => "something"
|
259
273
|
end
|
260
274
|
|
275
|
+
def render_with_location
|
276
|
+
render :xml => "<hello/>", :location => "http://example.com", :status => 201
|
277
|
+
end
|
278
|
+
|
279
|
+
def render_with_object_location
|
280
|
+
customer = Customer.new("Some guy", 1)
|
281
|
+
render :xml => "<customer/>", :location => customer_url(customer), :status => :created
|
282
|
+
end
|
283
|
+
|
284
|
+
def render_with_to_xml
|
285
|
+
to_xmlable = Class.new do
|
286
|
+
def to_xml
|
287
|
+
"<i-am-xml/>"
|
288
|
+
end
|
289
|
+
end.new
|
290
|
+
|
291
|
+
render :xml => to_xmlable
|
292
|
+
end
|
293
|
+
|
261
294
|
helper NewRenderTestHelper
|
262
295
|
helper do
|
263
296
|
def rjs_helper_method(value)
|
@@ -324,6 +357,14 @@ class NewRenderTestController < ActionController::Base
|
|
324
357
|
render :text => "hello world!"
|
325
358
|
end
|
326
359
|
|
360
|
+
def render_call_to_partial_with_layout
|
361
|
+
render :action => "calling_partial_with_layout"
|
362
|
+
end
|
363
|
+
|
364
|
+
def render_using_layout_around_block
|
365
|
+
render :action => "using_layout_around_block"
|
366
|
+
end
|
367
|
+
|
327
368
|
def rescue_action(e) raise end
|
328
369
|
|
329
370
|
private
|
@@ -350,8 +391,8 @@ class NewRenderTestController < ActionController::Base
|
|
350
391
|
end
|
351
392
|
end
|
352
393
|
|
353
|
-
NewRenderTestController.
|
354
|
-
Fun::GamesController.
|
394
|
+
NewRenderTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
395
|
+
Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
355
396
|
|
356
397
|
class NewRenderTest < Test::Unit::TestCase
|
357
398
|
def setup
|
@@ -460,14 +501,9 @@ class NewRenderTest < Test::Unit::TestCase
|
|
460
501
|
ActionController::Base.protected_variables_cache = nil
|
461
502
|
|
462
503
|
get :hello_world
|
463
|
-
assert assigns.include?('request'), 'request should be in assigns'
|
464
|
-
|
465
|
-
|
466
|
-
end
|
467
|
-
assert_not_deprecated do
|
468
|
-
assert_kind_of ActionController::AbstractRequest, @response.template.request
|
469
|
-
assert_kind_of ActionController::AbstractRequest, assigns['_request']
|
470
|
-
end
|
504
|
+
assert !assigns.include?('request'), 'request should not be in assigns'
|
505
|
+
assert_kind_of ActionController::AbstractRequest, assigns['_request']
|
506
|
+
assert_kind_of ActionController::AbstractRequest, @response.template.request
|
471
507
|
|
472
508
|
ensure
|
473
509
|
ActionController::Base.view_controller_internals = view_internals_old_value
|
@@ -594,7 +630,7 @@ EOS
|
|
594
630
|
end
|
595
631
|
|
596
632
|
def test_render_with_explicit_template
|
597
|
-
|
633
|
+
get :render_with_explicit_template
|
598
634
|
assert_response :success
|
599
635
|
end
|
600
636
|
|
@@ -653,7 +689,17 @@ EOS
|
|
653
689
|
|
654
690
|
def test_partial_with_hash_object
|
655
691
|
get :partial_with_hash_object
|
656
|
-
assert_equal "Sam", @response.body
|
692
|
+
assert_equal "Sam\nmaS\n", @response.body
|
693
|
+
end
|
694
|
+
|
695
|
+
def test_hash_partial_collection
|
696
|
+
get :partial_hash_collection
|
697
|
+
assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body
|
698
|
+
end
|
699
|
+
|
700
|
+
def test_partial_hash_collection_with_locals
|
701
|
+
get :partial_hash_collection_with_locals
|
702
|
+
assert_equal "Hola: PratikHola: Amy", @response.body
|
657
703
|
end
|
658
704
|
|
659
705
|
def test_partial_with_implicit_local_assignment
|
@@ -661,6 +707,12 @@ EOS
|
|
661
707
|
assert_equal "Hello: Marcel", @response.body
|
662
708
|
end
|
663
709
|
|
710
|
+
def test_render_missing_partial_template
|
711
|
+
assert_raises(ActionView::ActionViewError) do
|
712
|
+
get :missing_partial
|
713
|
+
end
|
714
|
+
end
|
715
|
+
|
664
716
|
def test_render_text_with_assigns
|
665
717
|
get :render_text_with_assigns
|
666
718
|
assert_equal "world", assigns["hello"]
|
@@ -669,14 +721,14 @@ EOS
|
|
669
721
|
def test_update_page
|
670
722
|
get :update_page
|
671
723
|
assert_template nil
|
672
|
-
assert_equal 'text/javascript; charset=utf-8', @response.headers['
|
724
|
+
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
673
725
|
assert_equal 2, @response.body.split($/).length
|
674
726
|
end
|
675
727
|
|
676
728
|
def test_update_page_with_instance_variables
|
677
729
|
get :update_page_with_instance_variables
|
678
730
|
assert_template nil
|
679
|
-
assert_equal 'text/javascript; charset=utf-8', @response.headers['
|
731
|
+
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
680
732
|
assert_match /balance/, @response.body
|
681
733
|
assert_match /\$37/, @response.body
|
682
734
|
end
|
@@ -747,4 +799,34 @@ EOS
|
|
747
799
|
assert_equal "something", @response.headers["X-Custom-Header"]
|
748
800
|
assert_response :forbidden
|
749
801
|
end
|
802
|
+
|
803
|
+
def test_rendering_with_location_should_set_header
|
804
|
+
get :render_with_location
|
805
|
+
assert_equal "http://example.com", @response.headers["Location"]
|
806
|
+
end
|
807
|
+
|
808
|
+
def test_rendering_xml_should_call_to_xml_if_possible
|
809
|
+
get :render_with_to_xml
|
810
|
+
assert_equal "<i-am-xml/>", @response.body
|
811
|
+
end
|
812
|
+
|
813
|
+
def test_rendering_with_object_location_should_set_header_with_url_for
|
814
|
+
ActionController::Routing::Routes.draw do |map|
|
815
|
+
map.resources :customers
|
816
|
+
map.connect ':controller/:action/:id'
|
817
|
+
end
|
818
|
+
|
819
|
+
get :render_with_object_location
|
820
|
+
assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
|
821
|
+
end
|
822
|
+
|
823
|
+
def test_render_call_to_partial_with_layout
|
824
|
+
get :render_call_to_partial_with_layout
|
825
|
+
assert_equal "Before (David)\nInside from partial (David)\nAfter", @response.body
|
826
|
+
end
|
827
|
+
|
828
|
+
def test_using_layout_around_block
|
829
|
+
get :using_layout_around_block
|
830
|
+
assert_equal "Before (David)\nInside from block\nAfter", @response.body
|
831
|
+
end
|
750
832
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
+
|
3
|
+
class Article
|
4
|
+
attr_reader :id
|
5
|
+
def save; @id = 1 end
|
6
|
+
def new_record?; @id.nil? end
|
7
|
+
def name
|
8
|
+
@id.nil? ? 'new post' : "post ##{@id}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Comment
|
13
|
+
attr_reader :id
|
14
|
+
def post_id; 1 end
|
15
|
+
def save; @id = 1 end
|
16
|
+
def new_record?; @id.nil? end
|
17
|
+
def name
|
18
|
+
@id.nil? ? 'new comment' : "comment ##{@id}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Comment::Nested < Comment; end
|
23
|
+
|
24
|
+
class Test::Unit::TestCase
|
25
|
+
protected
|
26
|
+
def articles_url
|
27
|
+
'http://www.example.com/articles'
|
28
|
+
end
|
29
|
+
alias_method :new_article_url, :articles_url
|
30
|
+
|
31
|
+
def article_url(article)
|
32
|
+
"http://www.example.com/articles/#{article.id}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def article_comments_url(article)
|
36
|
+
"http://www.example.com/articles/#{article.id}/comments"
|
37
|
+
end
|
38
|
+
|
39
|
+
def article_comment_url(article, comment)
|
40
|
+
"http://www.example.com/articles/#{article.id}/comments/#{comment.id}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def admin_articles_url
|
44
|
+
"http://www.example.com/admin/articles"
|
45
|
+
end
|
46
|
+
alias_method :new_admin_article_url, :admin_articles_url
|
47
|
+
|
48
|
+
def admin_article_url(article)
|
49
|
+
"http://www.example.com/admin/articles/#{article.id}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def admin_article_comments_url(article)
|
53
|
+
"http://www.example.com/admin/articles/#{article.id}/comments"
|
54
|
+
end
|
55
|
+
|
56
|
+
def admin_article_comment_url(article, comment)
|
57
|
+
"http://www.example.com/admin/test/articles/#{article.id}/comments/#{comment.id}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
class PolymorphicRoutesTest < Test::Unit::TestCase
|
63
|
+
include ActionController::PolymorphicRoutes
|
64
|
+
|
65
|
+
def setup
|
66
|
+
@article = Article.new
|
67
|
+
@comment = Comment.new
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_with_record
|
71
|
+
assert_equal(articles_url, polymorphic_url(@article, :action => 'new'))
|
72
|
+
assert_equal(articles_url, polymorphic_url(@article))
|
73
|
+
@article.save
|
74
|
+
assert_equal(article_url(@article), polymorphic_url(@article))
|
75
|
+
end
|
76
|
+
|
77
|
+
# TODO: Needs to be updated to correctly know about whether the object is in a hash or not
|
78
|
+
def xtest_with_hash
|
79
|
+
@article.save
|
80
|
+
assert_equal(article_url(@article), polymorphic_url(:id => @article))
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_with_array
|
84
|
+
assert_equal(article_comments_url(@article), polymorphic_url([@article, @comment]))
|
85
|
+
@comment.save
|
86
|
+
assert_equal(article_comment_url(@article, @comment), polymorphic_url([@article, @comment]))
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_with_array_and_namespace
|
90
|
+
assert_equal(admin_articles_url, polymorphic_url([:admin, @article], :action => 'new'))
|
91
|
+
assert_equal(admin_articles_url, polymorphic_url([:admin, @article]))
|
92
|
+
@article.save
|
93
|
+
assert_equal(admin_article_url(@article), polymorphic_url([:admin, @article]))
|
94
|
+
assert_equal(admin_article_comments_url(@article), polymorphic_url([:admin, @article, @comment]))
|
95
|
+
@comment.save
|
96
|
+
assert_equal(admin_article_comment_url(@article, @comment), polymorphic_url([:admin, @article, @comment]))
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
+
|
3
|
+
class Comment
|
4
|
+
attr_reader :id
|
5
|
+
def save; @id = 1 end
|
6
|
+
def new_record?; @id.nil? end
|
7
|
+
def name
|
8
|
+
@id.nil? ? 'new comment' : "comment ##{@id}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Comment::Nested < Comment; end
|
13
|
+
|
14
|
+
class Test::Unit::TestCase
|
15
|
+
protected
|
16
|
+
def comments_url
|
17
|
+
'http://www.example.com/comments'
|
18
|
+
end
|
19
|
+
|
20
|
+
def comment_url(comment)
|
21
|
+
"http://www.example.com/comments/#{comment.id}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
class RecordIdentifierTest < Test::Unit::TestCase
|
27
|
+
include ActionController::RecordIdentifier
|
28
|
+
|
29
|
+
def setup
|
30
|
+
@klass = Comment
|
31
|
+
@record = @klass.new
|
32
|
+
@singular = 'comment'
|
33
|
+
@plural = 'comments'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_dom_id_with_new_record
|
37
|
+
assert_equal "new_#{@singular}", dom_id(@record)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_dom_id_with_new_record_and_prefix
|
41
|
+
assert_equal "custom_prefix_#{@singular}", dom_id(@record, :custom_prefix)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_dom_id_with_saved_record
|
45
|
+
@record.save
|
46
|
+
assert_equal "#{@singular}_1", dom_id(@record)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_dom_id_with_prefix
|
50
|
+
@record.save
|
51
|
+
assert_equal "edit_#{@singular}_1", dom_id(@record, :edit)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_partial_path
|
55
|
+
expected = "#{@plural}/#{@singular}"
|
56
|
+
assert_equal expected, partial_path(@record)
|
57
|
+
assert_equal expected, partial_path(Comment)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_dom_class
|
61
|
+
assert_equal @singular, dom_class(@record)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_dom_class_with_prefix
|
65
|
+
assert_equal "custom_prefix_#{@singular}", dom_class(@record, :custom_prefix)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_singular_class_name
|
69
|
+
assert_equal @singular, singular_class_name(@record)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_singular_class_name_for_class
|
73
|
+
assert_equal @singular, singular_class_name(@klass)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_plural_class_name
|
77
|
+
assert_equal @plural, plural_class_name(@record)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_plural_class_name_for_class
|
81
|
+
assert_equal @plural, plural_class_name(@klass)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def method_missing(method, *args)
|
86
|
+
RecordIdentifier.send(method, *args)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class NestedRecordIdentifierTest < RecordIdentifierTest
|
91
|
+
def setup
|
92
|
+
@klass = Comment::Nested
|
93
|
+
@record = @klass.new
|
94
|
+
@singular = 'comment_nested'
|
95
|
+
@plural = 'comment_nesteds'
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_partial_path
|
99
|
+
expected = "comment/nesteds/nested"
|
100
|
+
assert_equal expected, partial_path(@record)
|
101
|
+
assert_equal expected, partial_path(Comment::Nested)
|
102
|
+
end
|
103
|
+
end
|
@@ -1,14 +1,57 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
2
|
|
3
|
+
class WorkshopsController < ActionController::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
class Workshop
|
7
|
+
attr_accessor :id, :new_record
|
8
|
+
|
9
|
+
def initialize(id, new_record)
|
10
|
+
@id, @new_record = id, new_record
|
11
|
+
end
|
12
|
+
|
13
|
+
def new_record?
|
14
|
+
@new_record
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
id.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
3
22
|
class RedirectController < ActionController::Base
|
4
23
|
def simple_redirect
|
5
24
|
redirect_to :action => "hello_world"
|
6
25
|
end
|
7
|
-
|
8
|
-
def
|
9
|
-
redirect_to
|
26
|
+
|
27
|
+
def redirect_with_status
|
28
|
+
redirect_to({:action => "hello_world", :status => 301})
|
29
|
+
end
|
30
|
+
|
31
|
+
def redirect_with_status_hash
|
32
|
+
redirect_to({:action => "hello_world"}, {:status => 301})
|
33
|
+
end
|
34
|
+
|
35
|
+
def url_redirect_with_status
|
36
|
+
redirect_to("http://www.example.com", :status => :moved_permanently)
|
37
|
+
end
|
38
|
+
|
39
|
+
def url_redirect_with_status_hash
|
40
|
+
redirect_to("http://www.example.com", {:status => 301})
|
41
|
+
end
|
42
|
+
|
43
|
+
def relative_url_redirect_with_status
|
44
|
+
redirect_to("/things/stuff", :status => :found)
|
45
|
+
end
|
46
|
+
|
47
|
+
def relative_url_redirect_with_status_hash
|
48
|
+
redirect_to("/things/stuff", {:status => 301})
|
49
|
+
end
|
50
|
+
|
51
|
+
def redirect_to_back_with_status
|
52
|
+
redirect_to :back, :status => 307
|
10
53
|
end
|
11
|
-
|
54
|
+
|
12
55
|
def host_redirect
|
13
56
|
redirect_to :action => "other_host", :only_path => false, :host => 'other.test.host'
|
14
57
|
end
|
@@ -26,6 +69,14 @@ class RedirectController < ActionController::Base
|
|
26
69
|
redirect_to :back
|
27
70
|
end
|
28
71
|
|
72
|
+
def redirect_to_existing_record
|
73
|
+
redirect_to Workshop.new(5, false)
|
74
|
+
end
|
75
|
+
|
76
|
+
def redirect_to_new_record
|
77
|
+
redirect_to Workshop.new(5, true)
|
78
|
+
end
|
79
|
+
|
29
80
|
def rescue_errors(e) raise e end
|
30
81
|
|
31
82
|
def rescue_action(e) raise end
|
@@ -49,10 +100,54 @@ class RedirectTest < Test::Unit::TestCase
|
|
49
100
|
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
|
50
101
|
end
|
51
102
|
|
52
|
-
def
|
53
|
-
|
54
|
-
assert_response
|
55
|
-
assert_equal "http://test.host/redirect/
|
103
|
+
def test_redirect_with_no_status
|
104
|
+
get :simple_redirect
|
105
|
+
assert_response 302
|
106
|
+
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_redirect_with_status
|
110
|
+
get :redirect_with_status
|
111
|
+
assert_response 301
|
112
|
+
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_redirect_with_status_hash
|
116
|
+
get :redirect_with_status_hash
|
117
|
+
assert_response 301
|
118
|
+
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_url_redirect_with_status
|
122
|
+
get :url_redirect_with_status
|
123
|
+
assert_response 301
|
124
|
+
assert_equal "http://www.example.com", redirect_to_url
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_url_redirect_with_status_hash
|
128
|
+
get :url_redirect_with_status_hash
|
129
|
+
assert_response 301
|
130
|
+
assert_equal "http://www.example.com", redirect_to_url
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
def test_relative_url_redirect_with_status
|
135
|
+
get :relative_url_redirect_with_status
|
136
|
+
assert_response 302
|
137
|
+
assert_equal "http://test.host/things/stuff", redirect_to_url
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_relative_url_redirect_with_status_hash
|
141
|
+
get :relative_url_redirect_with_status_hash
|
142
|
+
assert_response 301
|
143
|
+
assert_equal "http://test.host/things/stuff", redirect_to_url
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_redirect_to_back_with_status
|
147
|
+
@request.env["HTTP_REFERER"] = "http://www.example.com/coming/from"
|
148
|
+
get :redirect_to_back_with_status
|
149
|
+
assert_response 307
|
150
|
+
assert_equal "http://www.example.com/coming/from", redirect_to_url
|
56
151
|
end
|
57
152
|
|
58
153
|
def test_simple_redirect_using_options
|
@@ -67,11 +162,11 @@ class RedirectTest < Test::Unit::TestCase
|
|
67
162
|
begin
|
68
163
|
assert_redirected_to :action => "other_host", :only_path => true
|
69
164
|
rescue Test::Unit::AssertionFailedError => err
|
70
|
-
redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] }
|
165
|
+
expected_msg, redirection_msg, diff_msg = err.message.scan(/<\{[^\}]+\}>/).collect { |s| s[2..-3] }
|
71
166
|
assert_match %r("only_path"=>false), redirection_msg
|
72
167
|
assert_match %r("host"=>"other.test.host"), redirection_msg
|
73
168
|
assert_match %r("action"=>"other_host"), redirection_msg
|
74
|
-
assert_match %r("only_path"=>
|
169
|
+
assert_match %r("only_path"=>false), diff_msg
|
75
170
|
assert_match %r("host"=>"other.test.host"), diff_msg
|
76
171
|
end
|
77
172
|
end
|
@@ -107,6 +202,19 @@ class RedirectTest < Test::Unit::TestCase
|
|
107
202
|
get :redirect_to_back
|
108
203
|
}
|
109
204
|
end
|
205
|
+
|
206
|
+
def test_redirect_to_record
|
207
|
+
ActionController::Routing::Routes.draw do |map|
|
208
|
+
map.resources :workshops
|
209
|
+
map.connect ':controller/:action/:id'
|
210
|
+
end
|
211
|
+
|
212
|
+
get :redirect_to_existing_record
|
213
|
+
assert_equal "http://test.host/workshops/5", redirect_to_url
|
214
|
+
|
215
|
+
get :redirect_to_new_record
|
216
|
+
assert_equal "http://test.host/workshops", redirect_to_url
|
217
|
+
end
|
110
218
|
end
|
111
219
|
|
112
220
|
module ModuleTest
|
@@ -122,19 +230,13 @@ module ModuleTest
|
|
122
230
|
@request = ActionController::TestRequest.new
|
123
231
|
@response = ActionController::TestResponse.new
|
124
232
|
end
|
125
|
-
|
233
|
+
|
126
234
|
def test_simple_redirect
|
127
235
|
get :simple_redirect
|
128
236
|
assert_response :redirect
|
129
237
|
assert_equal "http://test.host/module_test/module_redirect/hello_world", redirect_to_url
|
130
238
|
end
|
131
|
-
|
132
|
-
def test_redirect_with_method_reference_and_parameters
|
133
|
-
assert_deprecated(/redirect_to/) { get :method_redirect }
|
134
|
-
assert_response :redirect
|
135
|
-
assert_equal "http://test.host/module_test/module_redirect/dashboard/1?message=hello", redirect_to_url
|
136
|
-
end
|
137
|
-
|
239
|
+
|
138
240
|
def test_simple_redirect_using_options
|
139
241
|
get :host_redirect
|
140
242
|
assert_response :redirect
|