actionpack-2.3.17-rack-upgrade 2.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5250 -0
- data/MIT-LICENSE +21 -0
- data/README +409 -0
- data/RUNNING_UNIT_TESTS +24 -0
- data/Rakefile +158 -0
- data/install.rb +30 -0
- data/lib/action_controller.rb +113 -0
- data/lib/action_controller/assertions/dom_assertions.rb +55 -0
- data/lib/action_controller/assertions/model_assertions.rb +21 -0
- data/lib/action_controller/assertions/response_assertions.rb +169 -0
- data/lib/action_controller/assertions/routing_assertions.rb +146 -0
- data/lib/action_controller/assertions/selector_assertions.rb +638 -0
- data/lib/action_controller/assertions/tag_assertions.rb +127 -0
- data/lib/action_controller/base.rb +1425 -0
- data/lib/action_controller/benchmarking.rb +107 -0
- data/lib/action_controller/caching.rb +71 -0
- data/lib/action_controller/caching/actions.rb +177 -0
- data/lib/action_controller/caching/fragments.rb +120 -0
- data/lib/action_controller/caching/pages.rb +152 -0
- data/lib/action_controller/caching/sweeper.rb +45 -0
- data/lib/action_controller/caching/sweeping.rb +55 -0
- data/lib/action_controller/cgi_ext.rb +15 -0
- data/lib/action_controller/cgi_ext/cookie.rb +112 -0
- data/lib/action_controller/cgi_ext/query_extension.rb +22 -0
- data/lib/action_controller/cgi_ext/stdinput.rb +24 -0
- data/lib/action_controller/cgi_process.rb +77 -0
- data/lib/action_controller/cookies.rb +197 -0
- data/lib/action_controller/dispatcher.rb +133 -0
- data/lib/action_controller/failsafe.rb +87 -0
- data/lib/action_controller/filters.rb +680 -0
- data/lib/action_controller/flash.rb +213 -0
- data/lib/action_controller/headers.rb +33 -0
- data/lib/action_controller/helpers.rb +225 -0
- data/lib/action_controller/http_authentication.rb +309 -0
- data/lib/action_controller/integration.rb +708 -0
- data/lib/action_controller/layout.rb +286 -0
- data/lib/action_controller/middleware_stack.rb +119 -0
- data/lib/action_controller/middlewares.rb +14 -0
- data/lib/action_controller/mime_responds.rb +193 -0
- data/lib/action_controller/mime_type.rb +212 -0
- data/lib/action_controller/mime_types.rb +21 -0
- data/lib/action_controller/params_parser.rb +77 -0
- data/lib/action_controller/performance_test.rb +15 -0
- data/lib/action_controller/polymorphic_routes.rb +189 -0
- data/lib/action_controller/rack_lint_patch.rb +36 -0
- data/lib/action_controller/record_identifier.rb +104 -0
- data/lib/action_controller/reloader.rb +54 -0
- data/lib/action_controller/request.rb +518 -0
- data/lib/action_controller/request_forgery_protection.rb +116 -0
- data/lib/action_controller/rescue.rb +183 -0
- data/lib/action_controller/resources.rb +682 -0
- data/lib/action_controller/response.rb +237 -0
- data/lib/action_controller/routing.rb +388 -0
- data/lib/action_controller/routing/builder.rb +197 -0
- data/lib/action_controller/routing/optimisations.rb +130 -0
- data/lib/action_controller/routing/recognition_optimisation.rb +167 -0
- data/lib/action_controller/routing/route.rb +265 -0
- data/lib/action_controller/routing/route_set.rb +503 -0
- data/lib/action_controller/routing/routing_ext.rb +49 -0
- data/lib/action_controller/routing/segments.rb +343 -0
- data/lib/action_controller/session/abstract_store.rb +276 -0
- data/lib/action_controller/session/cookie_store.rb +240 -0
- data/lib/action_controller/session/mem_cache_store.rb +60 -0
- data/lib/action_controller/session_management.rb +54 -0
- data/lib/action_controller/status_codes.rb +88 -0
- data/lib/action_controller/streaming.rb +181 -0
- data/lib/action_controller/string_coercion.rb +29 -0
- data/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
- data/lib/action_controller/templates/rescues/_trace.erb +26 -0
- data/lib/action_controller/templates/rescues/diagnostics.erb +11 -0
- data/lib/action_controller/templates/rescues/layout.erb +29 -0
- data/lib/action_controller/templates/rescues/missing_template.erb +2 -0
- data/lib/action_controller/templates/rescues/routing_error.erb +10 -0
- data/lib/action_controller/templates/rescues/template_error.erb +21 -0
- data/lib/action_controller/templates/rescues/unknown_action.erb +2 -0
- data/lib/action_controller/test_case.rb +209 -0
- data/lib/action_controller/test_process.rb +580 -0
- data/lib/action_controller/translation.rb +13 -0
- data/lib/action_controller/uploaded_file.rb +44 -0
- data/lib/action_controller/url_rewriter.rb +229 -0
- data/lib/action_controller/vendor/html-scanner.rb +16 -0
- data/lib/action_controller/vendor/html-scanner/html/document.rb +68 -0
- data/lib/action_controller/vendor/html-scanner/html/node.rb +537 -0
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +828 -0
- data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
- data/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
- data/lib/action_controller/verification.rb +130 -0
- data/lib/action_pack.rb +24 -0
- data/lib/action_pack/version.rb +9 -0
- data/lib/action_view.rb +58 -0
- data/lib/action_view/base.rb +362 -0
- data/lib/action_view/helpers.rb +61 -0
- data/lib/action_view/helpers/active_record_helper.rb +305 -0
- data/lib/action_view/helpers/asset_tag_helper.rb +695 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +198 -0
- data/lib/action_view/helpers/benchmark_helper.rb +54 -0
- data/lib/action_view/helpers/cache_helper.rb +39 -0
- data/lib/action_view/helpers/capture_helper.rb +136 -0
- data/lib/action_view/helpers/csrf_helper.rb +14 -0
- data/lib/action_view/helpers/date_helper.rb +989 -0
- data/lib/action_view/helpers/debug_helper.rb +38 -0
- data/lib/action_view/helpers/form_helper.rb +1118 -0
- data/lib/action_view/helpers/form_options_helper.rb +599 -0
- data/lib/action_view/helpers/form_tag_helper.rb +490 -0
- data/lib/action_view/helpers/javascript_helper.rb +208 -0
- data/lib/action_view/helpers/number_helper.rb +308 -0
- data/lib/action_view/helpers/prototype_helper.rb +1305 -0
- data/lib/action_view/helpers/raw_output_helper.rb +9 -0
- data/lib/action_view/helpers/record_identification_helper.rb +20 -0
- data/lib/action_view/helpers/record_tag_helper.rb +58 -0
- data/lib/action_view/helpers/sanitize_helper.rb +251 -0
- data/lib/action_view/helpers/scriptaculous_helper.rb +226 -0
- data/lib/action_view/helpers/tag_helper.rb +151 -0
- data/lib/action_view/helpers/text_helper.rb +597 -0
- data/lib/action_view/helpers/translation_helper.rb +67 -0
- data/lib/action_view/helpers/url_helper.rb +637 -0
- data/lib/action_view/inline_template.rb +19 -0
- data/lib/action_view/locale/en.yml +117 -0
- data/lib/action_view/partials.rb +241 -0
- data/lib/action_view/paths.rb +77 -0
- data/lib/action_view/reloadable_template.rb +117 -0
- data/lib/action_view/renderable.rb +109 -0
- data/lib/action_view/renderable_partial.rb +53 -0
- data/lib/action_view/template.rb +252 -0
- data/lib/action_view/template_error.rb +99 -0
- data/lib/action_view/template_handler.rb +34 -0
- data/lib/action_view/template_handlers.rb +48 -0
- data/lib/action_view/template_handlers/builder.rb +17 -0
- data/lib/action_view/template_handlers/erb.rb +25 -0
- data/lib/action_view/template_handlers/rjs.rb +13 -0
- data/lib/action_view/test_case.rb +162 -0
- data/lib/actionpack.rb +2 -0
- data/test/abstract_unit.rb +78 -0
- data/test/active_record_unit.rb +104 -0
- data/test/activerecord/active_record_store_test.rb +221 -0
- data/test/activerecord/render_partial_with_record_identification_test.rb +188 -0
- data/test/adv_attr_test.rb +20 -0
- data/test/controller/action_pack_assertions_test.rb +545 -0
- data/test/controller/addresses_render_test.rb +37 -0
- data/test/controller/assert_select_test.rb +735 -0
- data/test/controller/base_test.rb +217 -0
- data/test/controller/benchmark_test.rb +32 -0
- data/test/controller/caching_test.rb +743 -0
- data/test/controller/capture_test.rb +66 -0
- data/test/controller/content_type_test.rb +178 -0
- data/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
- data/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
- data/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
- data/test/controller/cookie_test.rb +208 -0
- data/test/controller/deprecation/deprecated_base_methods_test.rb +32 -0
- data/test/controller/dispatcher_test.rb +144 -0
- data/test/controller/dom_assertions_test.rb +53 -0
- data/test/controller/failsafe_test.rb +60 -0
- data/test/controller/fake_controllers.rb +33 -0
- data/test/controller/fake_models.rb +19 -0
- data/test/controller/filter_params_test.rb +52 -0
- data/test/controller/filters_test.rb +885 -0
- data/test/controller/flash_test.rb +174 -0
- data/test/controller/header_test.rb +14 -0
- data/test/controller/helper_test.rb +224 -0
- data/test/controller/html-scanner/cdata_node_test.rb +15 -0
- data/test/controller/html-scanner/document_test.rb +148 -0
- data/test/controller/html-scanner/node_test.rb +89 -0
- data/test/controller/html-scanner/sanitizer_test.rb +281 -0
- data/test/controller/html-scanner/tag_node_test.rb +238 -0
- data/test/controller/html-scanner/text_node_test.rb +50 -0
- data/test/controller/html-scanner/tokenizer_test.rb +131 -0
- data/test/controller/http_basic_authentication_test.rb +113 -0
- data/test/controller/http_digest_authentication_test.rb +254 -0
- data/test/controller/integration_test.rb +526 -0
- data/test/controller/layout_test.rb +215 -0
- data/test/controller/localized_templates_test.rb +24 -0
- data/test/controller/logging_test.rb +46 -0
- data/test/controller/middleware_stack_test.rb +90 -0
- data/test/controller/mime_responds_test.rb +536 -0
- data/test/controller/mime_type_test.rb +93 -0
- data/test/controller/output_escaping_test.rb +19 -0
- data/test/controller/polymorphic_routes_test.rb +297 -0
- data/test/controller/rack_test.rb +308 -0
- data/test/controller/record_identifier_test.rb +139 -0
- data/test/controller/redirect_test.rb +285 -0
- data/test/controller/reloader_test.rb +125 -0
- data/test/controller/render_test.rb +1783 -0
- data/test/controller/request/json_params_parsing_test.rb +65 -0
- data/test/controller/request/multipart_params_parsing_test.rb +177 -0
- data/test/controller/request/query_string_parsing_test.rb +129 -0
- data/test/controller/request/test_request_test.rb +35 -0
- data/test/controller/request/url_encoded_params_parsing_test.rb +146 -0
- data/test/controller/request/xml_params_parsing_test.rb +103 -0
- data/test/controller/request_forgery_protection_test.rb +233 -0
- data/test/controller/request_test.rb +398 -0
- data/test/controller/rescue_test.rb +541 -0
- data/test/controller/resources_test.rb +1393 -0
- data/test/controller/routing_test.rb +2592 -0
- data/test/controller/selector_test.rb +628 -0
- data/test/controller/send_file_test.rb +171 -0
- data/test/controller/session/abstract_store_test.rb +64 -0
- data/test/controller/session/cookie_store_test.rb +354 -0
- data/test/controller/session/mem_cache_store_test.rb +187 -0
- data/test/controller/session/test_session_test.rb +58 -0
- data/test/controller/test_test.rb +700 -0
- data/test/controller/translation_test.rb +26 -0
- data/test/controller/url_rewriter_test.rb +395 -0
- data/test/controller/verification_test.rb +270 -0
- data/test/controller/view_paths_test.rb +141 -0
- data/test/controller/webservice_test.rb +273 -0
- data/test/fixtures/_top_level_partial.html.erb +1 -0
- data/test/fixtures/_top_level_partial_only.erb +1 -0
- data/test/fixtures/addresses/list.erb +1 -0
- data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
- data/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
- data/test/fixtures/companies.yml +24 -0
- data/test/fixtures/company.rb +10 -0
- data/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
- data/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
- data/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
- data/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
- data/test/fixtures/customers/_customer.html.erb +1 -0
- data/test/fixtures/db_definitions/sqlite.sql +49 -0
- data/test/fixtures/developer.rb +9 -0
- data/test/fixtures/developers.yml +21 -0
- data/test/fixtures/developers/_developer.erb +1 -0
- data/test/fixtures/developers_projects.yml +13 -0
- data/test/fixtures/failsafe/500.html +1 -0
- data/test/fixtures/fun/games/_game.erb +1 -0
- data/test/fixtures/fun/games/hello_world.erb +1 -0
- data/test/fixtures/fun/serious/games/_game.erb +1 -0
- data/test/fixtures/functional_caching/_partial.erb +3 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +6 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
- data/test/fixtures/functional_caching/fragment_cached.html.erb +2 -0
- data/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
- data/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
- data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +1 -0
- data/test/fixtures/good_customers/_good_customer.html.erb +1 -0
- data/test/fixtures/helpers/abc_helper.rb +5 -0
- data/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
- data/test/fixtures/layout_tests/abs_path_layout.rhtml +1 -0
- data/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
- data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
- data/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
- data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
- data/test/fixtures/layout_tests/views/hello.rhtml +1 -0
- data/test/fixtures/layouts/_column.html.erb +2 -0
- data/test/fixtures/layouts/block_with_layout.erb +3 -0
- data/test/fixtures/layouts/builder.builder +3 -0
- data/test/fixtures/layouts/default_html.html.erb +1 -0
- data/test/fixtures/layouts/partial_with_layout.erb +3 -0
- data/test/fixtures/layouts/standard.erb +1 -0
- data/test/fixtures/layouts/talk_from_action.erb +2 -0
- data/test/fixtures/layouts/xhr.html.erb +2 -0
- data/test/fixtures/layouts/yield.erb +2 -0
- data/test/fixtures/localized/hello_world.de.html +1 -0
- data/test/fixtures/localized/hello_world.en.html +1 -0
- data/test/fixtures/mascot.rb +3 -0
- data/test/fixtures/mascots.yml +4 -0
- data/test/fixtures/mascots/_mascot.html.erb +1 -0
- data/test/fixtures/multipart/binary_file +0 -0
- data/test/fixtures/multipart/boundary_problem_file +10 -0
- data/test/fixtures/multipart/bracketed_param +5 -0
- data/test/fixtures/multipart/empty +10 -0
- data/test/fixtures/multipart/hello.txt +1 -0
- data/test/fixtures/multipart/large_text_file +10 -0
- data/test/fixtures/multipart/mixed_files +0 -0
- data/test/fixtures/multipart/mona_lisa.jpg +0 -0
- data/test/fixtures/multipart/none +9 -0
- data/test/fixtures/multipart/single_parameter +5 -0
- data/test/fixtures/multipart/text_file +10 -0
- data/test/fixtures/override/test/hello_world.erb +1 -0
- data/test/fixtures/override2/layouts/test/sub.erb +1 -0
- data/test/fixtures/post_test/layouts/post.html.erb +1 -0
- data/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
- data/test/fixtures/post_test/post/index.html.erb +1 -0
- data/test/fixtures/post_test/post/index.iphone.erb +1 -0
- data/test/fixtures/post_test/super_post/index.html.erb +1 -0
- data/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
- data/test/fixtures/project.rb +3 -0
- data/test/fixtures/projects.yml +7 -0
- data/test/fixtures/projects/_project.erb +1 -0
- data/test/fixtures/public/404.html +1 -0
- data/test/fixtures/public/500.da.html +1 -0
- data/test/fixtures/public/500.html +1 -0
- data/test/fixtures/public/absolute/test.css +23 -0
- data/test/fixtures/public/absolute/test.js +63 -0
- data/test/fixtures/public/images/rails.png +0 -0
- data/test/fixtures/public/javascripts/application.js +1 -0
- data/test/fixtures/public/javascripts/bank.js +1 -0
- data/test/fixtures/public/javascripts/controls.js +1 -0
- data/test/fixtures/public/javascripts/dragdrop.js +1 -0
- data/test/fixtures/public/javascripts/effects.js +1 -0
- data/test/fixtures/public/javascripts/prototype.js +1 -0
- data/test/fixtures/public/javascripts/robber.js +1 -0
- data/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
- data/test/fixtures/public/javascripts/version.1.0.js +1 -0
- data/test/fixtures/public/stylesheets/bank.css +1 -0
- data/test/fixtures/public/stylesheets/robber.css +1 -0
- data/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
- data/test/fixtures/public/stylesheets/version.1.0.css +1 -0
- data/test/fixtures/quiz/questions/_question.html.erb +1 -0
- data/test/fixtures/replies.yml +15 -0
- data/test/fixtures/replies/_reply.erb +1 -0
- data/test/fixtures/reply.rb +7 -0
- data/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
- data/test/fixtures/respond_to/all_types_with_layout.js.rjs +1 -0
- data/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
- data/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
- data/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
- data/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
- data/test/fixtures/respond_to/using_defaults.html.erb +1 -0
- data/test/fixtures/respond_to/using_defaults.js.rjs +1 -0
- data/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +1 -0
- data/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
- data/test/fixtures/scope/test/modgreet.erb +1 -0
- data/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +10 -0
- data/test/fixtures/shared.html.erb +1 -0
- data/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
- data/test/fixtures/test/_counter.html.erb +1 -0
- data/test/fixtures/test/_customer.erb +1 -0
- data/test/fixtures/test/_customer_counter.erb +1 -0
- data/test/fixtures/test/_customer_counter_with_as.erb +1 -0
- data/test/fixtures/test/_customer_greeting.erb +1 -0
- data/test/fixtures/test/_customer_with_var.erb +1 -0
- data/test/fixtures/test/_form.erb +1 -0
- data/test/fixtures/test/_from_helper.erb +1 -0
- data/test/fixtures/test/_hash_greeting.erb +1 -0
- data/test/fixtures/test/_hash_object.erb +2 -0
- data/test/fixtures/test/_hello.builder +1 -0
- data/test/fixtures/test/_labelling_form.erb +1 -0
- data/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
- data/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/test/fixtures/test/_local_inspector.html.erb +1 -0
- data/test/fixtures/test/_one.html.erb +1 -0
- data/test/fixtures/test/_partial.erb +1 -0
- data/test/fixtures/test/_partial.html.erb +1 -0
- data/test/fixtures/test/_partial.js.erb +1 -0
- data/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
- data/test/fixtures/test/_partial_only.erb +1 -0
- data/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
- data/test/fixtures/test/_person.erb +2 -0
- data/test/fixtures/test/_raise.html.erb +1 -0
- data/test/fixtures/test/_two.html.erb +1 -0
- data/test/fixtures/test/_utf8_partial.html.erb +1 -0
- data/test/fixtures/test/_utf8_partial_magic.html.erb +2 -0
- data/test/fixtures/test/action_talk_to_layout.erb +2 -0
- data/test/fixtures/test/array_translation.erb +1 -0
- data/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/test/fixtures/test/capturing.erb +4 -0
- data/test/fixtures/test/content_for.erb +2 -0
- data/test/fixtures/test/content_for_concatenated.erb +3 -0
- data/test/fixtures/test/content_for_with_parameter.erb +2 -0
- data/test/fixtures/test/delete_with_js.rjs +2 -0
- data/test/fixtures/test/dont_pick_me +1 -0
- data/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/test/fixtures/test/enum_rjs_test.rjs +6 -0
- data/test/fixtures/test/formatted_html_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.builder +1 -0
- data/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
- data/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
- data/test/fixtures/test/greeting.erb +1 -0
- data/test/fixtures/test/greeting.js.rjs +1 -0
- data/test/fixtures/test/hello.builder +4 -0
- data/test/fixtures/test/hello_world.da.html.erb +1 -0
- data/test/fixtures/test/hello_world.erb +1 -0
- data/test/fixtures/test/hello_world.erb~ +1 -0
- data/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
- data/test/fixtures/test/hello_world_container.builder +3 -0
- data/test/fixtures/test/hello_world_from_rxml.builder +4 -0
- data/test/fixtures/test/hello_world_with_layout_false.erb +1 -0
- data/test/fixtures/test/hello_xml_world.builder +11 -0
- data/test/fixtures/test/hyphen-ated.erb +1 -0
- data/test/fixtures/test/implicit_content_type.atom.builder +2 -0
- data/test/fixtures/test/list.erb +1 -0
- data/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
- data/test/fixtures/test/malformed/malformed.erb~ +1 -0
- data/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
- data/test/fixtures/test/nested_layout.erb +3 -0
- data/test/fixtures/test/non_erb_block_content_for.builder +4 -0
- data/test/fixtures/test/potential_conflicts.erb +4 -0
- data/test/fixtures/test/render_explicit_html_template.js.rjs +1 -0
- data/test/fixtures/test/render_file_from_template.html.erb +1 -0
- data/test/fixtures/test/render_file_with_ivar.erb +1 -0
- data/test/fixtures/test/render_file_with_locals.erb +1 -0
- data/test/fixtures/test/render_implicit_html_template.js.rjs +1 -0
- data/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
- data/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
- data/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +1 -0
- data/test/fixtures/test/render_to_string_test.erb +1 -0
- data/test/fixtures/test/scoped_array_translation.erb +1 -0
- data/test/fixtures/test/sub_template_raise.html.erb +1 -0
- data/test/fixtures/test/template.erb +1 -0
- data/test/fixtures/test/translation.erb +1 -0
- data/test/fixtures/test/update_element_with_capture.erb +9 -0
- data/test/fixtures/test/using_layout_around_block.html.erb +1 -0
- data/test/fixtures/test/using_layout_around_block_with_args.html.erb +1 -0
- data/test/fixtures/test/utf8.html.erb +4 -0
- data/test/fixtures/test/utf8_magic.html.erb +5 -0
- data/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +5 -0
- data/test/fixtures/topic.rb +3 -0
- data/test/fixtures/topics.yml +22 -0
- data/test/fixtures/topics/_topic.html.erb +1 -0
- data/test/template/active_record_helper_i18n_test.rb +51 -0
- data/test/template/active_record_helper_test.rb +302 -0
- data/test/template/asset_tag_helper_test.rb +770 -0
- data/test/template/atom_feed_helper_test.rb +315 -0
- data/test/template/benchmark_helper_test.rb +86 -0
- data/test/template/compiled_templates_test.rb +204 -0
- data/test/template/date_helper_i18n_test.rb +121 -0
- data/test/template/date_helper_test.rb +2603 -0
- data/test/template/erb_util_test.rb +36 -0
- data/test/template/form_helper_test.rb +1447 -0
- data/test/template/form_options_helper_i18n_test.rb +27 -0
- data/test/template/form_options_helper_test.rb +811 -0
- data/test/template/form_tag_helper_test.rb +356 -0
- data/test/template/javascript_helper_test.rb +106 -0
- data/test/template/number_helper_i18n_test.rb +69 -0
- data/test/template/number_helper_test.rb +132 -0
- data/test/template/prototype_helper_test.rb +639 -0
- data/test/template/raw_output_helper_test.rb +21 -0
- data/test/template/record_tag_helper_test.rb +58 -0
- data/test/template/render_test.rb +329 -0
- data/test/template/sanitize_helper_test.rb +57 -0
- data/test/template/scriptaculous_helper_test.rb +90 -0
- data/test/template/tag_helper_test.rb +98 -0
- data/test/template/template_test.rb +32 -0
- data/test/template/test_test.rb +54 -0
- data/test/template/text_helper_test.rb +601 -0
- data/test/template/translation_helper_test.rb +95 -0
- data/test/template/url_helper_test.rb +641 -0
- data/test/testing_sandbox.rb +15 -0
- data/test/view/test_case_test.rb +176 -0
- metadata +519 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
|
4
|
+
include ActionView::Helpers::DateHelper
|
5
|
+
attr_reader :request
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@from = Time.mktime(2004, 6, 6, 21, 45, 0)
|
9
|
+
end
|
10
|
+
|
11
|
+
# distance_of_time_in_words
|
12
|
+
|
13
|
+
def test_distance_of_time_in_words_calls_i18n
|
14
|
+
{ # with include_seconds
|
15
|
+
[2.seconds, true] => [:'less_than_x_seconds', 5],
|
16
|
+
[9.seconds, true] => [:'less_than_x_seconds', 10],
|
17
|
+
[19.seconds, true] => [:'less_than_x_seconds', 20],
|
18
|
+
[30.seconds, true] => [:'half_a_minute', nil],
|
19
|
+
[59.seconds, true] => [:'less_than_x_minutes', 1],
|
20
|
+
[60.seconds, true] => [:'x_minutes', 1],
|
21
|
+
|
22
|
+
# without include_seconds
|
23
|
+
[29.seconds, false] => [:'less_than_x_minutes', 1],
|
24
|
+
[60.seconds, false] => [:'x_minutes', 1],
|
25
|
+
[44.minutes, false] => [:'x_minutes', 44],
|
26
|
+
[61.minutes, false] => [:'about_x_hours', 1],
|
27
|
+
[24.hours, false] => [:'x_days', 1],
|
28
|
+
[30.days, false] => [:'about_x_months', 1],
|
29
|
+
[60.days, false] => [:'x_months', 2],
|
30
|
+
[1.year, false] => [:'about_x_years', 1],
|
31
|
+
[3.years + 6.months, false] => [:'over_x_years', 3],
|
32
|
+
[3.years + 10.months, false] => [:'almost_x_years', 4]
|
33
|
+
|
34
|
+
}.each do |passed, expected|
|
35
|
+
assert_distance_of_time_in_words_translates_key passed, expected
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def assert_distance_of_time_in_words_translates_key(passed, expected)
|
40
|
+
diff, include_seconds = *passed
|
41
|
+
key, count = *expected
|
42
|
+
to = @from + diff
|
43
|
+
|
44
|
+
options = {:locale => 'en', :scope => :'datetime.distance_in_words'}
|
45
|
+
options[:count] = count if count
|
46
|
+
|
47
|
+
I18n.expects(:t).with(key, options)
|
48
|
+
distance_of_time_in_words(@from, to, include_seconds, :locale => 'en')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_distance_of_time_pluralizations
|
52
|
+
{ [:'less_than_x_seconds', 1] => 'less than 1 second',
|
53
|
+
[:'less_than_x_seconds', 2] => 'less than 2 seconds',
|
54
|
+
[:'less_than_x_minutes', 1] => 'less than a minute',
|
55
|
+
[:'less_than_x_minutes', 2] => 'less than 2 minutes',
|
56
|
+
[:'x_minutes', 1] => '1 minute',
|
57
|
+
[:'x_minutes', 2] => '2 minutes',
|
58
|
+
[:'about_x_hours', 1] => 'about 1 hour',
|
59
|
+
[:'about_x_hours', 2] => 'about 2 hours',
|
60
|
+
[:'x_days', 1] => '1 day',
|
61
|
+
[:'x_days', 2] => '2 days',
|
62
|
+
[:'about_x_years', 1] => 'about 1 year',
|
63
|
+
[:'about_x_years', 2] => 'about 2 years',
|
64
|
+
[:'over_x_years', 1] => 'over 1 year',
|
65
|
+
[:'over_x_years', 2] => 'over 2 years'
|
66
|
+
|
67
|
+
}.each do |args, expected|
|
68
|
+
key, count = *args
|
69
|
+
assert_equal expected, I18n.t(key, :count => count, :scope => 'datetime.distance_in_words')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class DateHelperSelectTagsI18nTests < Test::Unit::TestCase
|
75
|
+
include ActionView::Helpers::DateHelper
|
76
|
+
attr_reader :request
|
77
|
+
|
78
|
+
def setup
|
79
|
+
@prompt_defaults = {:year => 'Year', :month => 'Month', :day => 'Day', :hour => 'Hour', :minute => 'Minute', :second => 'Seconds'}
|
80
|
+
|
81
|
+
I18n.stubs(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES
|
82
|
+
end
|
83
|
+
|
84
|
+
# select_month
|
85
|
+
|
86
|
+
def test_select_month_given_use_month_names_option_does_not_translate_monthnames
|
87
|
+
I18n.expects(:translate).never
|
88
|
+
select_month(8, :locale => 'en', :use_month_names => Date::MONTHNAMES)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_select_month_translates_monthnames
|
92
|
+
I18n.expects(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES
|
93
|
+
select_month(8, :locale => 'en')
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_select_month_given_use_short_month_option_translates_abbr_monthnames
|
97
|
+
I18n.expects(:translate).with(:'date.abbr_month_names', :locale => 'en').returns Date::ABBR_MONTHNAMES
|
98
|
+
select_month(8, :locale => 'en', :use_short_month => true)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_date_or_time_select_translates_prompts
|
102
|
+
@prompt_defaults.each do |key, prompt|
|
103
|
+
I18n.expects(:translate).with(('datetime.prompts.' + key.to_s).to_sym, :locale => 'en').returns prompt
|
104
|
+
end
|
105
|
+
|
106
|
+
I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day]
|
107
|
+
datetime_select('post', 'updated_at', :locale => 'en', :include_seconds => true, :prompt => true)
|
108
|
+
end
|
109
|
+
|
110
|
+
# date_or_time_select
|
111
|
+
|
112
|
+
def test_date_or_time_select_given_an_order_options_does_not_translate_order
|
113
|
+
I18n.expects(:translate).never
|
114
|
+
datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en')
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_date_or_time_select_given_no_order_options_translates_order
|
118
|
+
I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day]
|
119
|
+
datetime_select('post', 'updated_at', :locale => 'en')
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,2603 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class DateHelperTest < ActionView::TestCase
|
4
|
+
tests ActionView::Helpers::DateHelper
|
5
|
+
|
6
|
+
silence_warnings do
|
7
|
+
Post = Struct.new("Post", :id, :written_on, :updated_at)
|
8
|
+
Post.class_eval do
|
9
|
+
def id
|
10
|
+
123
|
11
|
+
end
|
12
|
+
def id_before_type_cast
|
13
|
+
123
|
14
|
+
end
|
15
|
+
def to_param
|
16
|
+
'123'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def assert_distance_of_time_in_words(from, to=nil)
|
22
|
+
to ||= from
|
23
|
+
|
24
|
+
# 0..1 with include_seconds
|
25
|
+
assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 0.seconds, true)
|
26
|
+
assert_equal "less than 5 seconds", distance_of_time_in_words(from, to + 4.seconds, true)
|
27
|
+
assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 5.seconds, true)
|
28
|
+
assert_equal "less than 10 seconds", distance_of_time_in_words(from, to + 9.seconds, true)
|
29
|
+
assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 10.seconds, true)
|
30
|
+
assert_equal "less than 20 seconds", distance_of_time_in_words(from, to + 19.seconds, true)
|
31
|
+
assert_equal "half a minute", distance_of_time_in_words(from, to + 20.seconds, true)
|
32
|
+
assert_equal "half a minute", distance_of_time_in_words(from, to + 39.seconds, true)
|
33
|
+
assert_equal "less than a minute", distance_of_time_in_words(from, to + 40.seconds, true)
|
34
|
+
assert_equal "less than a minute", distance_of_time_in_words(from, to + 59.seconds, true)
|
35
|
+
assert_equal "1 minute", distance_of_time_in_words(from, to + 60.seconds, true)
|
36
|
+
assert_equal "1 minute", distance_of_time_in_words(from, to + 89.seconds, true)
|
37
|
+
|
38
|
+
# First case 0..1
|
39
|
+
assert_equal "less than a minute", distance_of_time_in_words(from, to + 0.seconds)
|
40
|
+
assert_equal "less than a minute", distance_of_time_in_words(from, to + 29.seconds)
|
41
|
+
assert_equal "1 minute", distance_of_time_in_words(from, to + 30.seconds)
|
42
|
+
assert_equal "1 minute", distance_of_time_in_words(from, to + 1.minutes + 29.seconds)
|
43
|
+
|
44
|
+
# 2..44
|
45
|
+
assert_equal "2 minutes", distance_of_time_in_words(from, to + 1.minutes + 30.seconds)
|
46
|
+
assert_equal "44 minutes", distance_of_time_in_words(from, to + 44.minutes + 29.seconds)
|
47
|
+
|
48
|
+
# 45..89
|
49
|
+
assert_equal "about 1 hour", distance_of_time_in_words(from, to + 44.minutes + 30.seconds)
|
50
|
+
assert_equal "about 1 hour", distance_of_time_in_words(from, to + 89.minutes + 29.seconds)
|
51
|
+
|
52
|
+
# 90..1439
|
53
|
+
assert_equal "about 2 hours", distance_of_time_in_words(from, to + 89.minutes + 30.seconds)
|
54
|
+
assert_equal "about 24 hours", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 29.seconds)
|
55
|
+
|
56
|
+
# 1440..2529
|
57
|
+
assert_equal "1 day", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 30.seconds)
|
58
|
+
assert_equal "1 day", distance_of_time_in_words(from, to + 41.hours + 59.minutes + 29.seconds)
|
59
|
+
|
60
|
+
# 2530..43199
|
61
|
+
assert_equal "2 days", distance_of_time_in_words(from, to + 42.hours + 59.minutes + 30.seconds)
|
62
|
+
assert_equal "3 days", distance_of_time_in_words(from, to + 2.days + 12.hours)
|
63
|
+
assert_equal "30 days", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 29.seconds)
|
64
|
+
|
65
|
+
# 43200..86399
|
66
|
+
assert_equal "about 1 month", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 30.seconds)
|
67
|
+
assert_equal "about 1 month", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 29.seconds)
|
68
|
+
|
69
|
+
# 86400..525599
|
70
|
+
assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds)
|
71
|
+
assert_equal "12 months", distance_of_time_in_words(from, to + 1.years - 31.seconds)
|
72
|
+
|
73
|
+
# > 525599
|
74
|
+
assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds)
|
75
|
+
assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years + 3.months - 1.day)
|
76
|
+
assert_equal "over 1 year", distance_of_time_in_words(from, to + 1.years + 6.months)
|
77
|
+
|
78
|
+
assert_equal "almost 2 years", distance_of_time_in_words(from, to + 2.years - 3.months + 1.day)
|
79
|
+
assert_equal "about 2 years", distance_of_time_in_words(from, to + 2.years + 3.months - 1.day)
|
80
|
+
assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 3.months + 1.day)
|
81
|
+
assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 9.months - 1.day)
|
82
|
+
assert_equal "almost 3 years", distance_of_time_in_words(from, to + 2.years + 9.months + 1.day)
|
83
|
+
|
84
|
+
assert_equal "almost 5 years", distance_of_time_in_words(from, to + 5.years - 3.months + 1.day)
|
85
|
+
assert_equal "about 5 years", distance_of_time_in_words(from, to + 5.years + 3.months - 1.day)
|
86
|
+
assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 3.months + 1.day)
|
87
|
+
assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 9.months - 1.day)
|
88
|
+
assert_equal "almost 6 years", distance_of_time_in_words(from, to + 5.years + 9.months + 1.day)
|
89
|
+
|
90
|
+
assert_equal "almost 10 years", distance_of_time_in_words(from, to + 10.years - 3.months + 1.day)
|
91
|
+
assert_equal "about 10 years", distance_of_time_in_words(from, to + 10.years + 3.months - 1.day)
|
92
|
+
assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 3.months + 1.day)
|
93
|
+
assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 9.months - 1.day)
|
94
|
+
assert_equal "almost 11 years", distance_of_time_in_words(from, to + 10.years + 9.months + 1.day)
|
95
|
+
|
96
|
+
# test to < from
|
97
|
+
assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to)
|
98
|
+
assert_equal "less than 20 seconds", distance_of_time_in_words(from + 19.seconds, to, true)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_distance_in_words
|
102
|
+
from = Time.mktime(2004, 6, 6, 21, 45, 0)
|
103
|
+
assert_distance_of_time_in_words(from)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_distance_in_words_with_time_zones
|
107
|
+
from = Time.mktime(2004, 6, 6, 21, 45, 0)
|
108
|
+
assert_distance_of_time_in_words(from.in_time_zone('Alaska'))
|
109
|
+
assert_distance_of_time_in_words(from.in_time_zone('Hawaii'))
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_distance_in_words_with_different_time_zones
|
113
|
+
from = Time.mktime(2004, 6, 6, 21, 45, 0)
|
114
|
+
assert_distance_of_time_in_words(
|
115
|
+
from.in_time_zone('Alaska'),
|
116
|
+
from.in_time_zone('Hawaii')
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_distance_in_words_with_dates
|
121
|
+
start_date = Date.new 1975, 1, 31
|
122
|
+
end_date = Date.new 1977, 1, 31
|
123
|
+
assert_equal("about 2 years", distance_of_time_in_words(start_date, end_date))
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_distance_in_words_with_integers
|
127
|
+
assert_equal "less than a minute", distance_of_time_in_words(59)
|
128
|
+
assert_equal "about 1 hour", distance_of_time_in_words(60*60)
|
129
|
+
assert_equal "less than a minute", distance_of_time_in_words(0, 59)
|
130
|
+
assert_equal "about 1 hour", distance_of_time_in_words(60*60, 0)
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_time_ago_in_words
|
134
|
+
assert_equal "about 1 year", time_ago_in_words(1.year.ago - 1.day)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_select_day
|
138
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
139
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
140
|
+
expected << "</select>\n"
|
141
|
+
|
142
|
+
assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16))
|
143
|
+
assert_dom_equal expected, select_day(16)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_select_day_with_blank
|
147
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
148
|
+
expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
149
|
+
expected << "</select>\n"
|
150
|
+
|
151
|
+
assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true)
|
152
|
+
assert_dom_equal expected, select_day(16, :include_blank => true)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_select_day_nil_with_blank
|
156
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
157
|
+
expected << %(<option value=""></option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
158
|
+
expected << "</select>\n"
|
159
|
+
|
160
|
+
assert_dom_equal expected, select_day(nil, :include_blank => true)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_select_day_with_html_options
|
164
|
+
expected = %(<select id="date_day" name="date[day]" class="selector">\n)
|
165
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
166
|
+
expected << "</select>\n"
|
167
|
+
|
168
|
+
assert_dom_equal expected, select_day(Time.mktime(2003, 8, 16), {}, :class => 'selector')
|
169
|
+
assert_dom_equal expected, select_day(16, {}, :class => 'selector')
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_select_day_with_default_prompt
|
173
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
174
|
+
expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
175
|
+
expected << "</select>\n"
|
176
|
+
|
177
|
+
assert_dom_equal expected, select_day(16, :prompt => true)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_select_day_with_custom_prompt
|
181
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
182
|
+
expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
183
|
+
expected << "</select>\n"
|
184
|
+
|
185
|
+
assert_dom_equal expected, select_day(16, :prompt => 'Choose day')
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_select_month
|
189
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
190
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
191
|
+
expected << "</select>\n"
|
192
|
+
|
193
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16))
|
194
|
+
assert_dom_equal expected, select_month(8)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_select_month_with_disabled
|
198
|
+
expected = %(<select id="date_month" name="date[month]" disabled="disabled">\n)
|
199
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
200
|
+
expected << "</select>\n"
|
201
|
+
|
202
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true)
|
203
|
+
assert_dom_equal expected, select_month(8, :disabled => true)
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_select_month_with_field_name_override
|
207
|
+
expected = %(<select id="date_mois" name="date[mois]">\n)
|
208
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
209
|
+
expected << "</select>\n"
|
210
|
+
|
211
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :field_name => 'mois')
|
212
|
+
assert_dom_equal expected, select_month(8, :field_name => 'mois')
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_select_month_with_blank
|
216
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
217
|
+
expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
218
|
+
expected << "</select>\n"
|
219
|
+
|
220
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :include_blank => true)
|
221
|
+
assert_dom_equal expected, select_month(8, :include_blank => true)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_select_month_nil_with_blank
|
225
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
226
|
+
expected << %(<option value=""></option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
227
|
+
expected << "</select>\n"
|
228
|
+
|
229
|
+
assert_dom_equal expected, select_month(nil, :include_blank => true)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_select_month_with_numbers
|
233
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
234
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8" selected="selected">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n)
|
235
|
+
expected << "</select>\n"
|
236
|
+
|
237
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true)
|
238
|
+
assert_dom_equal expected, select_month(8, :use_month_numbers => true)
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_select_month_with_numbers_and_names
|
242
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
243
|
+
expected << %(<option value="1">1 - January</option>\n<option value="2">2 - February</option>\n<option value="3">3 - March</option>\n<option value="4">4 - April</option>\n<option value="5">5 - May</option>\n<option value="6">6 - June</option>\n<option value="7">7 - July</option>\n<option value="8" selected="selected">8 - August</option>\n<option value="9">9 - September</option>\n<option value="10">10 - October</option>\n<option value="11">11 - November</option>\n<option value="12">12 - December</option>\n)
|
244
|
+
expected << "</select>\n"
|
245
|
+
|
246
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true)
|
247
|
+
assert_dom_equal expected, select_month(8, :add_month_numbers => true)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_select_month_with_numbers_and_names_with_abbv
|
251
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
252
|
+
expected << %(<option value="1">1 - Jan</option>\n<option value="2">2 - Feb</option>\n<option value="3">3 - Mar</option>\n<option value="4">4 - Apr</option>\n<option value="5">5 - May</option>\n<option value="6">6 - Jun</option>\n<option value="7">7 - Jul</option>\n<option value="8" selected="selected">8 - Aug</option>\n<option value="9">9 - Sep</option>\n<option value="10">10 - Oct</option>\n<option value="11">11 - Nov</option>\n<option value="12">12 - Dec</option>\n)
|
253
|
+
expected << "</select>\n"
|
254
|
+
|
255
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true)
|
256
|
+
assert_dom_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_select_month_with_abbv
|
260
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
261
|
+
expected << %(<option value="1">Jan</option>\n<option value="2">Feb</option>\n<option value="3">Mar</option>\n<option value="4">Apr</option>\n<option value="5">May</option>\n<option value="6">Jun</option>\n<option value="7">Jul</option>\n<option value="8" selected="selected">Aug</option>\n<option value="9">Sep</option>\n<option value="10">Oct</option>\n<option value="11">Nov</option>\n<option value="12">Dec</option>\n)
|
262
|
+
expected << "</select>\n"
|
263
|
+
|
264
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true)
|
265
|
+
assert_dom_equal expected, select_month(8, :use_short_month => true)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_select_month_with_custom_names
|
269
|
+
month_names = %w(nil Januar Februar Marts April Maj Juni Juli August September Oktober November December)
|
270
|
+
|
271
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
272
|
+
1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month]}</option>\n) }
|
273
|
+
expected << "</select>\n"
|
274
|
+
|
275
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names)
|
276
|
+
assert_dom_equal expected, select_month(8, :use_month_names => month_names)
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_select_month_with_zero_indexed_custom_names
|
280
|
+
month_names = %w(Januar Februar Marts April Maj Juni Juli August September Oktober November December)
|
281
|
+
|
282
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
283
|
+
1.upto(12) { |month| expected << %(<option value="#{month}"#{' selected="selected"' if month == 8}>#{month_names[month-1]}</option>\n) }
|
284
|
+
expected << "</select>\n"
|
285
|
+
|
286
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_names => month_names)
|
287
|
+
assert_dom_equal expected, select_month(8, :use_month_names => month_names)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_select_month_with_hidden
|
291
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_month\" name=\"date[month]\" value=\"8\" />\n", select_month(8, :use_hidden => true)
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_select_month_with_hidden_and_field_name
|
295
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_mois\" name=\"date[mois]\" value=\"8\" />\n", select_month(8, :use_hidden => true, :field_name => 'mois')
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_select_month_with_html_options
|
299
|
+
expected = %(<select id="date_month" name="date[month]" class="selector" accesskey="M">\n)
|
300
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
301
|
+
expected << "</select>\n"
|
302
|
+
|
303
|
+
assert_dom_equal expected, select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M')
|
304
|
+
#result = select_month(Time.mktime(2003, 8, 16), {}, :class => 'selector', :accesskey => 'M')
|
305
|
+
#assert result.include?('<select id="date_month" name="date[month]"')
|
306
|
+
#assert result.include?('class="selector"')
|
307
|
+
#assert result.include?('accesskey="M"')
|
308
|
+
#assert result.include?('<option value="1">January')
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_select_month_with_default_prompt
|
312
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
313
|
+
expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
314
|
+
expected << "</select>\n"
|
315
|
+
|
316
|
+
assert_dom_equal expected, select_month(8, :prompt => true)
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_select_month_with_custom_prompt
|
320
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
321
|
+
expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
322
|
+
expected << "</select>\n"
|
323
|
+
|
324
|
+
assert_dom_equal expected, select_month(8, :prompt => 'Choose month')
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_select_year
|
328
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
329
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
330
|
+
expected << "</select>\n"
|
331
|
+
|
332
|
+
assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005)
|
333
|
+
assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_select_year_with_disabled
|
337
|
+
expected = %(<select id="date_year" name="date[year]" disabled="disabled">\n)
|
338
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
339
|
+
expected << "</select>\n"
|
340
|
+
|
341
|
+
assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005)
|
342
|
+
assert_dom_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005)
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_select_year_with_field_name_override
|
346
|
+
expected = %(<select id="date_annee" name="date[annee]">\n)
|
347
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
348
|
+
expected << "</select>\n"
|
349
|
+
|
350
|
+
assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :field_name => 'annee')
|
351
|
+
assert_dom_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee')
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_select_year_with_type_discarding
|
355
|
+
expected = %(<select id="date_year" name="date_year">\n)
|
356
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
357
|
+
expected << "</select>\n"
|
358
|
+
|
359
|
+
assert_dom_equal expected, select_year(
|
360
|
+
Time.mktime(2003, 8, 16), :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005)
|
361
|
+
assert_dom_equal expected, select_year(
|
362
|
+
2003, :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005)
|
363
|
+
end
|
364
|
+
|
365
|
+
def test_select_year_descending
|
366
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
367
|
+
expected << %(<option value="2005" selected="selected">2005</option>\n<option value="2004">2004</option>\n<option value="2003">2003</option>\n)
|
368
|
+
expected << "</select>\n"
|
369
|
+
|
370
|
+
assert_dom_equal expected, select_year(Time.mktime(2005, 8, 16), :start_year => 2005, :end_year => 2003)
|
371
|
+
assert_dom_equal expected, select_year(2005, :start_year => 2005, :end_year => 2003)
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_select_year_with_hidden
|
375
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_year\" name=\"date[year]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true)
|
376
|
+
end
|
377
|
+
|
378
|
+
def test_select_year_with_hidden_and_field_name
|
379
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_anno\" name=\"date[anno]\" value=\"2007\" />\n", select_year(2007, :use_hidden => true, :field_name => 'anno')
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_select_year_with_html_options
|
383
|
+
expected = %(<select id="date_year" name="date[year]" class="selector" accesskey="M">\n)
|
384
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
385
|
+
expected << "</select>\n"
|
386
|
+
|
387
|
+
assert_dom_equal expected, select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M')
|
388
|
+
#result = select_year(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005}, :class => 'selector', :accesskey => 'M')
|
389
|
+
#assert result.include?('<select id="date_year" name="date[year]"')
|
390
|
+
#assert result.include?('class="selector"')
|
391
|
+
#assert result.include?('accesskey="M"')
|
392
|
+
#assert result.include?('<option value="2003"')
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_select_year_with_default_prompt
|
396
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
397
|
+
expected << %(<option value="">Year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
398
|
+
expected << "</select>\n"
|
399
|
+
|
400
|
+
assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => true)
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_select_year_with_custom_prompt
|
404
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
405
|
+
expected << %(<option value="">Choose year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
406
|
+
expected << "</select>\n"
|
407
|
+
|
408
|
+
assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => 'Choose year')
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_select_hour
|
412
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
413
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
414
|
+
expected << "</select>\n"
|
415
|
+
|
416
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18))
|
417
|
+
end
|
418
|
+
|
419
|
+
def test_select_hour_with_disabled
|
420
|
+
expected = %(<select id="date_hour" name="date[hour]" disabled="disabled">\n)
|
421
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
422
|
+
expected << "</select>\n"
|
423
|
+
|
424
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_select_hour_with_field_name_override
|
428
|
+
expected = %(<select id="date_heure" name="date[heure]">\n)
|
429
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
430
|
+
expected << "</select>\n"
|
431
|
+
|
432
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'heure')
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_select_hour_with_blank
|
436
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
437
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
438
|
+
expected << "</select>\n"
|
439
|
+
|
440
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true)
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_select_hour_nil_with_blank
|
444
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
445
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
446
|
+
expected << "</select>\n"
|
447
|
+
|
448
|
+
assert_dom_equal expected, select_hour(nil, :include_blank => true)
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_select_hour_with_html_options
|
452
|
+
expected = %(<select id="date_hour" name="date[hour]" class="selector" accesskey="M">\n)
|
453
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
454
|
+
expected << "</select>\n"
|
455
|
+
|
456
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_select_hour_with_default_prompt
|
460
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
461
|
+
expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
462
|
+
expected << "</select>\n"
|
463
|
+
|
464
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_select_hour_with_custom_prompt
|
468
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
469
|
+
expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
470
|
+
expected << "</select>\n"
|
471
|
+
|
472
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose hour')
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_select_minute
|
476
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
477
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
478
|
+
expected << "</select>\n"
|
479
|
+
|
480
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18))
|
481
|
+
end
|
482
|
+
|
483
|
+
def test_select_minute_with_disabled
|
484
|
+
expected = %(<select id="date_minute" name="date[minute]" disabled="disabled">\n)
|
485
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
486
|
+
expected << "</select>\n"
|
487
|
+
|
488
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
|
489
|
+
end
|
490
|
+
|
491
|
+
def test_select_minute_with_field_name_override
|
492
|
+
expected = %(<select id="date_minuto" name="date[minuto]">\n)
|
493
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
494
|
+
expected << "</select>\n"
|
495
|
+
|
496
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'minuto')
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_select_minute_with_blank
|
500
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
501
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
502
|
+
expected << "</select>\n"
|
503
|
+
|
504
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true)
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_select_minute_with_blank_and_step
|
508
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
509
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n)
|
510
|
+
expected << "</select>\n"
|
511
|
+
|
512
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 })
|
513
|
+
end
|
514
|
+
|
515
|
+
def test_select_minute_nil_with_blank
|
516
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
517
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
518
|
+
expected << "</select>\n"
|
519
|
+
|
520
|
+
assert_dom_equal expected, select_minute(nil, :include_blank => true)
|
521
|
+
end
|
522
|
+
|
523
|
+
def test_select_minute_nil_with_blank_and_step
|
524
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
525
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n)
|
526
|
+
expected << "</select>\n"
|
527
|
+
|
528
|
+
assert_dom_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 })
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_select_minute_with_hidden
|
532
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_minute\" name=\"date[minute]\" value=\"8\" />\n", select_minute(8, :use_hidden => true)
|
533
|
+
end
|
534
|
+
|
535
|
+
def test_select_minute_with_hidden_and_field_name
|
536
|
+
assert_dom_equal "<input type=\"hidden\" id=\"date_minuto\" name=\"date[minuto]\" value=\"8\" />\n", select_minute(8, :use_hidden => true, :field_name => 'minuto')
|
537
|
+
end
|
538
|
+
|
539
|
+
def test_select_minute_with_html_options
|
540
|
+
expected = expected = %(<select id="date_minute" name="date[minute]" class="selector" accesskey="M">\n)
|
541
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
542
|
+
expected << "</select>\n"
|
543
|
+
|
544
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
545
|
+
|
546
|
+
#result = select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
547
|
+
#assert result.include?('<select id="date_minute" name="date[minute]"')
|
548
|
+
#assert result.include?('class="selector"')
|
549
|
+
#assert result.include?('accesskey="M"')
|
550
|
+
#assert result.include?('<option value="00">00')
|
551
|
+
end
|
552
|
+
|
553
|
+
def test_select_minute_with_default_prompt
|
554
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
555
|
+
expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
556
|
+
expected << "</select>\n"
|
557
|
+
|
558
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_select_minute_with_custom_prompt
|
562
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
563
|
+
expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
564
|
+
expected << "</select>\n"
|
565
|
+
|
566
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose minute')
|
567
|
+
end
|
568
|
+
|
569
|
+
def test_select_second
|
570
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
571
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
572
|
+
expected << "</select>\n"
|
573
|
+
|
574
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18))
|
575
|
+
end
|
576
|
+
|
577
|
+
def test_select_second_with_disabled
|
578
|
+
expected = %(<select id="date_second" name="date[second]" disabled="disabled">\n)
|
579
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
580
|
+
expected << "</select>\n"
|
581
|
+
|
582
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_select_second_with_field_name_override
|
586
|
+
expected = %(<select id="date_segundo" name="date[segundo]">\n)
|
587
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
588
|
+
expected << "</select>\n"
|
589
|
+
|
590
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :field_name => 'segundo')
|
591
|
+
end
|
592
|
+
|
593
|
+
def test_select_second_with_blank
|
594
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
595
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
596
|
+
expected << "</select>\n"
|
597
|
+
|
598
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true)
|
599
|
+
end
|
600
|
+
|
601
|
+
def test_select_second_nil_with_blank
|
602
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
603
|
+
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
604
|
+
expected << "</select>\n"
|
605
|
+
|
606
|
+
assert_dom_equal expected, select_second(nil, :include_blank => true)
|
607
|
+
end
|
608
|
+
|
609
|
+
def test_select_second_with_html_options
|
610
|
+
expected = %(<select id="date_second" name="date[second]" class="selector" accesskey="M">\n)
|
611
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
612
|
+
expected << "</select>\n"
|
613
|
+
|
614
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
615
|
+
|
616
|
+
#result = select_second(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
617
|
+
#assert result.include?('<select id="date_second" name="date[second]"')
|
618
|
+
#assert result.include?('class="selector"')
|
619
|
+
#assert result.include?('accesskey="M"')
|
620
|
+
#assert result.include?('<option value="00">00')
|
621
|
+
end
|
622
|
+
|
623
|
+
def test_select_second_with_default_prompt
|
624
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
625
|
+
expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
626
|
+
expected << "</select>\n"
|
627
|
+
|
628
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
629
|
+
end
|
630
|
+
|
631
|
+
def test_select_second_with_custom_prompt
|
632
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
633
|
+
expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
634
|
+
expected << "</select>\n"
|
635
|
+
|
636
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose seconds')
|
637
|
+
end
|
638
|
+
|
639
|
+
def test_select_date
|
640
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
641
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
642
|
+
expected << "</select>\n"
|
643
|
+
|
644
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
645
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
646
|
+
expected << "</select>\n"
|
647
|
+
|
648
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
649
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
650
|
+
expected << "</select>\n"
|
651
|
+
|
652
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]")
|
653
|
+
end
|
654
|
+
|
655
|
+
def test_select_date_with_order
|
656
|
+
expected = %(<select id="date_first_month" name="date[first][month]">\n)
|
657
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
658
|
+
expected << "</select>\n"
|
659
|
+
|
660
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
661
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
662
|
+
expected << "</select>\n"
|
663
|
+
|
664
|
+
expected << %(<select id="date_first_year" name="date[first][year]">\n)
|
665
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
666
|
+
expected << "</select>\n"
|
667
|
+
|
668
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:month, :day, :year])
|
669
|
+
end
|
670
|
+
|
671
|
+
def test_select_date_with_incomplete_order
|
672
|
+
# NOTE: modified this test because of minimal API change
|
673
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
674
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
675
|
+
expected << "</select>\n"
|
676
|
+
|
677
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
678
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
679
|
+
expected << "</select>\n"
|
680
|
+
|
681
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
682
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
683
|
+
expected << "</select>\n"
|
684
|
+
|
685
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day])
|
686
|
+
end
|
687
|
+
|
688
|
+
def test_select_date_with_disabled
|
689
|
+
expected = %(<select id="date_first_year" name="date[first][year]" disabled="disabled">\n)
|
690
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
691
|
+
expected << "</select>\n"
|
692
|
+
|
693
|
+
expected << %(<select id="date_first_month" name="date[first][month]" disabled="disabled">\n)
|
694
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
695
|
+
expected << "</select>\n"
|
696
|
+
|
697
|
+
expected << %(<select id="date_first_day" name="date[first][day]" disabled="disabled">\n)
|
698
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
699
|
+
expected << "</select>\n"
|
700
|
+
|
701
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true)
|
702
|
+
end
|
703
|
+
|
704
|
+
def test_select_date_with_no_start_year
|
705
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
706
|
+
(Date.today.year-5).upto(Date.today.year+1) do |y|
|
707
|
+
if y == Date.today.year
|
708
|
+
expected << %(<option value="#{y}" selected="selected">#{y}</option>\n)
|
709
|
+
else
|
710
|
+
expected << %(<option value="#{y}">#{y}</option>\n)
|
711
|
+
end
|
712
|
+
end
|
713
|
+
expected << "</select>\n"
|
714
|
+
|
715
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
716
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
717
|
+
expected << "</select>\n"
|
718
|
+
|
719
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
720
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
721
|
+
expected << "</select>\n"
|
722
|
+
|
723
|
+
assert_dom_equal expected, select_date(
|
724
|
+
Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]"
|
725
|
+
)
|
726
|
+
end
|
727
|
+
|
728
|
+
def test_select_date_with_no_end_year
|
729
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
730
|
+
2003.upto(2008) do |y|
|
731
|
+
if y == 2003
|
732
|
+
expected << %(<option value="#{y}" selected="selected">#{y}</option>\n)
|
733
|
+
else
|
734
|
+
expected << %(<option value="#{y}">#{y}</option>\n)
|
735
|
+
end
|
736
|
+
end
|
737
|
+
expected << "</select>\n"
|
738
|
+
|
739
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
740
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
741
|
+
expected << "</select>\n"
|
742
|
+
|
743
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
744
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
745
|
+
expected << "</select>\n"
|
746
|
+
|
747
|
+
assert_dom_equal expected, select_date(
|
748
|
+
Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]"
|
749
|
+
)
|
750
|
+
end
|
751
|
+
|
752
|
+
def test_select_date_with_no_start_or_end_year
|
753
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
754
|
+
(Date.today.year-5).upto(Date.today.year+5) do |y|
|
755
|
+
if y == Date.today.year
|
756
|
+
expected << %(<option value="#{y}" selected="selected">#{y}</option>\n)
|
757
|
+
else
|
758
|
+
expected << %(<option value="#{y}">#{y}</option>\n)
|
759
|
+
end
|
760
|
+
end
|
761
|
+
expected << "</select>\n"
|
762
|
+
|
763
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
764
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
765
|
+
expected << "</select>\n"
|
766
|
+
|
767
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
768
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
769
|
+
expected << "</select>\n"
|
770
|
+
|
771
|
+
assert_dom_equal expected, select_date(
|
772
|
+
Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]"
|
773
|
+
)
|
774
|
+
end
|
775
|
+
|
776
|
+
def test_select_date_with_zero_value
|
777
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
778
|
+
expected << %(<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
779
|
+
expected << "</select>\n"
|
780
|
+
|
781
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
782
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
783
|
+
expected << "</select>\n"
|
784
|
+
|
785
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
786
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
787
|
+
expected << "</select>\n"
|
788
|
+
|
789
|
+
assert_dom_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]")
|
790
|
+
end
|
791
|
+
|
792
|
+
def test_select_date_with_zero_value_and_no_start_year
|
793
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
794
|
+
(Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
795
|
+
expected << "</select>\n"
|
796
|
+
|
797
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
798
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
799
|
+
expected << "</select>\n"
|
800
|
+
|
801
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
802
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
803
|
+
expected << "</select>\n"
|
804
|
+
|
805
|
+
assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]")
|
806
|
+
end
|
807
|
+
|
808
|
+
def test_select_date_with_zero_value_and_no_end_year
|
809
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
810
|
+
last_year = Time.now.year + 5
|
811
|
+
2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
812
|
+
expected << "</select>\n"
|
813
|
+
|
814
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
815
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
816
|
+
expected << "</select>\n"
|
817
|
+
|
818
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
819
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
820
|
+
expected << "</select>\n"
|
821
|
+
|
822
|
+
assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]")
|
823
|
+
end
|
824
|
+
|
825
|
+
def test_select_date_with_zero_value_and_no_start_and_end_year
|
826
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
827
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
828
|
+
expected << "</select>\n"
|
829
|
+
|
830
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
831
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
832
|
+
expected << "</select>\n"
|
833
|
+
|
834
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
835
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
836
|
+
expected << "</select>\n"
|
837
|
+
|
838
|
+
assert_dom_equal expected, select_date(0, :prefix => "date[first]")
|
839
|
+
end
|
840
|
+
|
841
|
+
def test_select_date_with_nil_value_and_no_start_and_end_year
|
842
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
843
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
844
|
+
expected << "</select>\n"
|
845
|
+
|
846
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
847
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
848
|
+
expected << "</select>\n"
|
849
|
+
|
850
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
851
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
852
|
+
expected << "</select>\n"
|
853
|
+
|
854
|
+
assert_dom_equal expected, select_date(nil, :prefix => "date[first]")
|
855
|
+
end
|
856
|
+
|
857
|
+
def test_select_date_with_html_options
|
858
|
+
expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n)
|
859
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
860
|
+
expected << "</select>\n"
|
861
|
+
|
862
|
+
expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n)
|
863
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
864
|
+
expected << "</select>\n"
|
865
|
+
|
866
|
+
expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n)
|
867
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
868
|
+
expected << "</select>\n"
|
869
|
+
|
870
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => "selector")
|
871
|
+
end
|
872
|
+
|
873
|
+
def test_select_date_with_separator
|
874
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
875
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
876
|
+
expected << "</select>\n"
|
877
|
+
|
878
|
+
expected << " / "
|
879
|
+
|
880
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
881
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
882
|
+
expected << "</select>\n"
|
883
|
+
|
884
|
+
expected << " / "
|
885
|
+
|
886
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
887
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
888
|
+
expected << "</select>\n"
|
889
|
+
|
890
|
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), { :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"})
|
891
|
+
end
|
892
|
+
|
893
|
+
def test_select_datetime
|
894
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
895
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
896
|
+
expected << "</select>\n"
|
897
|
+
|
898
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
899
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
900
|
+
expected << "</select>\n"
|
901
|
+
|
902
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
903
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
904
|
+
expected << "</select>\n"
|
905
|
+
|
906
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
907
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
908
|
+
expected << "</select>\n"
|
909
|
+
|
910
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
911
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
912
|
+
expected << "</select>\n"
|
913
|
+
|
914
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]")
|
915
|
+
end
|
916
|
+
|
917
|
+
def test_select_datetime_with_separators
|
918
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
919
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
920
|
+
expected << "</select>\n"
|
921
|
+
|
922
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
923
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
924
|
+
expected << "</select>\n"
|
925
|
+
|
926
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
927
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
928
|
+
expected << "</select>\n"
|
929
|
+
|
930
|
+
expected << " — "
|
931
|
+
|
932
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
933
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
934
|
+
expected << "</select>\n"
|
935
|
+
|
936
|
+
expected << " : "
|
937
|
+
|
938
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
939
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
940
|
+
expected << "</select>\n"
|
941
|
+
|
942
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :datetime_separator => ' — ', :time_separator => ' : ')
|
943
|
+
end
|
944
|
+
|
945
|
+
def test_select_datetime_with_nil_value_and_no_start_and_end_year
|
946
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
947
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
948
|
+
expected << "</select>\n"
|
949
|
+
|
950
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
951
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
952
|
+
expected << "</select>\n"
|
953
|
+
|
954
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
955
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
956
|
+
expected << "</select>\n"
|
957
|
+
|
958
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
959
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
960
|
+
expected << "</select>\n"
|
961
|
+
|
962
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
963
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
964
|
+
expected << "</select>\n"
|
965
|
+
|
966
|
+
assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]")
|
967
|
+
end
|
968
|
+
|
969
|
+
def test_select_datetime_with_html_options
|
970
|
+
expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n)
|
971
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
972
|
+
expected << "</select>\n"
|
973
|
+
|
974
|
+
expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n)
|
975
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
976
|
+
expected << "</select>\n"
|
977
|
+
|
978
|
+
expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n)
|
979
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
980
|
+
expected << "</select>\n"
|
981
|
+
|
982
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n)
|
983
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
984
|
+
expected << "</select>\n"
|
985
|
+
|
986
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n)
|
987
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
988
|
+
expected << "</select>\n"
|
989
|
+
|
990
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), {:start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector')
|
991
|
+
end
|
992
|
+
|
993
|
+
def test_select_datetime_with_all_separators
|
994
|
+
expected = %(<select id="date_first_year" name="date[first][year]" class="selector">\n)
|
995
|
+
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
996
|
+
expected << "</select>\n"
|
997
|
+
|
998
|
+
expected << "/"
|
999
|
+
|
1000
|
+
expected << %(<select id="date_first_month" name="date[first][month]" class="selector">\n)
|
1001
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1002
|
+
expected << "</select>\n"
|
1003
|
+
|
1004
|
+
expected << "/"
|
1005
|
+
|
1006
|
+
expected << %(<select id="date_first_day" name="date[first][day]" class="selector">\n)
|
1007
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1008
|
+
expected << "</select>\n"
|
1009
|
+
|
1010
|
+
expected << "—"
|
1011
|
+
|
1012
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n)
|
1013
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1014
|
+
expected << "</select>\n"
|
1015
|
+
|
1016
|
+
expected << ":"
|
1017
|
+
|
1018
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]" class="selector">\n)
|
1019
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1020
|
+
expected << "</select>\n"
|
1021
|
+
|
1022
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), { :datetime_separator => "—", :date_separator => "/", :time_separator => ":", :start_year => 2003, :end_year => 2005, :prefix => "date[first]"}, :class => 'selector')
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
def test_select_datetime_should_work_with_date
|
1026
|
+
assert_nothing_raised { select_datetime(Date.today) }
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
def test_select_datetime_with_default_prompt
|
1030
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1031
|
+
expected << %(<option value="">Year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
1032
|
+
expected << "</select>\n"
|
1033
|
+
|
1034
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1035
|
+
expected << %(<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1036
|
+
expected << "</select>\n"
|
1037
|
+
|
1038
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1039
|
+
expected << %(<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1040
|
+
expected << "</select>\n"
|
1041
|
+
|
1042
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
1043
|
+
expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1044
|
+
expected << "</select>\n"
|
1045
|
+
|
1046
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
1047
|
+
expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1048
|
+
expected << "</select>\n"
|
1049
|
+
|
1050
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005,
|
1051
|
+
:prefix => "date[first]", :prompt => true)
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
def test_select_datetime_with_custom_prompt
|
1055
|
+
|
1056
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1057
|
+
expected << %(<option value="">Choose year</option>\n<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
1058
|
+
expected << "</select>\n"
|
1059
|
+
|
1060
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1061
|
+
expected << %(<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1062
|
+
expected << "</select>\n"
|
1063
|
+
|
1064
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1065
|
+
expected << %(<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1066
|
+
expected << "</select>\n"
|
1067
|
+
|
1068
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
1069
|
+
expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1070
|
+
expected << "</select>\n"
|
1071
|
+
|
1072
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
1073
|
+
expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1074
|
+
expected << "</select>\n"
|
1075
|
+
|
1076
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]",
|
1077
|
+
:prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year', :hour => 'Choose hour', :minute => 'Choose minute'})
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
def test_select_time
|
1081
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1082
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1083
|
+
expected << "</select>\n"
|
1084
|
+
|
1085
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1086
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1087
|
+
expected << "</select>\n"
|
1088
|
+
|
1089
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18))
|
1090
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => false)
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
def test_select_time_with_separator
|
1094
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1095
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1096
|
+
expected << "</select>\n"
|
1097
|
+
|
1098
|
+
expected << " : "
|
1099
|
+
|
1100
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1101
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1102
|
+
expected << "</select>\n"
|
1103
|
+
|
1104
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ')
|
1105
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :time_separator => ' : ', :include_seconds => false)
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
def test_select_time_with_seconds
|
1109
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1110
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1111
|
+
expected << "</select>\n"
|
1112
|
+
|
1113
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1114
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1115
|
+
expected << "</select>\n"
|
1116
|
+
|
1117
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1118
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1119
|
+
expected << "</select>\n"
|
1120
|
+
|
1121
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true)
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
def test_select_time_with_seconds_and_separator
|
1125
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1126
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1127
|
+
expected << "</select>\n"
|
1128
|
+
|
1129
|
+
expected << " : "
|
1130
|
+
|
1131
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1132
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1133
|
+
expected << "</select>\n"
|
1134
|
+
|
1135
|
+
expected << " : "
|
1136
|
+
|
1137
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1138
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1139
|
+
expected << "</select>\n"
|
1140
|
+
|
1141
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :time_separator => ' : ')
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
def test_select_time_with_html_options
|
1145
|
+
expected = %(<select id="date_hour" name="date[hour]" class="selector">\n)
|
1146
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1147
|
+
expected << "</select>\n"
|
1148
|
+
|
1149
|
+
expected << %(<select id="date_minute" name="date[minute]" class="selector">\n)
|
1150
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1151
|
+
expected << "</select>\n"
|
1152
|
+
|
1153
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector')
|
1154
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {:include_seconds => false}, :class => 'selector')
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
def test_select_time_should_work_with_date
|
1158
|
+
assert_nothing_raised { select_time(Date.today) }
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
def test_select_time_with_default_prompt
|
1162
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1163
|
+
expected << %(<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1164
|
+
expected << "</select>\n"
|
1165
|
+
|
1166
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1167
|
+
expected << %(<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1168
|
+
expected << "</select>\n"
|
1169
|
+
|
1170
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1171
|
+
expected << %(<option value="">Seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1172
|
+
expected << "</select>\n"
|
1173
|
+
|
1174
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :prompt => true)
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
def test_select_time_with_custom_prompt
|
1178
|
+
|
1179
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1180
|
+
expected << %(<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08" selected="selected">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
1181
|
+
expected << "</select>\n"
|
1182
|
+
|
1183
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1184
|
+
expected << %(<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04" selected="selected">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1185
|
+
expected << "</select>\n"
|
1186
|
+
|
1187
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1188
|
+
expected << %(<option value="">Choose seconds</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18" selected="selected">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
1189
|
+
expected << "</select>\n"
|
1190
|
+
|
1191
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true, :include_seconds => true,
|
1192
|
+
:prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
def test_date_select
|
1196
|
+
@post = Post.new
|
1197
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1198
|
+
|
1199
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1200
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1201
|
+
expected << "</select>\n"
|
1202
|
+
|
1203
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1204
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1205
|
+
expected << "</select>\n"
|
1206
|
+
|
1207
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1208
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1209
|
+
|
1210
|
+
expected << "</select>\n"
|
1211
|
+
|
1212
|
+
assert_dom_equal expected, date_select("post", "written_on")
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
def test_date_select_without_day
|
1216
|
+
@post = Post.new
|
1217
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1218
|
+
|
1219
|
+
expected = "<input type=\"hidden\" id=\"post_written_on_3i\" name=\"post[written_on(3i)]\" value=\"1\" />\n"
|
1220
|
+
|
1221
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1222
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1223
|
+
expected << "</select>\n"
|
1224
|
+
|
1225
|
+
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1226
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1227
|
+
expected << "</select>\n"
|
1228
|
+
|
1229
|
+
assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ])
|
1230
|
+
end
|
1231
|
+
|
1232
|
+
def test_date_select_without_day_and_with_disabled_html_option
|
1233
|
+
@post = Post.new
|
1234
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1235
|
+
|
1236
|
+
expected = "<input type=\"hidden\" id=\"post_written_on_3i\" disabled=\"disabled\" name=\"post[written_on(3i)]\" value=\"1\" />\n"
|
1237
|
+
|
1238
|
+
expected << %{<select id="post_written_on_2i" disabled="disabled" name="post[written_on(2i)]">\n}
|
1239
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1240
|
+
expected << "</select>\n"
|
1241
|
+
|
1242
|
+
expected << %{<select id="post_written_on_1i" disabled="disabled" name="post[written_on(1i)]">\n}
|
1243
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1244
|
+
expected << "</select>\n"
|
1245
|
+
|
1246
|
+
assert_dom_equal expected, date_select("post", "written_on", { :order => [ :month, :year ] }, :disabled => true)
|
1247
|
+
end
|
1248
|
+
|
1249
|
+
def test_date_select_within_fields_for
|
1250
|
+
@post = Post.new
|
1251
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1252
|
+
|
1253
|
+
fields_for :post, @post do |f|
|
1254
|
+
concat f.date_select(:written_on)
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
expected = "<select id='post_written_on_1i' name='post[written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n"
|
1258
|
+
expected << "<select id='post_written_on_2i' name='post[written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n"
|
1259
|
+
expected << "<select id='post_written_on_3i' name='post[written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n"
|
1260
|
+
|
1261
|
+
assert_dom_equal(expected, output_buffer)
|
1262
|
+
end
|
1263
|
+
|
1264
|
+
def test_date_select_within_fields_for_with_index
|
1265
|
+
@post = Post.new
|
1266
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1267
|
+
id = 27
|
1268
|
+
|
1269
|
+
fields_for :post, @post, :index => id do |f|
|
1270
|
+
concat f.date_select(:written_on)
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n"
|
1274
|
+
expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n"
|
1275
|
+
expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n"
|
1276
|
+
|
1277
|
+
assert_dom_equal(expected, output_buffer)
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
def test_date_select_within_fields_for_with_blank_index
|
1281
|
+
@post = Post.new
|
1282
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1283
|
+
id = nil
|
1284
|
+
|
1285
|
+
fields_for :post, @post, :index => id do |f|
|
1286
|
+
concat f.date_select(:written_on)
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
expected = "<select id='post_#{id}_written_on_1i' name='post[#{id}][written_on(1i)]'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n"
|
1290
|
+
expected << "<select id='post_#{id}_written_on_2i' name='post[#{id}][written_on(2i)]'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n"
|
1291
|
+
expected << "<select id='post_#{id}_written_on_3i' name='post[#{id}][written_on(3i)]'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n"
|
1292
|
+
|
1293
|
+
assert_dom_equal(expected, output_buffer)
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
def test_date_select_with_index
|
1297
|
+
@post = Post.new
|
1298
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1299
|
+
id = 456
|
1300
|
+
|
1301
|
+
expected = %{<select id="post_456_written_on_1i" name="post[#{id}][written_on(1i)]">\n}
|
1302
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1303
|
+
expected << "</select>\n"
|
1304
|
+
|
1305
|
+
expected << %{<select id="post_456_written_on_2i" name="post[#{id}][written_on(2i)]">\n}
|
1306
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1307
|
+
expected << "</select>\n"
|
1308
|
+
|
1309
|
+
expected << %{<select id="post_456_written_on_3i" name="post[#{id}][written_on(3i)]">\n}
|
1310
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1311
|
+
expected << "</select>\n"
|
1312
|
+
|
1313
|
+
assert_dom_equal expected, date_select("post", "written_on", :index => id)
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
def test_date_select_with_auto_index
|
1317
|
+
@post = Post.new
|
1318
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1319
|
+
id = 123
|
1320
|
+
|
1321
|
+
expected = %{<select id="post_123_written_on_1i" name="post[#{id}][written_on(1i)]">\n}
|
1322
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1323
|
+
expected << "</select>\n"
|
1324
|
+
|
1325
|
+
expected << %{<select id="post_123_written_on_2i" name="post[#{id}][written_on(2i)]">\n}
|
1326
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1327
|
+
expected << "</select>\n"
|
1328
|
+
|
1329
|
+
expected << %{<select id="post_123_written_on_3i" name="post[#{id}][written_on(3i)]">\n}
|
1330
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1331
|
+
expected << "</select>\n"
|
1332
|
+
|
1333
|
+
assert_dom_equal expected, date_select("post[]", "written_on")
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
def test_date_select_with_different_order
|
1337
|
+
@post = Post.new
|
1338
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1339
|
+
|
1340
|
+
expected = %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1341
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
1342
|
+
expected << "</select>\n"
|
1343
|
+
|
1344
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1345
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
1346
|
+
expected << "</select>\n"
|
1347
|
+
|
1348
|
+
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1349
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
1350
|
+
expected << "</select>\n"
|
1351
|
+
|
1352
|
+
assert_dom_equal expected, date_select("post", "written_on", :order => [:day, :month, :year])
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
def test_date_select_with_nil
|
1356
|
+
@post = Post.new
|
1357
|
+
|
1358
|
+
start_year = Time.now.year-5
|
1359
|
+
end_year = Time.now.year+5
|
1360
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1361
|
+
start_year.upto(end_year) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) }
|
1362
|
+
expected << "</select>\n"
|
1363
|
+
|
1364
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1365
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.month}>#{Date::MONTHNAMES[i]}</option>\n) }
|
1366
|
+
expected << "</select>\n"
|
1367
|
+
|
1368
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1369
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) }
|
1370
|
+
expected << "</select>\n"
|
1371
|
+
|
1372
|
+
assert_dom_equal expected, date_select("post", "written_on")
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
def test_date_select_with_nil_and_blank
|
1376
|
+
@post = Post.new
|
1377
|
+
|
1378
|
+
start_year = Time.now.year-5
|
1379
|
+
end_year = Time.now.year+5
|
1380
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1381
|
+
expected << "<option value=\"\"></option>\n"
|
1382
|
+
start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
1383
|
+
expected << "</select>\n"
|
1384
|
+
|
1385
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1386
|
+
expected << "<option value=\"\"></option>\n"
|
1387
|
+
1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
|
1388
|
+
expected << "</select>\n"
|
1389
|
+
|
1390
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1391
|
+
expected << "<option value=\"\"></option>\n"
|
1392
|
+
1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
1393
|
+
expected << "</select>\n"
|
1394
|
+
|
1395
|
+
assert_dom_equal expected, date_select("post", "written_on", :include_blank => true)
|
1396
|
+
end
|
1397
|
+
|
1398
|
+
def test_date_select_with_nil_and_blank_and_order
|
1399
|
+
@post = Post.new
|
1400
|
+
|
1401
|
+
start_year = Time.now.year-5
|
1402
|
+
end_year = Time.now.year+5
|
1403
|
+
|
1404
|
+
expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n"
|
1405
|
+
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1406
|
+
expected << "<option value=\"\"></option>\n"
|
1407
|
+
start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
1408
|
+
expected << "</select>\n"
|
1409
|
+
|
1410
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1411
|
+
expected << "<option value=\"\"></option>\n"
|
1412
|
+
1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
|
1413
|
+
expected << "</select>\n"
|
1414
|
+
|
1415
|
+
assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true)
|
1416
|
+
end
|
1417
|
+
|
1418
|
+
def test_date_select_with_nil_and_blank_and_order
|
1419
|
+
@post = Post.new
|
1420
|
+
|
1421
|
+
start_year = Time.now.year-5
|
1422
|
+
end_year = Time.now.year+5
|
1423
|
+
|
1424
|
+
expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n"
|
1425
|
+
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1426
|
+
expected << "<option value=\"\"></option>\n"
|
1427
|
+
start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
1428
|
+
expected << "</select>\n"
|
1429
|
+
|
1430
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1431
|
+
expected << "<option value=\"\"></option>\n"
|
1432
|
+
1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
|
1433
|
+
expected << "</select>\n"
|
1434
|
+
|
1435
|
+
assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true)
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
def test_date_select_cant_override_discard_hour
|
1439
|
+
@post = Post.new
|
1440
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1441
|
+
|
1442
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1443
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1444
|
+
expected << "</select>\n"
|
1445
|
+
|
1446
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1447
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1448
|
+
expected << "</select>\n"
|
1449
|
+
|
1450
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1451
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1452
|
+
expected << "</select>\n"
|
1453
|
+
|
1454
|
+
assert_dom_equal expected, date_select("post", "written_on", :discard_hour => false)
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
def test_date_select_with_html_options
|
1458
|
+
@post = Post.new
|
1459
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1460
|
+
|
1461
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n}
|
1462
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1463
|
+
expected << "</select>\n"
|
1464
|
+
|
1465
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n}
|
1466
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1467
|
+
expected << "</select>\n"
|
1468
|
+
|
1469
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n}
|
1470
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1471
|
+
|
1472
|
+
expected << "</select>\n"
|
1473
|
+
|
1474
|
+
assert_dom_equal expected, date_select("post", "written_on", {}, :class => 'selector')
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
def test_date_select_with_html_options_within_fields_for
|
1478
|
+
@post = Post.new
|
1479
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1480
|
+
|
1481
|
+
fields_for :post, @post do |f|
|
1482
|
+
concat f.date_select(:written_on, {}, :class => 'selector')
|
1483
|
+
end
|
1484
|
+
|
1485
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]" class="selector">\n}
|
1486
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1487
|
+
expected << "</select>\n"
|
1488
|
+
|
1489
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]" class="selector">\n}
|
1490
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1491
|
+
expected << "</select>\n"
|
1492
|
+
|
1493
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]" class="selector">\n}
|
1494
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1495
|
+
|
1496
|
+
expected << "</select>\n"
|
1497
|
+
|
1498
|
+
assert_dom_equal expected, output_buffer
|
1499
|
+
end
|
1500
|
+
|
1501
|
+
def test_date_select_with_separator
|
1502
|
+
@post = Post.new
|
1503
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1504
|
+
|
1505
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1506
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1507
|
+
expected << "</select>\n"
|
1508
|
+
|
1509
|
+
expected << " / "
|
1510
|
+
|
1511
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1512
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1513
|
+
expected << "</select>\n"
|
1514
|
+
|
1515
|
+
expected << " / "
|
1516
|
+
|
1517
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1518
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1519
|
+
|
1520
|
+
expected << "</select>\n"
|
1521
|
+
|
1522
|
+
assert_dom_equal expected, date_select("post", "written_on", { :date_separator => " / " })
|
1523
|
+
end
|
1524
|
+
|
1525
|
+
def test_date_select_with_default_prompt
|
1526
|
+
@post = Post.new
|
1527
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1528
|
+
|
1529
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1530
|
+
expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1531
|
+
expected << "</select>\n"
|
1532
|
+
|
1533
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1534
|
+
expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1535
|
+
expected << "</select>\n"
|
1536
|
+
|
1537
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1538
|
+
expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1539
|
+
|
1540
|
+
expected << "</select>\n"
|
1541
|
+
|
1542
|
+
assert_dom_equal expected, date_select("post", "written_on", :prompt => true)
|
1543
|
+
end
|
1544
|
+
|
1545
|
+
def test_date_select_with_custom_prompt
|
1546
|
+
@post = Post.new
|
1547
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1548
|
+
|
1549
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1550
|
+
expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1551
|
+
expected << "</select>\n"
|
1552
|
+
|
1553
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1554
|
+
expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1555
|
+
expected << "</select>\n"
|
1556
|
+
|
1557
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1558
|
+
expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1559
|
+
|
1560
|
+
expected << "</select>\n"
|
1561
|
+
|
1562
|
+
assert_dom_equal expected, date_select("post", "written_on", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day'})
|
1563
|
+
end
|
1564
|
+
|
1565
|
+
def test_time_select
|
1566
|
+
@post = Post.new
|
1567
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1568
|
+
|
1569
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1570
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1571
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1572
|
+
|
1573
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1574
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1575
|
+
expected << "</select>\n"
|
1576
|
+
expected << " : "
|
1577
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1578
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1579
|
+
expected << "</select>\n"
|
1580
|
+
|
1581
|
+
assert_dom_equal expected, time_select("post", "written_on")
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
def test_time_select_without_date_hidden_fields
|
1585
|
+
@post = Post.new
|
1586
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1587
|
+
|
1588
|
+
expected = %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1589
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1590
|
+
expected << "</select>\n"
|
1591
|
+
expected << " : "
|
1592
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1593
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1594
|
+
expected << "</select>\n"
|
1595
|
+
|
1596
|
+
assert_dom_equal expected, time_select("post", "written_on", :ignore_date => true)
|
1597
|
+
end
|
1598
|
+
|
1599
|
+
def test_time_select_with_seconds
|
1600
|
+
@post = Post.new
|
1601
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1602
|
+
|
1603
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1604
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1605
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1606
|
+
|
1607
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1608
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1609
|
+
expected << "</select>\n"
|
1610
|
+
expected << " : "
|
1611
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1612
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1613
|
+
expected << "</select>\n"
|
1614
|
+
expected << " : "
|
1615
|
+
expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n)
|
1616
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) }
|
1617
|
+
expected << "</select>\n"
|
1618
|
+
|
1619
|
+
assert_dom_equal expected, time_select("post", "written_on", :include_seconds => true)
|
1620
|
+
end
|
1621
|
+
|
1622
|
+
def test_time_select_with_html_options
|
1623
|
+
@post = Post.new
|
1624
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1625
|
+
|
1626
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1627
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1628
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1629
|
+
|
1630
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n)
|
1631
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1632
|
+
expected << "</select>\n"
|
1633
|
+
expected << " : "
|
1634
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n)
|
1635
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1636
|
+
expected << "</select>\n"
|
1637
|
+
|
1638
|
+
assert_dom_equal expected, time_select("post", "written_on", {}, :class => 'selector')
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
def test_time_select_with_html_options_within_fields_for
|
1642
|
+
@post = Post.new
|
1643
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1644
|
+
|
1645
|
+
fields_for :post, @post do |f|
|
1646
|
+
concat f.time_select(:written_on, {}, :class => 'selector')
|
1647
|
+
end
|
1648
|
+
|
1649
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1650
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1651
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1652
|
+
|
1653
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]" class="selector">\n)
|
1654
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1655
|
+
expected << "</select>\n"
|
1656
|
+
expected << " : "
|
1657
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]" class="selector">\n)
|
1658
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1659
|
+
expected << "</select>\n"
|
1660
|
+
|
1661
|
+
assert_dom_equal expected, output_buffer
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
def test_time_select_with_separator
|
1665
|
+
@post = Post.new
|
1666
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1667
|
+
|
1668
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1669
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1670
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1671
|
+
|
1672
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1673
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1674
|
+
expected << "</select>\n"
|
1675
|
+
|
1676
|
+
expected << " - "
|
1677
|
+
|
1678
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1679
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1680
|
+
expected << "</select>\n"
|
1681
|
+
|
1682
|
+
expected << " - "
|
1683
|
+
|
1684
|
+
expected << %(<select id="post_written_on_6i" name="post[written_on(6i)]">\n)
|
1685
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) }
|
1686
|
+
expected << "</select>\n"
|
1687
|
+
|
1688
|
+
assert_dom_equal expected, time_select("post", "written_on", { :time_separator => " - ", :include_seconds => true })
|
1689
|
+
end
|
1690
|
+
|
1691
|
+
def test_time_select_with_default_prompt
|
1692
|
+
@post = Post.new
|
1693
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1694
|
+
|
1695
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1696
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1697
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1698
|
+
|
1699
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1700
|
+
expected << %(<option value="">Hour</option>\n)
|
1701
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1702
|
+
expected << "</select>\n"
|
1703
|
+
expected << " : "
|
1704
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1705
|
+
expected << %(<option value="">Minute</option>\n)
|
1706
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1707
|
+
expected << "</select>\n"
|
1708
|
+
|
1709
|
+
assert_dom_equal expected, time_select("post", "written_on", :prompt => true)
|
1710
|
+
end
|
1711
|
+
|
1712
|
+
def test_time_select_with_custom_prompt
|
1713
|
+
@post = Post.new
|
1714
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1715
|
+
|
1716
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1717
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1718
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1719
|
+
|
1720
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1721
|
+
expected << %(<option value="">Choose hour</option>\n)
|
1722
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1723
|
+
expected << "</select>\n"
|
1724
|
+
expected << " : "
|
1725
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1726
|
+
expected << %(<option value="">Choose minute</option>\n)
|
1727
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1728
|
+
expected << "</select>\n"
|
1729
|
+
|
1730
|
+
assert_dom_equal expected, time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute'})
|
1731
|
+
end
|
1732
|
+
|
1733
|
+
def test_time_select_with_disabled_html_option
|
1734
|
+
@post = Post.new
|
1735
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1736
|
+
|
1737
|
+
expected = %{<input type="hidden" id="post_written_on_1i" disabled="disabled" name="post[written_on(1i)]" value="2004" />\n}
|
1738
|
+
expected << %{<input type="hidden" id="post_written_on_2i" disabled="disabled" name="post[written_on(2i)]" value="6" />\n}
|
1739
|
+
expected << %{<input type="hidden" id="post_written_on_3i" disabled="disabled" name="post[written_on(3i)]" value="15" />\n}
|
1740
|
+
|
1741
|
+
expected << %(<select id="post_written_on_4i" disabled="disabled" name="post[written_on(4i)]">\n)
|
1742
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1743
|
+
expected << "</select>\n"
|
1744
|
+
expected << " : "
|
1745
|
+
expected << %(<select id="post_written_on_5i" disabled="disabled" name="post[written_on(5i)]">\n)
|
1746
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1747
|
+
expected << "</select>\n"
|
1748
|
+
|
1749
|
+
assert_dom_equal expected, time_select("post", "written_on", {}, :disabled => true)
|
1750
|
+
end
|
1751
|
+
|
1752
|
+
def test_datetime_select
|
1753
|
+
@post = Post.new
|
1754
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
1755
|
+
|
1756
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1757
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1758
|
+
expected << "</select>\n"
|
1759
|
+
|
1760
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1761
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1762
|
+
expected << "</select>\n"
|
1763
|
+
|
1764
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1765
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1766
|
+
expected << "</select>\n"
|
1767
|
+
|
1768
|
+
expected << " — "
|
1769
|
+
|
1770
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1771
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
1772
|
+
expected << "</select>\n"
|
1773
|
+
expected << " : "
|
1774
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1775
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
1776
|
+
expected << "</select>\n"
|
1777
|
+
|
1778
|
+
assert_dom_equal expected, datetime_select("post", "updated_at")
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set
|
1782
|
+
time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0)
|
1783
|
+
time_zone = mock()
|
1784
|
+
time_zone.expects(:now).returns time
|
1785
|
+
Time.zone_default = time_zone
|
1786
|
+
@post = Post.new
|
1787
|
+
|
1788
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1789
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1790
|
+
expected << "</select>\n"
|
1791
|
+
|
1792
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1793
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1794
|
+
expected << "</select>\n"
|
1795
|
+
|
1796
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1797
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1798
|
+
expected << "</select>\n"
|
1799
|
+
|
1800
|
+
expected << " — "
|
1801
|
+
|
1802
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1803
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
1804
|
+
expected << "</select>\n"
|
1805
|
+
expected << " : "
|
1806
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1807
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
1808
|
+
expected << "</select>\n"
|
1809
|
+
|
1810
|
+
assert_dom_equal expected, datetime_select("post", "updated_at")
|
1811
|
+
ensure
|
1812
|
+
Time.zone_default = nil
|
1813
|
+
end
|
1814
|
+
|
1815
|
+
def test_datetime_select_with_html_options_within_fields_for
|
1816
|
+
@post = Post.new
|
1817
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
1818
|
+
|
1819
|
+
fields_for :post, @post do |f|
|
1820
|
+
concat f.datetime_select(:updated_at, {}, :class => 'selector')
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
expected = "<select id='post_updated_at_1i' name='post[updated_at(1i)]' class='selector'>\n<option value='1999'>1999</option>\n<option value='2000'>2000</option>\n<option value='2001'>2001</option>\n<option value='2002'>2002</option>\n<option value='2003'>2003</option>\n<option selected='selected' value='2004'>2004</option>\n<option value='2005'>2005</option>\n<option value='2006'>2006</option>\n<option value='2007'>2007</option>\n<option value='2008'>2008</option>\n<option value='2009'>2009</option>\n</select>\n"
|
1824
|
+
expected << "<select id='post_updated_at_2i' name='post[updated_at(2i)]' class='selector'>\n<option value='1'>January</option>\n<option value='2'>February</option>\n<option value='3'>March</option>\n<option value='4'>April</option>\n<option value='5'>May</option>\n<option selected='selected' value='6'>June</option>\n<option value='7'>July</option>\n<option value='8'>August</option>\n<option value='9'>September</option>\n<option value='10'>October</option>\n<option value='11'>November</option>\n<option value='12'>December</option>\n</select>\n"
|
1825
|
+
expected << "<select id='post_updated_at_3i' name='post[updated_at(3i)]' class='selector'>\n<option value='1'>1</option>\n<option value='2'>2</option>\n<option value='3'>3</option>\n<option value='4'>4</option>\n<option value='5'>5</option>\n<option value='6'>6</option>\n<option value='7'>7</option>\n<option value='8'>8</option>\n<option value='9'>9</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option selected='selected' value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n</select>\n"
|
1826
|
+
expected << " — <select id='post_updated_at_4i' name='post[updated_at(4i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option selected='selected' value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n</select>\n"
|
1827
|
+
expected << " : <select id='post_updated_at_5i' name='post[updated_at(5i)]' class='selector'>\n<option value='00'>00</option>\n<option value='01'>01</option>\n<option value='02'>02</option>\n<option value='03'>03</option>\n<option value='04'>04</option>\n<option value='05'>05</option>\n<option value='06'>06</option>\n<option value='07'>07</option>\n<option value='08'>08</option>\n<option value='09'>09</option>\n<option value='10'>10</option>\n<option value='11'>11</option>\n<option value='12'>12</option>\n<option value='13'>13</option>\n<option value='14'>14</option>\n<option value='15'>15</option>\n<option value='16'>16</option>\n<option value='17'>17</option>\n<option value='18'>18</option>\n<option value='19'>19</option>\n<option value='20'>20</option>\n<option value='21'>21</option>\n<option value='22'>22</option>\n<option value='23'>23</option>\n<option value='24'>24</option>\n<option value='25'>25</option>\n<option value='26'>26</option>\n<option value='27'>27</option>\n<option value='28'>28</option>\n<option value='29'>29</option>\n<option value='30'>30</option>\n<option value='31'>31</option>\n<option value='32'>32</option>\n<option value='33'>33</option>\n<option value='34'>34</option>\n<option selected='selected' value='35'>35</option>\n<option value='36'>36</option>\n<option value='37'>37</option>\n<option value='38'>38</option>\n<option value='39'>39</option>\n<option value='40'>40</option>\n<option value='41'>41</option>\n<option value='42'>42</option>\n<option value='43'>43</option>\n<option value='44'>44</option>\n<option value='45'>45</option>\n<option value='46'>46</option>\n<option value='47'>47</option>\n<option value='48'>48</option>\n<option value='49'>49</option>\n<option value='50'>50</option>\n<option value='51'>51</option>\n<option value='52'>52</option>\n<option value='53'>53</option>\n<option value='54'>54</option>\n<option value='55'>55</option>\n<option value='56'>56</option>\n<option value='57'>57</option>\n<option value='58'>58</option>\n<option value='59'>59</option>\n</select>\n"
|
1828
|
+
|
1829
|
+
assert_dom_equal expected, output_buffer
|
1830
|
+
end
|
1831
|
+
|
1832
|
+
def test_datetime_select_with_separators
|
1833
|
+
@post = Post.new
|
1834
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
1835
|
+
|
1836
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1837
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1838
|
+
expected << "</select>\n"
|
1839
|
+
|
1840
|
+
expected << " / "
|
1841
|
+
|
1842
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1843
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1844
|
+
expected << "</select>\n"
|
1845
|
+
|
1846
|
+
expected << " / "
|
1847
|
+
|
1848
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1849
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1850
|
+
expected << "</select>\n"
|
1851
|
+
|
1852
|
+
expected << " , "
|
1853
|
+
|
1854
|
+
expected << %(<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n)
|
1855
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1856
|
+
expected << "</select>\n"
|
1857
|
+
|
1858
|
+
expected << " - "
|
1859
|
+
|
1860
|
+
expected << %(<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n)
|
1861
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1862
|
+
expected << "</select>\n"
|
1863
|
+
|
1864
|
+
expected << " - "
|
1865
|
+
|
1866
|
+
expected << %(<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n)
|
1867
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) }
|
1868
|
+
expected << "</select>\n"
|
1869
|
+
|
1870
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true })
|
1871
|
+
end
|
1872
|
+
|
1873
|
+
def test_datetime_select_with_default_prompt
|
1874
|
+
@post = Post.new
|
1875
|
+
@post.updated_at = nil
|
1876
|
+
|
1877
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1878
|
+
expected << %{<option value="">Year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1879
|
+
expected << "</select>\n"
|
1880
|
+
|
1881
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1882
|
+
expected << %{<option value="">Month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1883
|
+
expected << "</select>\n"
|
1884
|
+
|
1885
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1886
|
+
expected << %{<option value="">Day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1887
|
+
expected << "</select>\n"
|
1888
|
+
|
1889
|
+
expected << " — "
|
1890
|
+
|
1891
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1892
|
+
expected << %{<option value="">Hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
1893
|
+
expected << "</select>\n"
|
1894
|
+
expected << " : "
|
1895
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1896
|
+
expected << %{<option value="">Minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
1897
|
+
expected << "</select>\n"
|
1898
|
+
|
1899
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => true)
|
1900
|
+
end
|
1901
|
+
|
1902
|
+
def test_datetime_select_with_custom_prompt
|
1903
|
+
@post = Post.new
|
1904
|
+
@post.updated_at = nil
|
1905
|
+
|
1906
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1907
|
+
expected << %{<option value="">Choose year</option>\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
1908
|
+
expected << "</select>\n"
|
1909
|
+
|
1910
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1911
|
+
expected << %{<option value="">Choose month</option>\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
1912
|
+
expected << "</select>\n"
|
1913
|
+
|
1914
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1915
|
+
expected << %{<option value="">Choose day</option>\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
1916
|
+
expected << "</select>\n"
|
1917
|
+
|
1918
|
+
expected << " — "
|
1919
|
+
|
1920
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1921
|
+
expected << %{<option value="">Choose hour</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
1922
|
+
expected << "</select>\n"
|
1923
|
+
expected << " : "
|
1924
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1925
|
+
expected << %{<option value="">Choose minute</option>\n<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
1926
|
+
expected << "</select>\n"
|
1927
|
+
|
1928
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'})
|
1929
|
+
end
|
1930
|
+
|
1931
|
+
def test_date_select_with_zero_value_and_no_start_year
|
1932
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1933
|
+
(Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
1934
|
+
expected << "</select>\n"
|
1935
|
+
|
1936
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1937
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1938
|
+
expected << "</select>\n"
|
1939
|
+
|
1940
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1941
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1942
|
+
expected << "</select>\n"
|
1943
|
+
|
1944
|
+
assert_dom_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]")
|
1945
|
+
end
|
1946
|
+
|
1947
|
+
def test_date_select_with_zero_value_and_no_end_year
|
1948
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1949
|
+
last_year = Time.now.year + 5
|
1950
|
+
2003.upto(last_year) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
1951
|
+
expected << "</select>\n"
|
1952
|
+
|
1953
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1954
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1955
|
+
expected << "</select>\n"
|
1956
|
+
|
1957
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1958
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1959
|
+
expected << "</select>\n"
|
1960
|
+
|
1961
|
+
assert_dom_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]")
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
def test_date_select_with_zero_value_and_no_start_and_end_year
|
1965
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1966
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
1967
|
+
expected << "</select>\n"
|
1968
|
+
|
1969
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1970
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1971
|
+
expected << "</select>\n"
|
1972
|
+
|
1973
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1974
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1975
|
+
expected << "</select>\n"
|
1976
|
+
|
1977
|
+
assert_dom_equal expected, select_date(0, :prefix => "date[first]")
|
1978
|
+
end
|
1979
|
+
|
1980
|
+
def test_date_select_with_nil_value_and_no_start_and_end_year
|
1981
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1982
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
1983
|
+
expected << "</select>\n"
|
1984
|
+
|
1985
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1986
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
1987
|
+
expected << "</select>\n"
|
1988
|
+
|
1989
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1990
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
1991
|
+
expected << "</select>\n"
|
1992
|
+
|
1993
|
+
assert_dom_equal expected, select_date(nil, :prefix => "date[first]")
|
1994
|
+
end
|
1995
|
+
|
1996
|
+
def test_datetime_select_with_nil_value_and_no_start_and_end_year
|
1997
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1998
|
+
(Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
1999
|
+
expected << "</select>\n"
|
2000
|
+
|
2001
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
2002
|
+
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)
|
2003
|
+
expected << "</select>\n"
|
2004
|
+
|
2005
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
2006
|
+
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
|
2007
|
+
expected << "</select>\n"
|
2008
|
+
|
2009
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
2010
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n)
|
2011
|
+
expected << "</select>\n"
|
2012
|
+
|
2013
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
2014
|
+
expected << %(<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n)
|
2015
|
+
expected << "</select>\n"
|
2016
|
+
|
2017
|
+
assert_dom_equal expected, select_datetime(nil, :prefix => "date[first]")
|
2018
|
+
end
|
2019
|
+
|
2020
|
+
def test_datetime_select_with_options_index
|
2021
|
+
@post = Post.new
|
2022
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
2023
|
+
id = 456
|
2024
|
+
|
2025
|
+
expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n}
|
2026
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
2027
|
+
expected << "</select>\n"
|
2028
|
+
|
2029
|
+
expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n}
|
2030
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
2031
|
+
expected << "</select>\n"
|
2032
|
+
|
2033
|
+
expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n}
|
2034
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
2035
|
+
expected << "</select>\n"
|
2036
|
+
|
2037
|
+
expected << " — "
|
2038
|
+
|
2039
|
+
expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n}
|
2040
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
2041
|
+
expected << "</select>\n"
|
2042
|
+
expected << " : "
|
2043
|
+
expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n}
|
2044
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
2045
|
+
expected << "</select>\n"
|
2046
|
+
|
2047
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :index => id)
|
2048
|
+
end
|
2049
|
+
|
2050
|
+
def test_datetime_select_within_fields_for_with_options_index
|
2051
|
+
@post = Post.new
|
2052
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
2053
|
+
id = 456
|
2054
|
+
|
2055
|
+
fields_for :post, @post, :index => id do |f|
|
2056
|
+
concat f.datetime_select(:updated_at)
|
2057
|
+
end
|
2058
|
+
|
2059
|
+
expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n}
|
2060
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
2061
|
+
expected << "</select>\n"
|
2062
|
+
|
2063
|
+
expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n}
|
2064
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
2065
|
+
expected << "</select>\n"
|
2066
|
+
|
2067
|
+
expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n}
|
2068
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
2069
|
+
expected << "</select>\n"
|
2070
|
+
|
2071
|
+
expected << " — "
|
2072
|
+
|
2073
|
+
expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n}
|
2074
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
2075
|
+
expected << "</select>\n"
|
2076
|
+
expected << " : "
|
2077
|
+
expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n}
|
2078
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
2079
|
+
expected << "</select>\n"
|
2080
|
+
|
2081
|
+
assert_dom_equal expected, output_buffer
|
2082
|
+
end
|
2083
|
+
|
2084
|
+
def test_datetime_select_with_auto_index
|
2085
|
+
@post = Post.new
|
2086
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
2087
|
+
id = @post.id
|
2088
|
+
|
2089
|
+
expected = %{<select id="post_123_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n}
|
2090
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
2091
|
+
expected << "</select>\n"
|
2092
|
+
|
2093
|
+
expected << %{<select id="post_123_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n}
|
2094
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
2095
|
+
expected << "</select>\n"
|
2096
|
+
|
2097
|
+
expected << %{<select id="post_123_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n}
|
2098
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
2099
|
+
expected << "</select>\n"
|
2100
|
+
|
2101
|
+
expected << " — "
|
2102
|
+
|
2103
|
+
expected << %{<select id="post_123_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n}
|
2104
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
2105
|
+
expected << "</select>\n"
|
2106
|
+
expected << " : "
|
2107
|
+
expected << %{<select id="post_123_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n}
|
2108
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
2109
|
+
expected << "</select>\n"
|
2110
|
+
|
2111
|
+
assert_dom_equal expected, datetime_select("post[]", "updated_at")
|
2112
|
+
end
|
2113
|
+
|
2114
|
+
def test_datetime_select_with_seconds
|
2115
|
+
@post = Post.new
|
2116
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2117
|
+
|
2118
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2119
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
2120
|
+
expected << "</select>\n"
|
2121
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2122
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2123
|
+
expected << "</select>\n"
|
2124
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2125
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2126
|
+
expected << "</select>\n"
|
2127
|
+
|
2128
|
+
expected << " — "
|
2129
|
+
|
2130
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2131
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2132
|
+
expected << "</select>\n"
|
2133
|
+
expected << " : "
|
2134
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2135
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2136
|
+
expected << "</select>\n"
|
2137
|
+
expected << " : "
|
2138
|
+
expected << %{<select id="post_updated_at_6i" name="post[updated_at(6i)]">\n}
|
2139
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 35}>#{sprintf("%02d", i)}</option>\n) }
|
2140
|
+
expected << "</select>\n"
|
2141
|
+
|
2142
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :include_seconds => true)
|
2143
|
+
end
|
2144
|
+
|
2145
|
+
def test_datetime_select_discard_year
|
2146
|
+
@post = Post.new
|
2147
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2148
|
+
|
2149
|
+
expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n}
|
2150
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2151
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2152
|
+
expected << "</select>\n"
|
2153
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2154
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2155
|
+
expected << "</select>\n"
|
2156
|
+
|
2157
|
+
expected << " — "
|
2158
|
+
|
2159
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2160
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2161
|
+
expected << "</select>\n"
|
2162
|
+
expected << " : "
|
2163
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2164
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2165
|
+
expected << "</select>\n"
|
2166
|
+
|
2167
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true)
|
2168
|
+
end
|
2169
|
+
|
2170
|
+
def test_datetime_select_discard_month
|
2171
|
+
@post = Post.new
|
2172
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2173
|
+
|
2174
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2175
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
2176
|
+
expected << "</select>\n"
|
2177
|
+
expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n}
|
2178
|
+
expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n}
|
2179
|
+
|
2180
|
+
expected << " — "
|
2181
|
+
|
2182
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2183
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2184
|
+
expected << "</select>\n"
|
2185
|
+
expected << " : "
|
2186
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2187
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2188
|
+
expected << "</select>\n"
|
2189
|
+
|
2190
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_month => true)
|
2191
|
+
end
|
2192
|
+
|
2193
|
+
def test_datetime_select_discard_year_and_month
|
2194
|
+
@post = Post.new
|
2195
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2196
|
+
|
2197
|
+
expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n}
|
2198
|
+
expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n}
|
2199
|
+
expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n}
|
2200
|
+
|
2201
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2202
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2203
|
+
expected << "</select>\n"
|
2204
|
+
expected << " : "
|
2205
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2206
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2207
|
+
expected << "</select>\n"
|
2208
|
+
|
2209
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_year => true, :discard_month => true)
|
2210
|
+
end
|
2211
|
+
|
2212
|
+
def test_datetime_select_discard_year_and_month_with_disabled_html_option
|
2213
|
+
@post = Post.new
|
2214
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2215
|
+
|
2216
|
+
expected = %{<input type="hidden" id="post_updated_at_1i" disabled="disabled" name="post[updated_at(1i)]" value="2004" />\n}
|
2217
|
+
expected << %{<input type="hidden" id="post_updated_at_2i" disabled="disabled" name="post[updated_at(2i)]" value="6" />\n}
|
2218
|
+
expected << %{<input type="hidden" id="post_updated_at_3i" disabled="disabled" name="post[updated_at(3i)]" value="15" />\n}
|
2219
|
+
|
2220
|
+
expected << %{<select id="post_updated_at_4i" disabled="disabled" name="post[updated_at(4i)]">\n}
|
2221
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2222
|
+
expected << "</select>\n"
|
2223
|
+
expected << " : "
|
2224
|
+
expected << %{<select id="post_updated_at_5i" disabled="disabled" name="post[updated_at(5i)]">\n}
|
2225
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2226
|
+
expected << "</select>\n"
|
2227
|
+
|
2228
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", { :discard_year => true, :discard_month => true }, :disabled => true)
|
2229
|
+
end
|
2230
|
+
|
2231
|
+
def test_datetime_select_discard_hour
|
2232
|
+
@post = Post.new
|
2233
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2234
|
+
|
2235
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2236
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
2237
|
+
expected << "</select>\n"
|
2238
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2239
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2240
|
+
expected << "</select>\n"
|
2241
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2242
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2243
|
+
expected << "</select>\n"
|
2244
|
+
|
2245
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_hour => true)
|
2246
|
+
end
|
2247
|
+
|
2248
|
+
def test_datetime_select_discard_minute
|
2249
|
+
@post = Post.new
|
2250
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2251
|
+
|
2252
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2253
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
2254
|
+
expected << "</select>\n"
|
2255
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2256
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2257
|
+
expected << "</select>\n"
|
2258
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2259
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2260
|
+
expected << "</select>\n"
|
2261
|
+
|
2262
|
+
expected << " — "
|
2263
|
+
|
2264
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2265
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2266
|
+
expected << "</select>\n"
|
2267
|
+
expected << %{<input type="hidden" id="post_updated_at_5i" name="post[updated_at(5i)]" value="16" />\n}
|
2268
|
+
|
2269
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :discard_minute => true)
|
2270
|
+
end
|
2271
|
+
|
2272
|
+
def test_datetime_select_invalid_order
|
2273
|
+
@post = Post.new
|
2274
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2275
|
+
|
2276
|
+
expected = %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2277
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2278
|
+
expected << "</select>\n"
|
2279
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2280
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2281
|
+
expected << "</select>\n"
|
2282
|
+
expected << %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2283
|
+
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
|
2284
|
+
expected << "</select>\n"
|
2285
|
+
|
2286
|
+
expected << " — "
|
2287
|
+
|
2288
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2289
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2290
|
+
expected << "</select>\n"
|
2291
|
+
expected << " : "
|
2292
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2293
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2294
|
+
expected << "</select>\n"
|
2295
|
+
|
2296
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:minute, :day, :hour, :month, :year, :second])
|
2297
|
+
end
|
2298
|
+
|
2299
|
+
def test_datetime_select_discard_with_order
|
2300
|
+
@post = Post.new
|
2301
|
+
@post.updated_at = Time.local(2004, 6, 15, 15, 16, 35)
|
2302
|
+
|
2303
|
+
expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n}
|
2304
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2305
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 15}>#{i}</option>\n) }
|
2306
|
+
expected << "</select>\n"
|
2307
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2308
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 6}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2309
|
+
expected << "</select>\n"
|
2310
|
+
|
2311
|
+
expected << " — "
|
2312
|
+
|
2313
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2314
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2315
|
+
expected << "</select>\n"
|
2316
|
+
expected << " : "
|
2317
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2318
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2319
|
+
expected << "</select>\n"
|
2320
|
+
|
2321
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :order => [:day, :month])
|
2322
|
+
end
|
2323
|
+
|
2324
|
+
def test_datetime_select_with_default_value_as_time
|
2325
|
+
@post = Post.new
|
2326
|
+
@post.updated_at = nil
|
2327
|
+
|
2328
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2329
|
+
2001.upto(2011) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2006}>#{i}</option>\n) }
|
2330
|
+
expected << "</select>\n"
|
2331
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2332
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 9}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2333
|
+
expected << "</select>\n"
|
2334
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2335
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 19}>#{i}</option>\n) }
|
2336
|
+
expected << "</select>\n"
|
2337
|
+
|
2338
|
+
expected << " — "
|
2339
|
+
|
2340
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2341
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
2342
|
+
expected << "</select>\n"
|
2343
|
+
expected << " : "
|
2344
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2345
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
2346
|
+
expected << "</select>\n"
|
2347
|
+
|
2348
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35))
|
2349
|
+
end
|
2350
|
+
|
2351
|
+
def test_include_blank_overrides_default_option
|
2352
|
+
@post = Post.new
|
2353
|
+
@post.updated_at = nil
|
2354
|
+
|
2355
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2356
|
+
expected << %(<option value=""></option>\n)
|
2357
|
+
(Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
2358
|
+
expected << "</select>\n"
|
2359
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2360
|
+
expected << %(<option value=""></option>\n)
|
2361
|
+
1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
|
2362
|
+
expected << "</select>\n"
|
2363
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2364
|
+
expected << %(<option value=""></option>\n)
|
2365
|
+
1.upto(31) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
2366
|
+
expected << "</select>\n"
|
2367
|
+
|
2368
|
+
assert_dom_equal expected, date_select("post", "updated_at", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true)
|
2369
|
+
end
|
2370
|
+
|
2371
|
+
def test_datetime_select_with_default_value_as_hash
|
2372
|
+
@post = Post.new
|
2373
|
+
@post.updated_at = nil
|
2374
|
+
|
2375
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
2376
|
+
(Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.year}>#{i}</option>\n) }
|
2377
|
+
expected << "</select>\n"
|
2378
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
2379
|
+
1.upto(12) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 10}>#{Date::MONTHNAMES[i]}</option>\n) }
|
2380
|
+
expected << "</select>\n"
|
2381
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
2382
|
+
1.upto(31) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == Time.now.day}>#{i}</option>\n) }
|
2383
|
+
expected << "</select>\n"
|
2384
|
+
|
2385
|
+
expected << " — "
|
2386
|
+
|
2387
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
2388
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 9}>#{sprintf("%02d", i)}</option>\n) }
|
2389
|
+
expected << "</select>\n"
|
2390
|
+
expected << " : "
|
2391
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
2392
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 42}>#{sprintf("%02d", i)}</option>\n) }
|
2393
|
+
expected << "</select>\n"
|
2394
|
+
|
2395
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :default => { :month => 10, :minute => 42, :hour => 9 })
|
2396
|
+
end
|
2397
|
+
|
2398
|
+
def test_datetime_select_with_html_options
|
2399
|
+
@post = Post.new
|
2400
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
2401
|
+
|
2402
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]" class="selector">\n}
|
2403
|
+
expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
|
2404
|
+
expected << "</select>\n"
|
2405
|
+
|
2406
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]" class="selector">\n}
|
2407
|
+
expected << %{<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6" selected="selected">June</option>\n<option value="7">July</option>\n<option value="8">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n}
|
2408
|
+
expected << "</select>\n"
|
2409
|
+
|
2410
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]" class="selector">\n}
|
2411
|
+
expected << %{<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15" selected="selected">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n}
|
2412
|
+
expected << "</select>\n"
|
2413
|
+
|
2414
|
+
expected << " — "
|
2415
|
+
|
2416
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]" class="selector">\n}
|
2417
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n}
|
2418
|
+
expected << "</select>\n"
|
2419
|
+
expected << " : "
|
2420
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]" class="selector">\n}
|
2421
|
+
expected << %{<option value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n<option value="32">32</option>\n<option value="33">33</option>\n<option value="34">34</option>\n<option value="35" selected="selected">35</option>\n<option value="36">36</option>\n<option value="37">37</option>\n<option value="38">38</option>\n<option value="39">39</option>\n<option value="40">40</option>\n<option value="41">41</option>\n<option value="42">42</option>\n<option value="43">43</option>\n<option value="44">44</option>\n<option value="45">45</option>\n<option value="46">46</option>\n<option value="47">47</option>\n<option value="48">48</option>\n<option value="49">49</option>\n<option value="50">50</option>\n<option value="51">51</option>\n<option value="52">52</option>\n<option value="53">53</option>\n<option value="54">54</option>\n<option value="55">55</option>\n<option value="56">56</option>\n<option value="57">57</option>\n<option value="58">58</option>\n<option value="59">59</option>\n}
|
2422
|
+
expected << "</select>\n"
|
2423
|
+
|
2424
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", {}, :class => 'selector')
|
2425
|
+
end
|
2426
|
+
|
2427
|
+
def test_date_select_should_not_change_passed_options_hash
|
2428
|
+
@post = Post.new
|
2429
|
+
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
2430
|
+
|
2431
|
+
options = {
|
2432
|
+
:order => [ :year, :month, :day ],
|
2433
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2434
|
+
:discard_type => false,
|
2435
|
+
:include_blank => false,
|
2436
|
+
:ignore_date => false,
|
2437
|
+
:include_seconds => true
|
2438
|
+
}
|
2439
|
+
date_select(@post, :updated_at, options)
|
2440
|
+
|
2441
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2442
|
+
# don't change this!
|
2443
|
+
assert_equal({
|
2444
|
+
:order => [ :year, :month, :day ],
|
2445
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2446
|
+
:discard_type => false,
|
2447
|
+
:include_blank => false,
|
2448
|
+
:ignore_date => false,
|
2449
|
+
:include_seconds => true
|
2450
|
+
}, options)
|
2451
|
+
end
|
2452
|
+
|
2453
|
+
def test_datetime_select_should_not_change_passed_options_hash
|
2454
|
+
@post = Post.new
|
2455
|
+
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
2456
|
+
|
2457
|
+
options = {
|
2458
|
+
:order => [ :year, :month, :day ],
|
2459
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2460
|
+
:discard_type => false,
|
2461
|
+
:include_blank => false,
|
2462
|
+
:ignore_date => false,
|
2463
|
+
:include_seconds => true
|
2464
|
+
}
|
2465
|
+
datetime_select(@post, :updated_at, options)
|
2466
|
+
|
2467
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2468
|
+
# don't change this!
|
2469
|
+
assert_equal({
|
2470
|
+
:order => [ :year, :month, :day ],
|
2471
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2472
|
+
:discard_type => false,
|
2473
|
+
:include_blank => false,
|
2474
|
+
:ignore_date => false,
|
2475
|
+
:include_seconds => true
|
2476
|
+
}, options)
|
2477
|
+
end
|
2478
|
+
|
2479
|
+
def test_time_select_should_not_change_passed_options_hash
|
2480
|
+
@post = Post.new
|
2481
|
+
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
2482
|
+
|
2483
|
+
options = {
|
2484
|
+
:order => [ :year, :month, :day ],
|
2485
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2486
|
+
:discard_type => false,
|
2487
|
+
:include_blank => false,
|
2488
|
+
:ignore_date => false,
|
2489
|
+
:include_seconds => true
|
2490
|
+
}
|
2491
|
+
time_select(@post, :updated_at, options)
|
2492
|
+
|
2493
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2494
|
+
# don't change this!
|
2495
|
+
assert_equal({
|
2496
|
+
:order => [ :year, :month, :day ],
|
2497
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2498
|
+
:discard_type => false,
|
2499
|
+
:include_blank => false,
|
2500
|
+
:ignore_date => false,
|
2501
|
+
:include_seconds => true
|
2502
|
+
}, options)
|
2503
|
+
end
|
2504
|
+
|
2505
|
+
def test_select_date_should_not_change_passed_options_hash
|
2506
|
+
options = {
|
2507
|
+
:order => [ :year, :month, :day ],
|
2508
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2509
|
+
:discard_type => false,
|
2510
|
+
:include_blank => false,
|
2511
|
+
:ignore_date => false,
|
2512
|
+
:include_seconds => true
|
2513
|
+
}
|
2514
|
+
select_date(Date.today, options)
|
2515
|
+
|
2516
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2517
|
+
# don't change this!
|
2518
|
+
assert_equal({
|
2519
|
+
:order => [ :year, :month, :day ],
|
2520
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2521
|
+
:discard_type => false,
|
2522
|
+
:include_blank => false,
|
2523
|
+
:ignore_date => false,
|
2524
|
+
:include_seconds => true
|
2525
|
+
}, options)
|
2526
|
+
end
|
2527
|
+
|
2528
|
+
def test_select_datetime_should_not_change_passed_options_hash
|
2529
|
+
options = {
|
2530
|
+
:order => [ :year, :month, :day ],
|
2531
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2532
|
+
:discard_type => false,
|
2533
|
+
:include_blank => false,
|
2534
|
+
:ignore_date => false,
|
2535
|
+
:include_seconds => true
|
2536
|
+
}
|
2537
|
+
select_datetime(Time.now, options)
|
2538
|
+
|
2539
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2540
|
+
# don't change this!
|
2541
|
+
assert_equal({
|
2542
|
+
:order => [ :year, :month, :day ],
|
2543
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2544
|
+
:discard_type => false,
|
2545
|
+
:include_blank => false,
|
2546
|
+
:ignore_date => false,
|
2547
|
+
:include_seconds => true
|
2548
|
+
}, options)
|
2549
|
+
end
|
2550
|
+
|
2551
|
+
def test_select_time_should_not_change_passed_options_hash
|
2552
|
+
options = {
|
2553
|
+
:order => [ :year, :month, :day ],
|
2554
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2555
|
+
:discard_type => false,
|
2556
|
+
:include_blank => false,
|
2557
|
+
:ignore_date => false,
|
2558
|
+
:include_seconds => true
|
2559
|
+
}
|
2560
|
+
select_time(Time.now, options)
|
2561
|
+
|
2562
|
+
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2563
|
+
# don't change this!
|
2564
|
+
assert_equal({
|
2565
|
+
:order => [ :year, :month, :day ],
|
2566
|
+
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2567
|
+
:discard_type => false,
|
2568
|
+
:include_blank => false,
|
2569
|
+
:ignore_date => false,
|
2570
|
+
:include_seconds => true
|
2571
|
+
}, options)
|
2572
|
+
end
|
2573
|
+
|
2574
|
+
def test_select_html_safety
|
2575
|
+
assert select_day(16).html_safe?
|
2576
|
+
assert select_month(8).html_safe?
|
2577
|
+
assert select_year(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
2578
|
+
assert select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
2579
|
+
assert select_second(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
2580
|
+
|
2581
|
+
assert select_minute(8, :use_hidden => true).html_safe?
|
2582
|
+
assert select_month(8, :prompt => 'Choose month').html_safe?
|
2583
|
+
|
2584
|
+
assert select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector').html_safe?
|
2585
|
+
assert select_date(Time.mktime(2003, 8, 16), :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]").html_safe?
|
2586
|
+
end
|
2587
|
+
|
2588
|
+
def test_object_select_html_safety
|
2589
|
+
@post = Post.new
|
2590
|
+
@post.written_on = Date.new(2004, 6, 15)
|
2591
|
+
|
2592
|
+
assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe?
|
2593
|
+
assert time_select("post", "written_on", :ignore_date => true).html_safe?
|
2594
|
+
end
|
2595
|
+
|
2596
|
+
protected
|
2597
|
+
def with_env_tz(new_tz = 'US/Eastern')
|
2598
|
+
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
|
2599
|
+
yield
|
2600
|
+
ensure
|
2601
|
+
old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
|
2602
|
+
end
|
2603
|
+
end
|