eactionpack 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,50 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class TextNodeTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_to_s
|
9
|
+
assert_equal "hello, howdy, aloha, annyeong", @node.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_find_string
|
13
|
+
assert_equal @node, @node.find("hello, howdy, aloha, annyeong")
|
14
|
+
assert_equal false, @node.find("bogus")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_regexp
|
18
|
+
assert_equal @node, @node.find(/an+y/)
|
19
|
+
assert_nil @node.find(/b/)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_find_hash
|
23
|
+
assert_equal @node, @node.find(:content => /howdy/)
|
24
|
+
assert_nil @node.find(:content => /^howdy$/)
|
25
|
+
assert_equal false, @node.find(:content => "howdy")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_find_other
|
29
|
+
assert_nil @node.find(:hello)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_match_string
|
33
|
+
assert @node.match("hello, howdy, aloha, annyeong")
|
34
|
+
assert_equal false, @node.match("bogus")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_match_regexp
|
38
|
+
assert_not_nil @node, @node.match(/an+y/)
|
39
|
+
assert_nil @node.match(/b/)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_match_hash
|
43
|
+
assert_not_nil @node, @node.match(:content => "howdy")
|
44
|
+
assert_nil @node.match(:content => /^howdy$/)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_match_other
|
48
|
+
assert_nil @node.match(:hello)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class TokenizerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_blank
|
6
|
+
tokenize ""
|
7
|
+
assert_end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_space
|
11
|
+
tokenize " "
|
12
|
+
assert_next " "
|
13
|
+
assert_end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_tag_simple_open
|
17
|
+
tokenize "<tag>"
|
18
|
+
assert_next "<tag>"
|
19
|
+
assert_end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_tag_simple_self_closing
|
23
|
+
tokenize "<tag />"
|
24
|
+
assert_next "<tag />"
|
25
|
+
assert_end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_tag_simple_closing
|
29
|
+
tokenize "</tag>"
|
30
|
+
assert_next "</tag>"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_tag_with_single_quoted_attribute
|
34
|
+
tokenize %{<tag a='hello'>x}
|
35
|
+
assert_next %{<tag a='hello'>}
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_tag_with_single_quoted_attribute_with_escape
|
39
|
+
tokenize %{<tag a='hello\\''>x}
|
40
|
+
assert_next %{<tag a='hello\\''>}
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_tag_with_double_quoted_attribute
|
44
|
+
tokenize %{<tag a="hello">x}
|
45
|
+
assert_next %{<tag a="hello">}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_tag_with_double_quoted_attribute_with_escape
|
49
|
+
tokenize %{<tag a="hello\\"">x}
|
50
|
+
assert_next %{<tag a="hello\\"">}
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_tag_with_unquoted_attribute
|
54
|
+
tokenize %{<tag a=hello>x}
|
55
|
+
assert_next %{<tag a=hello>}
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_tag_with_lt_char_in_attribute
|
59
|
+
tokenize %{<tag a="x < y">x}
|
60
|
+
assert_next %{<tag a="x < y">}
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_tag_with_gt_char_in_attribute
|
64
|
+
tokenize %{<tag a="x > y">x}
|
65
|
+
assert_next %{<tag a="x > y">}
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_doctype_tag
|
69
|
+
tokenize %{<!DOCTYPE "blah" "blah" "blah">\n <html>}
|
70
|
+
assert_next %{<!DOCTYPE "blah" "blah" "blah">}
|
71
|
+
assert_next %{\n }
|
72
|
+
assert_next %{<html>}
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_cdata_tag
|
76
|
+
tokenize %{<![CDATA[<br>]]>}
|
77
|
+
assert_next %{<![CDATA[<br>]]>}
|
78
|
+
assert_end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_unterminated_cdata_tag
|
82
|
+
tokenize %{<content:encoded><![CDATA[ neverending...}
|
83
|
+
assert_next %{<content:encoded>}
|
84
|
+
assert_next %{<![CDATA[ neverending...}
|
85
|
+
assert_end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_less_than_with_space
|
89
|
+
tokenize %{original < hello > world}
|
90
|
+
assert_next %{original }
|
91
|
+
assert_next %{< hello > world}
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_less_than_without_matching_greater_than
|
95
|
+
tokenize %{hello <span onmouseover="gotcha"\n<b>foo</b>\nbar</span>}
|
96
|
+
assert_next %{hello }
|
97
|
+
assert_next %{<span onmouseover="gotcha"\n}
|
98
|
+
assert_next %{<b>}
|
99
|
+
assert_next %{foo}
|
100
|
+
assert_next %{</b>}
|
101
|
+
assert_next %{\nbar}
|
102
|
+
assert_next %{</span>}
|
103
|
+
assert_end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_unterminated_comment
|
107
|
+
tokenize %{hello <!-- neverending...}
|
108
|
+
assert_next %{hello }
|
109
|
+
assert_next %{<!-- neverending...}
|
110
|
+
assert_end
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def tokenize(text)
|
116
|
+
@tokenizer = HTML::Tokenizer.new(text)
|
117
|
+
end
|
118
|
+
|
119
|
+
def assert_next(expected, message=nil)
|
120
|
+
token = @tokenizer.next
|
121
|
+
assert_equal expected, token, message
|
122
|
+
end
|
123
|
+
|
124
|
+
def assert_sequence(*expected)
|
125
|
+
assert_next expected.shift until expected.empty?
|
126
|
+
end
|
127
|
+
|
128
|
+
def assert_end(message=nil)
|
129
|
+
assert_nil @tokenizer.next, message
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class HttpBasicAuthenticationTest < Test::Unit::TestCase
|
4
|
+
include ActionController::HttpAuthentication::Basic
|
5
|
+
|
6
|
+
class DummyController
|
7
|
+
attr_accessor :headers, :renders, :request
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@headers, @renders = {}, []
|
11
|
+
@request = ActionController::TestRequest.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(options)
|
15
|
+
self.renders << options
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@controller = DummyController.new
|
21
|
+
@credentials = ActionController::HttpAuthentication::Basic.encode_credentials("dhh", "secret")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_successful_authentication
|
25
|
+
login = Proc.new { |user_name, password| user_name == "dhh" && password == "secret" }
|
26
|
+
set_headers
|
27
|
+
assert authenticate(@controller, &login)
|
28
|
+
|
29
|
+
set_headers ''
|
30
|
+
assert_nothing_raised do
|
31
|
+
assert !authenticate(@controller, &login)
|
32
|
+
end
|
33
|
+
|
34
|
+
set_headers nil
|
35
|
+
set_headers @credentials, 'REDIRECT_X_HTTP_AUTHORIZATION'
|
36
|
+
assert authenticate(@controller, &login)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_failing_authentication
|
40
|
+
set_headers
|
41
|
+
assert !authenticate(@controller) { |user_name, password| user_name == "dhh" && password == "incorrect" }
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_authentication_request
|
45
|
+
authentication_request(@controller, "Megaglobalapp")
|
46
|
+
assert_equal 'Basic realm="Megaglobalapp"', @controller.headers["WWW-Authenticate"]
|
47
|
+
assert_equal :unauthorized, @controller.renders.first[:status]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def set_headers(value = @credentials, name = 'HTTP_AUTHORIZATION')
|
52
|
+
@controller.request.env[name] = value
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,252 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'action_controller/integration'
|
3
|
+
|
4
|
+
uses_mocha 'integration' do
|
5
|
+
|
6
|
+
module IntegrationSessionStubbing
|
7
|
+
def stub_integration_session(session)
|
8
|
+
session.stubs(:process)
|
9
|
+
session.stubs(:generic_url_rewriter)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class SessionTest < Test::Unit::TestCase
|
14
|
+
include IntegrationSessionStubbing
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@session = ActionController::Integration::Session.new
|
18
|
+
stub_integration_session(@session)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_https_bang_works_and_sets_truth_by_default
|
22
|
+
assert !@session.https?
|
23
|
+
@session.https!
|
24
|
+
assert @session.https?
|
25
|
+
@session.https! false
|
26
|
+
assert !@session.https?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_host!
|
30
|
+
assert_not_equal "glu.ttono.us", @session.host
|
31
|
+
@session.host! "rubyonrails.com"
|
32
|
+
assert_equal "rubyonrails.com", @session.host
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_follow_redirect_raises_when_no_redirect
|
36
|
+
@session.stubs(:redirect?).returns(false)
|
37
|
+
assert_raise(RuntimeError) { @session.follow_redirect! }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_follow_redirect_calls_get_and_returns_status
|
41
|
+
@session.stubs(:redirect?).returns(true)
|
42
|
+
@session.stubs(:headers).returns({"location" => ["www.google.com"]})
|
43
|
+
@session.stubs(:status).returns(200)
|
44
|
+
@session.expects(:get)
|
45
|
+
assert_equal 200, @session.follow_redirect!
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_request_via_redirect_uses_given_method
|
49
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
50
|
+
@session.expects(:put).with(path, args, headers)
|
51
|
+
@session.stubs(:redirect?).returns(false)
|
52
|
+
@session.request_via_redirect(:put, path, args, headers)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_request_via_redirect_follows_redirects
|
56
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
57
|
+
@session.stubs(:redirect?).returns(true, true, false)
|
58
|
+
@session.expects(:follow_redirect!).times(2)
|
59
|
+
@session.request_via_redirect(:get, path, args, headers)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_request_via_redirect_returns_status
|
63
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
64
|
+
@session.stubs(:redirect?).returns(false)
|
65
|
+
@session.stubs(:status).returns(200)
|
66
|
+
assert_equal 200, @session.request_via_redirect(:get, path, args, headers)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_get_via_redirect
|
70
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
71
|
+
@session.expects(:request_via_redirect).with(:get, path, args, headers)
|
72
|
+
@session.get_via_redirect(path, args, headers)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_post_via_redirect
|
76
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
77
|
+
@session.expects(:request_via_redirect).with(:post, path, args, headers)
|
78
|
+
@session.post_via_redirect(path, args, headers)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_put_via_redirect
|
82
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
83
|
+
@session.expects(:request_via_redirect).with(:put, path, args, headers)
|
84
|
+
@session.put_via_redirect(path, args, headers)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_delete_via_redirect
|
88
|
+
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue" }
|
89
|
+
@session.expects(:request_via_redirect).with(:delete, path, args, headers)
|
90
|
+
@session.delete_via_redirect(path, args, headers)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_url_for_with_controller
|
94
|
+
options = {:action => 'show'}
|
95
|
+
mock_controller = mock()
|
96
|
+
mock_controller.expects(:url_for).with(options).returns('/show')
|
97
|
+
@session.stubs(:controller).returns(mock_controller)
|
98
|
+
assert_equal '/show', @session.url_for(options)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_url_for_without_controller
|
102
|
+
options = {:action => 'show'}
|
103
|
+
mock_rewriter = mock()
|
104
|
+
mock_rewriter.expects(:rewrite).with(options).returns('/show')
|
105
|
+
@session.stubs(:generic_url_rewriter).returns(mock_rewriter)
|
106
|
+
@session.stubs(:controller).returns(nil)
|
107
|
+
assert_equal '/show', @session.url_for(options)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_redirect_bool_with_status_in_300s
|
111
|
+
@session.stubs(:status).returns 301
|
112
|
+
assert @session.redirect?
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_redirect_bool_with_status_in_200s
|
116
|
+
@session.stubs(:status).returns 200
|
117
|
+
assert !@session.redirect?
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_get
|
121
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
122
|
+
@session.expects(:process).with(:get,path,params,headers)
|
123
|
+
@session.get(path,params,headers)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_post
|
127
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
128
|
+
@session.expects(:process).with(:post,path,params,headers)
|
129
|
+
@session.post(path,params,headers)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_put
|
133
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
134
|
+
@session.expects(:process).with(:put,path,params,headers)
|
135
|
+
@session.put(path,params,headers)
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_delete
|
139
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
140
|
+
@session.expects(:process).with(:delete,path,params,headers)
|
141
|
+
@session.delete(path,params,headers)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_head
|
145
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
146
|
+
@session.expects(:process).with(:head,path,params,headers)
|
147
|
+
@session.head(path,params,headers)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_xml_http_request_get
|
151
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
152
|
+
headers_after_xhr = headers.merge(
|
153
|
+
"X-Requested-With" => "XMLHttpRequest",
|
154
|
+
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
155
|
+
)
|
156
|
+
@session.expects(:process).with(:get,path,params,headers_after_xhr)
|
157
|
+
@session.xml_http_request(:get,path,params,headers)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_xml_http_request_post
|
161
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
162
|
+
headers_after_xhr = headers.merge(
|
163
|
+
"X-Requested-With" => "XMLHttpRequest",
|
164
|
+
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
165
|
+
)
|
166
|
+
@session.expects(:process).with(:post,path,params,headers_after_xhr)
|
167
|
+
@session.xml_http_request(:post,path,params,headers)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_xml_http_request_put
|
171
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
172
|
+
headers_after_xhr = headers.merge(
|
173
|
+
"X-Requested-With" => "XMLHttpRequest",
|
174
|
+
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
175
|
+
)
|
176
|
+
@session.expects(:process).with(:put,path,params,headers_after_xhr)
|
177
|
+
@session.xml_http_request(:put,path,params,headers)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_xml_http_request_delete
|
181
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
182
|
+
headers_after_xhr = headers.merge(
|
183
|
+
"X-Requested-With" => "XMLHttpRequest",
|
184
|
+
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
185
|
+
)
|
186
|
+
@session.expects(:process).with(:delete,path,params,headers_after_xhr)
|
187
|
+
@session.xml_http_request(:delete,path,params,headers)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_xml_http_request_head
|
191
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah'}
|
192
|
+
headers_after_xhr = headers.merge(
|
193
|
+
"X-Requested-With" => "XMLHttpRequest",
|
194
|
+
"Accept" => "text/javascript, text/html, application/xml, text/xml, */*"
|
195
|
+
)
|
196
|
+
@session.expects(:process).with(:head,path,params,headers_after_xhr)
|
197
|
+
@session.xml_http_request(:head,path,params,headers)
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_xml_http_request_override_accept
|
201
|
+
path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"}
|
202
|
+
headers_after_xhr = headers.merge(
|
203
|
+
"X-Requested-With" => "XMLHttpRequest"
|
204
|
+
)
|
205
|
+
@session.expects(:process).with(:post,path,params,headers_after_xhr)
|
206
|
+
@session.xml_http_request(:post,path,params,headers)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
class IntegrationTestTest < Test::Unit::TestCase
|
211
|
+
include IntegrationSessionStubbing
|
212
|
+
|
213
|
+
def setup
|
214
|
+
@test = ::ActionController::IntegrationTest.new(:default_test)
|
215
|
+
@test.class.stubs(:fixture_table_names).returns([])
|
216
|
+
@session = @test.open_session
|
217
|
+
stub_integration_session(@session)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_opens_new_session
|
221
|
+
@test.class.expects(:fixture_table_names).times(2).returns(['foo'])
|
222
|
+
|
223
|
+
session1 = @test.open_session { |sess| }
|
224
|
+
session2 = @test.open_session # implicit session
|
225
|
+
|
226
|
+
assert_equal ::ActionController::Integration::Session, session1.class
|
227
|
+
assert_equal ::ActionController::Integration::Session, session2.class
|
228
|
+
assert_not_equal session1, session2
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
# Tests that integration tests don't call Controller test methods for processing.
|
234
|
+
# Integration tests have their own setup and teardown.
|
235
|
+
class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
|
236
|
+
include IntegrationSessionStubbing
|
237
|
+
|
238
|
+
def self.fixture_table_names
|
239
|
+
[]
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_integration_methods_called
|
243
|
+
reset!
|
244
|
+
stub_integration_session(@integration_session)
|
245
|
+
%w( get post head put delete ).each do |verb|
|
246
|
+
assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
end # uses_mocha
|