actionpack 2.2.3 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +433 -375
- data/MIT-LICENSE +1 -1
- data/README +21 -75
- data/Rakefile +1 -1
- data/lib/action_controller.rb +80 -43
- data/lib/action_controller/assertions/model_assertions.rb +1 -0
- data/lib/action_controller/assertions/response_assertions.rb +43 -16
- data/lib/action_controller/assertions/routing_assertions.rb +1 -1
- data/lib/action_controller/assertions/selector_assertions.rb +17 -12
- data/lib/action_controller/assertions/tag_assertions.rb +1 -4
- data/lib/action_controller/base.rb +153 -82
- data/lib/action_controller/benchmarking.rb +9 -9
- data/lib/action_controller/caching.rb +9 -11
- data/lib/action_controller/caching/actions.rb +11 -18
- data/lib/action_controller/caching/fragments.rb +28 -20
- data/lib/action_controller/caching/pages.rb +13 -15
- data/lib/action_controller/caching/sweeping.rb +2 -2
- data/lib/action_controller/cgi_ext.rb +0 -1
- data/lib/action_controller/cgi_ext/cookie.rb +2 -0
- data/lib/action_controller/cgi_process.rb +54 -162
- data/lib/action_controller/cookies.rb +13 -25
- data/lib/action_controller/dispatcher.rb +43 -122
- data/lib/action_controller/failsafe.rb +52 -0
- data/lib/action_controller/flash.rb +38 -47
- data/lib/action_controller/helpers.rb +13 -9
- data/lib/action_controller/http_authentication.rb +203 -23
- data/lib/action_controller/integration.rb +126 -70
- data/lib/action_controller/layout.rb +36 -39
- data/lib/action_controller/middleware_stack.rb +119 -0
- data/lib/action_controller/middlewares.rb +13 -0
- data/lib/action_controller/mime_responds.rb +19 -4
- data/lib/action_controller/mime_type.rb +8 -0
- data/lib/action_controller/params_parser.rb +71 -0
- data/lib/action_controller/performance_test.rb +0 -1
- data/lib/action_controller/polymorphic_routes.rb +36 -30
- data/lib/action_controller/reloader.rb +14 -0
- data/lib/action_controller/request.rb +107 -499
- data/lib/action_controller/request_forgery_protection.rb +7 -39
- data/lib/action_controller/rescue.rb +55 -35
- data/lib/action_controller/resources.rb +34 -31
- data/lib/action_controller/response.rb +99 -57
- data/lib/action_controller/rewindable_input.rb +28 -0
- data/lib/action_controller/routing.rb +7 -7
- data/lib/action_controller/routing/builder.rb +4 -1
- data/lib/action_controller/routing/optimisations.rb +1 -1
- data/lib/action_controller/routing/recognition_optimisation.rb +1 -2
- data/lib/action_controller/routing/route.rb +15 -5
- data/lib/action_controller/routing/route_set.rb +82 -35
- data/lib/action_controller/routing/segments.rb +35 -0
- data/lib/action_controller/session/abstract_store.rb +181 -0
- data/lib/action_controller/session/cookie_store.rb +197 -175
- data/lib/action_controller/session/mem_cache_store.rb +36 -83
- data/lib/action_controller/session_management.rb +26 -134
- data/lib/action_controller/streaming.rb +24 -7
- data/lib/action_controller/templates/rescues/diagnostics.erb +2 -2
- data/lib/action_controller/templates/rescues/template_error.erb +2 -2
- data/lib/action_controller/test_case.rb +87 -30
- data/lib/action_controller/test_process.rb +145 -104
- data/lib/action_controller/uploaded_file.rb +44 -0
- data/lib/action_controller/url_rewriter.rb +3 -6
- data/lib/action_controller/vendor/html-scanner.rb +16 -0
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +1 -1
- data/lib/action_controller/vendor/rack-1.0/rack.rb +89 -0
- data/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +22 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +37 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +37 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +58 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +124 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +51 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +40 -0
- data/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +480 -0
- data/lib/action_controller/vendor/rack-1.0/rack/builder.rb +63 -0
- data/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +36 -0
- data/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +49 -0
- data/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +61 -0
- data/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +45 -0
- data/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +29 -0
- data/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +23 -0
- data/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +85 -0
- data/lib/action_controller/vendor/rack-1.0/rack/directory.rb +153 -0
- data/lib/action_controller/vendor/rack-1.0/rack/file.rb +88 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler.rb +48 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +61 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +8 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +89 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +84 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +59 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +8 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +18 -0
- data/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +67 -0
- data/lib/action_controller/vendor/rack-1.0/rack/head.rb +19 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lint.rb +462 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +65 -0
- data/lib/action_controller/vendor/rack-1.0/rack/lock.rb +16 -0
- data/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +27 -0
- data/lib/action_controller/vendor/rack-1.0/rack/mime.rb +204 -0
- data/lib/action_controller/vendor/rack-1.0/rack/mock.rb +160 -0
- data/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +57 -0
- data/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +64 -0
- data/lib/action_controller/vendor/rack-1.0/rack/request.rb +241 -0
- data/lib/action_controller/vendor/rack-1.0/rack/response.rb +179 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +142 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +91 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +109 -0
- data/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +100 -0
- data/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +349 -0
- data/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +106 -0
- data/lib/action_controller/vendor/rack-1.0/rack/static.rb +38 -0
- data/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +55 -0
- data/lib/action_controller/vendor/rack-1.0/rack/utils.rb +392 -0
- data/lib/action_controller/verification.rb +1 -1
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +2 -2
- data/lib/action_view.rb +22 -17
- data/lib/action_view/base.rb +53 -79
- data/lib/action_view/erb/util.rb +38 -0
- data/lib/action_view/helpers.rb +24 -5
- data/lib/action_view/helpers/active_record_helper.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +81 -50
- data/lib/action_view/helpers/atom_feed_helper.rb +1 -1
- data/lib/action_view/helpers/benchmark_helper.rb +26 -5
- data/lib/action_view/helpers/date_helper.rb +82 -7
- data/lib/action_view/helpers/form_helper.rb +295 -64
- data/lib/action_view/helpers/form_options_helper.rb +160 -18
- data/lib/action_view/helpers/form_tag_helper.rb +2 -2
- data/lib/action_view/helpers/number_helper.rb +31 -18
- data/lib/action_view/helpers/prototype_helper.rb +2 -12
- data/lib/action_view/helpers/sanitize_helper.rb +0 -10
- data/lib/action_view/helpers/scriptaculous_helper.rb +1 -0
- data/lib/action_view/helpers/tag_helper.rb +3 -4
- data/lib/action_view/helpers/text_helper.rb +99 -122
- data/lib/action_view/helpers/translation_helper.rb +19 -1
- data/lib/action_view/helpers/url_helper.rb +25 -2
- data/lib/action_view/inline_template.rb +1 -1
- data/lib/action_view/locale/en.yml +19 -1
- data/lib/action_view/partials.rb +46 -9
- data/lib/action_view/paths.rb +28 -84
- data/lib/action_view/reloadable_template.rb +117 -0
- data/lib/action_view/renderable.rb +28 -35
- data/lib/action_view/renderable_partial.rb +3 -4
- data/lib/action_view/template.rb +172 -31
- data/lib/action_view/template_error.rb +8 -9
- data/lib/action_view/template_handler.rb +1 -1
- data/lib/action_view/template_handlers.rb +9 -6
- data/lib/action_view/template_handlers/erb.rb +2 -39
- data/lib/action_view/template_handlers/rjs.rb +1 -0
- data/lib/action_view/test_case.rb +27 -1
- data/test/abstract_unit.rb +23 -17
- data/test/active_record_unit.rb +5 -4
- data/test/activerecord/active_record_store_test.rb +139 -106
- data/test/activerecord/render_partial_with_record_identification_test.rb +5 -21
- data/test/controller/action_pack_assertions_test.rb +25 -23
- data/test/controller/addresses_render_test.rb +3 -6
- data/test/controller/assert_select_test.rb +83 -70
- data/test/controller/base_test.rb +11 -13
- data/test/controller/benchmark_test.rb +3 -3
- data/test/controller/caching_test.rb +34 -24
- data/test/controller/capture_test.rb +3 -6
- data/test/controller/content_type_test.rb +3 -6
- data/test/controller/cookie_test.rb +31 -66
- data/test/controller/deprecation/deprecated_base_methods_test.rb +9 -11
- data/test/controller/dispatcher_test.rb +23 -28
- data/test/controller/fake_models.rb +8 -0
- data/test/controller/filters_test.rb +6 -2
- data/test/controller/flash_test.rb +2 -6
- data/test/controller/helper_test.rb +15 -1
- data/test/controller/html-scanner/document_test.rb +1 -1
- data/test/controller/html-scanner/sanitizer_test.rb +1 -1
- data/test/controller/http_basic_authentication_test.rb +88 -0
- data/test/controller/http_digest_authentication_test.rb +178 -0
- data/test/controller/integration_test.rb +56 -52
- data/test/controller/layout_test.rb +46 -44
- data/test/controller/middleware_stack_test.rb +90 -0
- data/test/controller/mime_responds_test.rb +7 -11
- data/test/controller/mime_type_test.rb +9 -0
- data/test/controller/polymorphic_routes_test.rb +235 -151
- data/test/controller/rack_test.rb +52 -81
- data/test/controller/redirect_test.rb +6 -14
- data/test/controller/render_test.rb +273 -60
- data/test/controller/request/json_params_parsing_test.rb +45 -0
- data/test/controller/request/multipart_params_parsing_test.rb +223 -0
- data/test/controller/request/query_string_parsing_test.rb +120 -0
- data/test/controller/request/url_encoded_params_parsing_test.rb +184 -0
- data/test/controller/request/xml_params_parsing_test.rb +88 -0
- data/test/controller/request_forgery_protection_test.rb +17 -98
- data/test/controller/request_test.rb +45 -530
- data/test/controller/rescue_test.rb +45 -22
- data/test/controller/resources_test.rb +112 -37
- data/test/controller/routing_test.rb +1442 -1384
- data/test/controller/selector_test.rb +3 -3
- data/test/controller/send_file_test.rb +30 -3
- data/test/controller/session/cookie_store_test.rb +169 -240
- data/test/controller/session/mem_cache_store_test.rb +94 -148
- data/test/controller/session/test_session_test.rb +58 -0
- data/test/controller/test_test.rb +32 -13
- data/test/controller/url_rewriter_test.rb +54 -4
- data/test/controller/verification_test.rb +1 -1
- data/test/controller/view_paths_test.rb +15 -15
- data/test/controller/webservice_test.rb +178 -147
- data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
- data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
- data/test/fixtures/layouts/default_html.html.erb +1 -0
- data/test/fixtures/layouts/xhr.html.erb +2 -0
- data/test/fixtures/multipart/empty +10 -0
- data/test/fixtures/multipart/hello.txt +1 -0
- data/test/fixtures/multipart/none +9 -0
- data/test/fixtures/public/500.da.html +1 -0
- data/test/fixtures/quiz/questions/_question.html.erb +1 -0
- data/test/fixtures/replies.yml +1 -1
- data/test/fixtures/test/_one.html.erb +1 -0
- data/test/fixtures/test/_two.html.erb +1 -0
- data/test/fixtures/test/dont_pick_me +1 -0
- data/test/fixtures/test/hello.builder +1 -1
- 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.pt-BR.html.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/render_explicit_html_template.js.rjs +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/utf8.html.erb +2 -0
- data/test/template/active_record_helper_i18n_test.rb +31 -33
- data/test/template/active_record_helper_test.rb +34 -0
- data/test/template/asset_tag_helper_test.rb +52 -14
- data/test/template/atom_feed_helper_test.rb +3 -5
- data/test/template/benchmark_helper_test.rb +50 -24
- data/test/template/compiled_templates_test.rb +177 -33
- data/test/template/date_helper_i18n_test.rb +88 -81
- data/test/template/date_helper_test.rb +427 -43
- data/test/template/form_helper_test.rb +243 -44
- data/test/template/form_options_helper_test.rb +631 -565
- data/test/template/form_tag_helper_test.rb +9 -2
- data/test/template/javascript_helper_test.rb +0 -5
- data/test/template/number_helper_i18n_test.rb +60 -48
- data/test/template/number_helper_test.rb +1 -0
- data/test/template/render_test.rb +117 -35
- data/test/template/test_test.rb +4 -6
- data/test/template/text_helper_test.rb +129 -50
- data/test/template/translation_helper_test.rb +23 -19
- data/test/template/url_helper_test.rb +35 -2
- data/test/view/test_case_test.rb +8 -0
- metadata +197 -23
- data/lib/action_controller/assertions.rb +0 -69
- data/lib/action_controller/caching/sql_cache.rb +0 -18
- data/lib/action_controller/cgi_ext/session.rb +0 -53
- data/lib/action_controller/components.rb +0 -169
- data/lib/action_controller/rack_process.rb +0 -297
- data/lib/action_controller/request_profiler.rb +0 -169
- data/lib/action_controller/session/active_record_store.rb +0 -340
- data/lib/action_controller/session/drb_server.rb +0 -32
- data/lib/action_controller/session/drb_store.rb +0 -35
- data/test/controller/cgi_test.rb +0 -269
- data/test/controller/components_test.rb +0 -156
- data/test/controller/http_authentication_test.rb +0 -54
- data/test/controller/integration_upload_test.rb +0 -43
- data/test/controller/session_fixation_test.rb +0 -89
- data/test/controller/session_management_test.rb +0 -178
- data/test/fixtures/test/hello_world.js +0 -1
@@ -8,66 +8,64 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
|
|
8
8
|
@from = Time.mktime(2004, 6, 6, 21, 45, 0)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
assert_distance_of_time_in_words_translates_key passed, expected
|
36
|
-
end
|
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, false] => [:'over_x_years', 3]
|
32
|
+
|
33
|
+
}.each do |passed, expected|
|
34
|
+
assert_distance_of_time_in_words_translates_key passed, expected
|
37
35
|
end
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
def assert_distance_of_time_in_words_translates_key(passed, expected)
|
39
|
+
diff, include_seconds = *passed
|
40
|
+
key, count = *expected
|
41
|
+
to = @from + diff
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
options = {:locale => 'en', :scope => :'datetime.distance_in_words'}
|
44
|
+
options[:count] = count if count
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
I18n.expects(:t).with(key, options)
|
47
|
+
distance_of_time_in_words(@from, to, include_seconds, :locale => 'en')
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
50
|
+
def test_distance_of_time_pluralizations
|
51
|
+
{ [:'less_than_x_seconds', 1] => 'less than 1 second',
|
52
|
+
[:'less_than_x_seconds', 2] => 'less than 2 seconds',
|
53
|
+
[:'less_than_x_minutes', 1] => 'less than a minute',
|
54
|
+
[:'less_than_x_minutes', 2] => 'less than 2 minutes',
|
55
|
+
[:'x_minutes', 1] => '1 minute',
|
56
|
+
[:'x_minutes', 2] => '2 minutes',
|
57
|
+
[:'about_x_hours', 1] => 'about 1 hour',
|
58
|
+
[:'about_x_hours', 2] => 'about 2 hours',
|
59
|
+
[:'x_days', 1] => '1 day',
|
60
|
+
[:'x_days', 2] => '2 days',
|
61
|
+
[:'about_x_years', 1] => 'about 1 year',
|
62
|
+
[:'about_x_years', 2] => 'about 2 years',
|
63
|
+
[:'over_x_years', 1] => 'over 1 year',
|
64
|
+
[:'over_x_years', 2] => 'over 2 years'
|
65
|
+
|
66
|
+
}.each do |args, expected|
|
67
|
+
key, count = *args
|
68
|
+
assert_equal expected, I18n.t(key, :count => count, :scope => 'datetime.distance_in_words')
|
71
69
|
end
|
72
70
|
end
|
73
71
|
end
|
@@ -76,38 +74,47 @@ class DateHelperSelectTagsI18nTests < Test::Unit::TestCase
|
|
76
74
|
include ActionView::Helpers::DateHelper
|
77
75
|
attr_reader :request
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
I18n.stubs(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES
|
82
|
-
end
|
77
|
+
def setup
|
78
|
+
@prompt_defaults = {:year => 'Year', :month => 'Month', :day => 'Day', :hour => 'Hour', :minute => 'Minute', :second => 'Seconds'}
|
83
79
|
|
84
|
-
|
80
|
+
I18n.stubs(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES
|
81
|
+
end
|
85
82
|
|
86
|
-
|
87
|
-
I18n.expects(:translate).never
|
88
|
-
select_month(8, :locale => 'en', :use_month_names => Date::MONTHNAMES)
|
89
|
-
end
|
83
|
+
# select_month
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
85
|
+
def test_select_month_given_use_month_names_option_does_not_translate_monthnames
|
86
|
+
I18n.expects(:translate).never
|
87
|
+
select_month(8, :locale => 'en', :use_month_names => Date::MONTHNAMES)
|
88
|
+
end
|
95
89
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
90
|
+
def test_select_month_translates_monthnames
|
91
|
+
I18n.expects(:translate).with(:'date.month_names', :locale => 'en').returns Date::MONTHNAMES
|
92
|
+
select_month(8, :locale => 'en')
|
93
|
+
end
|
100
94
|
|
101
|
-
|
95
|
+
def test_select_month_given_use_short_month_option_translates_abbr_monthnames
|
96
|
+
I18n.expects(:translate).with(:'date.abbr_month_names', :locale => 'en').returns Date::ABBR_MONTHNAMES
|
97
|
+
select_month(8, :locale => 'en', :use_short_month => true)
|
98
|
+
end
|
102
99
|
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
def test_date_or_time_select_translates_prompts
|
101
|
+
@prompt_defaults.each do |key, prompt|
|
102
|
+
I18n.expects(:translate).with(('datetime.prompts.' + key.to_s).to_sym, :locale => 'en').returns prompt
|
106
103
|
end
|
107
104
|
|
108
|
-
|
109
|
-
|
110
|
-
datetime_select('post', 'updated_at', :locale => 'en')
|
111
|
-
end
|
105
|
+
I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day]
|
106
|
+
datetime_select('post', 'updated_at', :locale => 'en', :include_seconds => true, :prompt => true)
|
112
107
|
end
|
113
|
-
|
108
|
+
|
109
|
+
# date_or_time_select
|
110
|
+
|
111
|
+
def test_date_or_time_select_given_an_order_options_does_not_translate_order
|
112
|
+
I18n.expects(:translate).never
|
113
|
+
datetime_select('post', 'updated_at', :order => [:year, :month, :day], :locale => 'en')
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_date_or_time_select_given_no_order_options_translates_order
|
117
|
+
I18n.expects(:translate).with(:'date.order', :locale => 'en').returns [:year, :month, :day]
|
118
|
+
datetime_select('post', 'updated_at', :locale => 'en')
|
119
|
+
end
|
120
|
+
end
|
@@ -153,6 +153,22 @@ class DateHelperTest < ActionView::TestCase
|
|
153
153
|
assert_dom_equal expected, select_day(16, {}, :class => 'selector')
|
154
154
|
end
|
155
155
|
|
156
|
+
def test_select_day_with_default_prompt
|
157
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
158
|
+
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)
|
159
|
+
expected << "</select>\n"
|
160
|
+
|
161
|
+
assert_dom_equal expected, select_day(16, :prompt => true)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_select_day_with_custom_prompt
|
165
|
+
expected = %(<select id="date_day" name="date[day]">\n)
|
166
|
+
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)
|
167
|
+
expected << "</select>\n"
|
168
|
+
|
169
|
+
assert_dom_equal expected, select_day(16, :prompt => 'Choose day')
|
170
|
+
end
|
171
|
+
|
156
172
|
def test_select_month
|
157
173
|
expected = %(<select id="date_month" name="date[month]">\n)
|
158
174
|
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)
|
@@ -276,6 +292,22 @@ class DateHelperTest < ActionView::TestCase
|
|
276
292
|
#assert result.include?('<option value="1">January')
|
277
293
|
end
|
278
294
|
|
295
|
+
def test_select_month_with_default_prompt
|
296
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
297
|
+
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)
|
298
|
+
expected << "</select>\n"
|
299
|
+
|
300
|
+
assert_dom_equal expected, select_month(8, :prompt => true)
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_select_month_with_custom_prompt
|
304
|
+
expected = %(<select id="date_month" name="date[month]">\n)
|
305
|
+
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)
|
306
|
+
expected << "</select>\n"
|
307
|
+
|
308
|
+
assert_dom_equal expected, select_month(8, :prompt => 'Choose month')
|
309
|
+
end
|
310
|
+
|
279
311
|
def test_select_year
|
280
312
|
expected = %(<select id="date_year" name="date[year]">\n)
|
281
313
|
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
@@ -344,6 +376,22 @@ class DateHelperTest < ActionView::TestCase
|
|
344
376
|
#assert result.include?('<option value="2003"')
|
345
377
|
end
|
346
378
|
|
379
|
+
def test_select_year_with_default_prompt
|
380
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
381
|
+
expected << %(<option value="">Year</option>\n<option value="2003">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
382
|
+
expected << "</select>\n"
|
383
|
+
|
384
|
+
assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => true)
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_select_year_with_custom_prompt
|
388
|
+
expected = %(<select id="date_year" name="date[year]">\n)
|
389
|
+
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)
|
390
|
+
expected << "</select>\n"
|
391
|
+
|
392
|
+
assert_dom_equal expected, select_year(nil, :start_year => 2003, :end_year => 2005, :prompt => 'Choose year')
|
393
|
+
end
|
394
|
+
|
347
395
|
def test_select_hour
|
348
396
|
expected = %(<select id="date_hour" name="date[hour]">\n)
|
349
397
|
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)
|
@@ -392,6 +440,22 @@ class DateHelperTest < ActionView::TestCase
|
|
392
440
|
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector', :accesskey => 'M')
|
393
441
|
end
|
394
442
|
|
443
|
+
def test_select_hour_with_default_prompt
|
444
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
445
|
+
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)
|
446
|
+
expected << "</select>\n"
|
447
|
+
|
448
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_select_hour_with_custom_prompt
|
452
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
453
|
+
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)
|
454
|
+
expected << "</select>\n"
|
455
|
+
|
456
|
+
assert_dom_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose hour')
|
457
|
+
end
|
458
|
+
|
395
459
|
def test_select_minute
|
396
460
|
expected = %(<select id="date_minute" name="date[minute]">\n)
|
397
461
|
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)
|
@@ -470,6 +534,22 @@ class DateHelperTest < ActionView::TestCase
|
|
470
534
|
#assert result.include?('<option value="00">00')
|
471
535
|
end
|
472
536
|
|
537
|
+
def test_select_minute_with_default_prompt
|
538
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
539
|
+
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)
|
540
|
+
expected << "</select>\n"
|
541
|
+
|
542
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_select_minute_with_custom_prompt
|
546
|
+
expected = %(<select id="date_minute" name="date[minute]">\n)
|
547
|
+
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)
|
548
|
+
expected << "</select>\n"
|
549
|
+
|
550
|
+
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose minute')
|
551
|
+
end
|
552
|
+
|
473
553
|
def test_select_second
|
474
554
|
expected = %(<select id="date_second" name="date[second]">\n)
|
475
555
|
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)
|
@@ -524,6 +604,22 @@ class DateHelperTest < ActionView::TestCase
|
|
524
604
|
#assert result.include?('<option value="00">00')
|
525
605
|
end
|
526
606
|
|
607
|
+
def test_select_second_with_default_prompt
|
608
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
609
|
+
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)
|
610
|
+
expected << "</select>\n"
|
611
|
+
|
612
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true)
|
613
|
+
end
|
614
|
+
|
615
|
+
def test_select_second_with_custom_prompt
|
616
|
+
expected = %(<select id="date_second" name="date[second]">\n)
|
617
|
+
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)
|
618
|
+
expected << "</select>\n"
|
619
|
+
|
620
|
+
assert_dom_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => 'Choose seconds')
|
621
|
+
end
|
622
|
+
|
527
623
|
def test_select_date
|
528
624
|
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
529
625
|
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
|
@@ -914,6 +1010,57 @@ class DateHelperTest < ActionView::TestCase
|
|
914
1010
|
assert_nothing_raised { select_datetime(Date.today) }
|
915
1011
|
end
|
916
1012
|
|
1013
|
+
def test_select_datetime_with_default_prompt
|
1014
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1015
|
+
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)
|
1016
|
+
expected << "</select>\n"
|
1017
|
+
|
1018
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1019
|
+
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)
|
1020
|
+
expected << "</select>\n"
|
1021
|
+
|
1022
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1023
|
+
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)
|
1024
|
+
expected << "</select>\n"
|
1025
|
+
|
1026
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
1027
|
+
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)
|
1028
|
+
expected << "</select>\n"
|
1029
|
+
|
1030
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
1031
|
+
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)
|
1032
|
+
expected << "</select>\n"
|
1033
|
+
|
1034
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005,
|
1035
|
+
:prefix => "date[first]", :prompt => true)
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
def test_select_datetime_with_custom_prompt
|
1039
|
+
|
1040
|
+
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1041
|
+
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)
|
1042
|
+
expected << "</select>\n"
|
1043
|
+
|
1044
|
+
expected << %(<select id="date_first_month" name="date[first][month]">\n)
|
1045
|
+
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)
|
1046
|
+
expected << "</select>\n"
|
1047
|
+
|
1048
|
+
expected << %(<select id="date_first_day" name="date[first][day]">\n)
|
1049
|
+
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)
|
1050
|
+
expected << "</select>\n"
|
1051
|
+
|
1052
|
+
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
|
1053
|
+
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)
|
1054
|
+
expected << "</select>\n"
|
1055
|
+
|
1056
|
+
expected << %(<select id="date_first_minute" name="date[first][minute]">\n)
|
1057
|
+
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)
|
1058
|
+
expected << "</select>\n"
|
1059
|
+
|
1060
|
+
assert_dom_equal expected, select_datetime(Time.mktime(2003, 8, 16, 8, 4, 18), :start_year => 2003, :end_year => 2005, :prefix => "date[first]",
|
1061
|
+
:prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year', :hour => 'Choose hour', :minute => 'Choose minute'})
|
1062
|
+
end
|
1063
|
+
|
917
1064
|
def test_select_time
|
918
1065
|
expected = %(<select id="date_hour" name="date[hour]">\n)
|
919
1066
|
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)
|
@@ -995,6 +1142,40 @@ class DateHelperTest < ActionView::TestCase
|
|
995
1142
|
assert_nothing_raised { select_time(Date.today) }
|
996
1143
|
end
|
997
1144
|
|
1145
|
+
def test_select_time_with_default_prompt
|
1146
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1147
|
+
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)
|
1148
|
+
expected << "</select>\n"
|
1149
|
+
|
1150
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1151
|
+
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)
|
1152
|
+
expected << "</select>\n"
|
1153
|
+
|
1154
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1155
|
+
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)
|
1156
|
+
expected << "</select>\n"
|
1157
|
+
|
1158
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :include_seconds => true, :prompt => true)
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
def test_select_time_with_custom_prompt
|
1162
|
+
|
1163
|
+
expected = %(<select id="date_hour" name="date[hour]">\n)
|
1164
|
+
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)
|
1165
|
+
expected << "</select>\n"
|
1166
|
+
|
1167
|
+
expected << %(<select id="date_minute" name="date[minute]">\n)
|
1168
|
+
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)
|
1169
|
+
expected << "</select>\n"
|
1170
|
+
|
1171
|
+
expected << %(<select id="date_second" name="date[second]">\n)
|
1172
|
+
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)
|
1173
|
+
expected << "</select>\n"
|
1174
|
+
|
1175
|
+
assert_dom_equal expected, select_time(Time.mktime(2003, 8, 16, 8, 4, 18), :prompt => true, :include_seconds => true,
|
1176
|
+
:prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})
|
1177
|
+
end
|
1178
|
+
|
998
1179
|
def test_date_select
|
999
1180
|
@post = Post.new
|
1000
1181
|
@post.written_on = Date.new(2004, 6, 15)
|
@@ -1047,6 +1228,38 @@ class DateHelperTest < ActionView::TestCase
|
|
1047
1228
|
assert_dom_equal(expected, output_buffer)
|
1048
1229
|
end
|
1049
1230
|
|
1231
|
+
def test_date_select_within_fields_for_with_index
|
1232
|
+
@post = Post.new
|
1233
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1234
|
+
id = 27
|
1235
|
+
|
1236
|
+
fields_for :post, @post, :index => id do |f|
|
1237
|
+
concat f.date_select(:written_on)
|
1238
|
+
end
|
1239
|
+
|
1240
|
+
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"
|
1241
|
+
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"
|
1242
|
+
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"
|
1243
|
+
|
1244
|
+
assert_dom_equal(expected, output_buffer)
|
1245
|
+
end
|
1246
|
+
|
1247
|
+
def test_date_select_within_fields_for_with_blank_index
|
1248
|
+
@post = Post.new
|
1249
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1250
|
+
id = nil
|
1251
|
+
|
1252
|
+
fields_for :post, @post, :index => id do |f|
|
1253
|
+
concat f.date_select(:written_on)
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
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"
|
1257
|
+
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"
|
1258
|
+
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"
|
1259
|
+
|
1260
|
+
assert_dom_equal(expected, output_buffer)
|
1261
|
+
end
|
1262
|
+
|
1050
1263
|
def test_date_select_with_index
|
1051
1264
|
@post = Post.new
|
1052
1265
|
@post.written_on = Date.new(2004, 6, 15)
|
@@ -1062,7 +1275,6 @@ class DateHelperTest < ActionView::TestCase
|
|
1062
1275
|
|
1063
1276
|
expected << %{<select id="post_456_written_on_3i" name="post[#{id}][written_on(3i)]">\n}
|
1064
1277
|
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}
|
1065
|
-
|
1066
1278
|
expected << "</select>\n"
|
1067
1279
|
|
1068
1280
|
assert_dom_equal expected, date_select("post", "written_on", :index => id)
|
@@ -1149,13 +1361,13 @@ class DateHelperTest < ActionView::TestCase
|
|
1149
1361
|
|
1150
1362
|
assert_dom_equal expected, date_select("post", "written_on", :include_blank => true)
|
1151
1363
|
end
|
1152
|
-
|
1364
|
+
|
1153
1365
|
def test_date_select_with_nil_and_blank_and_order
|
1154
1366
|
@post = Post.new
|
1155
1367
|
|
1156
1368
|
start_year = Time.now.year-5
|
1157
1369
|
end_year = Time.now.year+5
|
1158
|
-
|
1370
|
+
|
1159
1371
|
expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n"
|
1160
1372
|
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1161
1373
|
expected << "<option value=\"\"></option>\n"
|
@@ -1277,6 +1489,46 @@ class DateHelperTest < ActionView::TestCase
|
|
1277
1489
|
assert_dom_equal expected, date_select("post", "written_on", { :date_separator => " / " })
|
1278
1490
|
end
|
1279
1491
|
|
1492
|
+
def test_date_select_with_default_prompt
|
1493
|
+
@post = Post.new
|
1494
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1495
|
+
|
1496
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1497
|
+
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}
|
1498
|
+
expected << "</select>\n"
|
1499
|
+
|
1500
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1501
|
+
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}
|
1502
|
+
expected << "</select>\n"
|
1503
|
+
|
1504
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1505
|
+
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}
|
1506
|
+
|
1507
|
+
expected << "</select>\n"
|
1508
|
+
|
1509
|
+
assert_dom_equal expected, date_select("post", "written_on", :prompt => true)
|
1510
|
+
end
|
1511
|
+
|
1512
|
+
def test_date_select_with_custom_prompt
|
1513
|
+
@post = Post.new
|
1514
|
+
@post.written_on = Date.new(2004, 6, 15)
|
1515
|
+
|
1516
|
+
expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
1517
|
+
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}
|
1518
|
+
expected << "</select>\n"
|
1519
|
+
|
1520
|
+
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
1521
|
+
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}
|
1522
|
+
expected << "</select>\n"
|
1523
|
+
|
1524
|
+
expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
|
1525
|
+
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}
|
1526
|
+
|
1527
|
+
expected << "</select>\n"
|
1528
|
+
|
1529
|
+
assert_dom_equal expected, date_select("post", "written_on", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day'})
|
1530
|
+
end
|
1531
|
+
|
1280
1532
|
def test_time_select
|
1281
1533
|
@post = Post.new
|
1282
1534
|
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
@@ -1403,6 +1655,48 @@ class DateHelperTest < ActionView::TestCase
|
|
1403
1655
|
assert_dom_equal expected, time_select("post", "written_on", { :time_separator => " - ", :include_seconds => true })
|
1404
1656
|
end
|
1405
1657
|
|
1658
|
+
def test_time_select_with_default_prompt
|
1659
|
+
@post = Post.new
|
1660
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1661
|
+
|
1662
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1663
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1664
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1665
|
+
|
1666
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1667
|
+
expected << %(<option value="">Hour</option>\n)
|
1668
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1669
|
+
expected << "</select>\n"
|
1670
|
+
expected << " : "
|
1671
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1672
|
+
expected << %(<option value="">Minute</option>\n)
|
1673
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1674
|
+
expected << "</select>\n"
|
1675
|
+
|
1676
|
+
assert_dom_equal expected, time_select("post", "written_on", :prompt => true)
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
def test_time_select_with_custom_prompt
|
1680
|
+
@post = Post.new
|
1681
|
+
@post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
|
1682
|
+
|
1683
|
+
expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
|
1684
|
+
expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
|
1685
|
+
expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
|
1686
|
+
|
1687
|
+
expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
|
1688
|
+
expected << %(<option value="">Choose hour</option>\n)
|
1689
|
+
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
|
1690
|
+
expected << "</select>\n"
|
1691
|
+
expected << " : "
|
1692
|
+
expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
|
1693
|
+
expected << %(<option value="">Choose minute</option>\n)
|
1694
|
+
0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
|
1695
|
+
expected << "</select>\n"
|
1696
|
+
|
1697
|
+
assert_dom_equal expected, time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute'})
|
1698
|
+
end
|
1699
|
+
|
1406
1700
|
def test_datetime_select
|
1407
1701
|
@post = Post.new
|
1408
1702
|
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
@@ -1432,40 +1726,38 @@ class DateHelperTest < ActionView::TestCase
|
|
1432
1726
|
assert_dom_equal expected, datetime_select("post", "updated_at")
|
1433
1727
|
end
|
1434
1728
|
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
@post = Post.new
|
1729
|
+
def test_datetime_select_defaults_to_time_zone_now_when_config_time_zone_is_set
|
1730
|
+
time = stub(:year => 2004, :month => 6, :day => 15, :hour => 16, :min => 35, :sec => 0)
|
1731
|
+
time_zone = mock()
|
1732
|
+
time_zone.expects(:now).returns time
|
1733
|
+
Time.zone_default = time_zone
|
1734
|
+
@post = Post.new
|
1442
1735
|
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1736
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1737
|
+
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}
|
1738
|
+
expected << "</select>\n"
|
1446
1739
|
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1740
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1741
|
+
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}
|
1742
|
+
expected << "</select>\n"
|
1450
1743
|
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1744
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1745
|
+
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}
|
1746
|
+
expected << "</select>\n"
|
1454
1747
|
|
1455
|
-
|
1748
|
+
expected << " — "
|
1456
1749
|
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1750
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1751
|
+
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}
|
1752
|
+
expected << "</select>\n"
|
1753
|
+
expected << " : "
|
1754
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1755
|
+
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}
|
1756
|
+
expected << "</select>\n"
|
1464
1757
|
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
end
|
1758
|
+
assert_dom_equal expected, datetime_select("post", "updated_at")
|
1759
|
+
ensure
|
1760
|
+
Time.zone_default = nil
|
1469
1761
|
end
|
1470
1762
|
|
1471
1763
|
def test_datetime_select_with_html_options_within_fields_for
|
@@ -1526,6 +1818,64 @@ class DateHelperTest < ActionView::TestCase
|
|
1526
1818
|
assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true })
|
1527
1819
|
end
|
1528
1820
|
|
1821
|
+
def test_datetime_select_with_default_prompt
|
1822
|
+
@post = Post.new
|
1823
|
+
@post.updated_at = nil
|
1824
|
+
|
1825
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1826
|
+
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}
|
1827
|
+
expected << "</select>\n"
|
1828
|
+
|
1829
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1830
|
+
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}
|
1831
|
+
expected << "</select>\n"
|
1832
|
+
|
1833
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1834
|
+
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}
|
1835
|
+
expected << "</select>\n"
|
1836
|
+
|
1837
|
+
expected << " — "
|
1838
|
+
|
1839
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1840
|
+
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}
|
1841
|
+
expected << "</select>\n"
|
1842
|
+
expected << " : "
|
1843
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1844
|
+
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}
|
1845
|
+
expected << "</select>\n"
|
1846
|
+
|
1847
|
+
assert_dom_equal expected, datetime_select("post", "updated_at", :start_year=>1999, :end_year=>2009, :prompt => true)
|
1848
|
+
end
|
1849
|
+
|
1850
|
+
def test_datetime_select_with_custom_prompt
|
1851
|
+
@post = Post.new
|
1852
|
+
@post.updated_at = nil
|
1853
|
+
|
1854
|
+
expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
|
1855
|
+
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}
|
1856
|
+
expected << "</select>\n"
|
1857
|
+
|
1858
|
+
expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
|
1859
|
+
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}
|
1860
|
+
expected << "</select>\n"
|
1861
|
+
|
1862
|
+
expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
|
1863
|
+
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}
|
1864
|
+
expected << "</select>\n"
|
1865
|
+
|
1866
|
+
expected << " — "
|
1867
|
+
|
1868
|
+
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
|
1869
|
+
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}
|
1870
|
+
expected << "</select>\n"
|
1871
|
+
expected << " : "
|
1872
|
+
expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
|
1873
|
+
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}
|
1874
|
+
expected << "</select>\n"
|
1875
|
+
|
1876
|
+
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'})
|
1877
|
+
end
|
1878
|
+
|
1529
1879
|
def test_date_select_with_zero_value_and_no_start_year
|
1530
1880
|
expected = %(<select id="date_first_year" name="date[first][year]">\n)
|
1531
1881
|
(Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }
|
@@ -1645,6 +1995,40 @@ class DateHelperTest < ActionView::TestCase
|
|
1645
1995
|
assert_dom_equal expected, datetime_select("post", "updated_at", :index => id)
|
1646
1996
|
end
|
1647
1997
|
|
1998
|
+
def test_datetime_select_within_fields_for_with_options_index
|
1999
|
+
@post = Post.new
|
2000
|
+
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
2001
|
+
id = 456
|
2002
|
+
|
2003
|
+
fields_for :post, @post, :index => id do |f|
|
2004
|
+
concat f.datetime_select(:updated_at)
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
expected = %{<select id="post_456_updated_at_1i" name="post[#{id}][updated_at(1i)]">\n}
|
2008
|
+
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}
|
2009
|
+
expected << "</select>\n"
|
2010
|
+
|
2011
|
+
expected << %{<select id="post_456_updated_at_2i" name="post[#{id}][updated_at(2i)]">\n}
|
2012
|
+
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}
|
2013
|
+
expected << "</select>\n"
|
2014
|
+
|
2015
|
+
expected << %{<select id="post_456_updated_at_3i" name="post[#{id}][updated_at(3i)]">\n}
|
2016
|
+
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}
|
2017
|
+
expected << "</select>\n"
|
2018
|
+
|
2019
|
+
expected << " — "
|
2020
|
+
|
2021
|
+
expected << %{<select id="post_456_updated_at_4i" name="post[#{id}][updated_at(4i)]">\n}
|
2022
|
+
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}
|
2023
|
+
expected << "</select>\n"
|
2024
|
+
expected << " : "
|
2025
|
+
expected << %{<select id="post_456_updated_at_5i" name="post[#{id}][updated_at(5i)]">\n}
|
2026
|
+
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}
|
2027
|
+
expected << "</select>\n"
|
2028
|
+
|
2029
|
+
assert_dom_equal expected, output_buffer
|
2030
|
+
end
|
2031
|
+
|
1648
2032
|
def test_datetime_select_with_auto_index
|
1649
2033
|
@post = Post.new
|
1650
2034
|
@post.updated_at = Time.local(2004, 6, 15, 16, 35)
|
@@ -1932,7 +2316,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1932
2316
|
@post = Post.new
|
1933
2317
|
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
1934
2318
|
|
1935
|
-
options = {
|
2319
|
+
options = {
|
1936
2320
|
:order => [ :year, :month, :day ],
|
1937
2321
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
1938
2322
|
:discard_type => false,
|
@@ -1944,7 +2328,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1944
2328
|
|
1945
2329
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
1946
2330
|
# don't change this!
|
1947
|
-
assert_equal({
|
2331
|
+
assert_equal({
|
1948
2332
|
:order => [ :year, :month, :day ],
|
1949
2333
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
1950
2334
|
:discard_type => false,
|
@@ -1958,7 +2342,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1958
2342
|
@post = Post.new
|
1959
2343
|
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
1960
2344
|
|
1961
|
-
options = {
|
2345
|
+
options = {
|
1962
2346
|
:order => [ :year, :month, :day ],
|
1963
2347
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
1964
2348
|
:discard_type => false,
|
@@ -1970,7 +2354,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1970
2354
|
|
1971
2355
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
1972
2356
|
# don't change this!
|
1973
|
-
assert_equal({
|
2357
|
+
assert_equal({
|
1974
2358
|
:order => [ :year, :month, :day ],
|
1975
2359
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
1976
2360
|
:discard_type => false,
|
@@ -1984,7 +2368,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1984
2368
|
@post = Post.new
|
1985
2369
|
@post.updated_at = Time.local(2008, 7, 16, 23, 30)
|
1986
2370
|
|
1987
|
-
options = {
|
2371
|
+
options = {
|
1988
2372
|
:order => [ :year, :month, :day ],
|
1989
2373
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
1990
2374
|
:discard_type => false,
|
@@ -1996,7 +2380,7 @@ class DateHelperTest < ActionView::TestCase
|
|
1996
2380
|
|
1997
2381
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
1998
2382
|
# don't change this!
|
1999
|
-
assert_equal({
|
2383
|
+
assert_equal({
|
2000
2384
|
:order => [ :year, :month, :day ],
|
2001
2385
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2002
2386
|
:discard_type => false,
|
@@ -2007,7 +2391,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2007
2391
|
end
|
2008
2392
|
|
2009
2393
|
def test_select_date_should_not_change_passed_options_hash
|
2010
|
-
options = {
|
2394
|
+
options = {
|
2011
2395
|
:order => [ :year, :month, :day ],
|
2012
2396
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2013
2397
|
:discard_type => false,
|
@@ -2019,7 +2403,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2019
2403
|
|
2020
2404
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2021
2405
|
# don't change this!
|
2022
|
-
assert_equal({
|
2406
|
+
assert_equal({
|
2023
2407
|
:order => [ :year, :month, :day ],
|
2024
2408
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2025
2409
|
:discard_type => false,
|
@@ -2030,7 +2414,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2030
2414
|
end
|
2031
2415
|
|
2032
2416
|
def test_select_datetime_should_not_change_passed_options_hash
|
2033
|
-
options = {
|
2417
|
+
options = {
|
2034
2418
|
:order => [ :year, :month, :day ],
|
2035
2419
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2036
2420
|
:discard_type => false,
|
@@ -2042,7 +2426,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2042
2426
|
|
2043
2427
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2044
2428
|
# don't change this!
|
2045
|
-
assert_equal({
|
2429
|
+
assert_equal({
|
2046
2430
|
:order => [ :year, :month, :day ],
|
2047
2431
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2048
2432
|
:discard_type => false,
|
@@ -2053,7 +2437,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2053
2437
|
end
|
2054
2438
|
|
2055
2439
|
def test_select_time_should_not_change_passed_options_hash
|
2056
|
-
options = {
|
2440
|
+
options = {
|
2057
2441
|
:order => [ :year, :month, :day ],
|
2058
2442
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2059
2443
|
:discard_type => false,
|
@@ -2065,7 +2449,7 @@ class DateHelperTest < ActionView::TestCase
|
|
2065
2449
|
|
2066
2450
|
# note: the literal hash is intentional to show that the actual options hash isn't modified
|
2067
2451
|
# don't change this!
|
2068
|
-
assert_equal({
|
2452
|
+
assert_equal({
|
2069
2453
|
:order => [ :year, :month, :day ],
|
2070
2454
|
:default => { :year => 2008, :month => 7, :day => 16, :hour => 23, :minute => 30, :second => 1 },
|
2071
2455
|
:discard_type => false,
|