diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9abf436390d58c4c2aa97b00c0216abf70454011..591fe91b4ec92ae34ee334b1e5ce448871c22034 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added minute_step as an option to select_minute (and the helpers that use it) to jump in larger increments than just 1 minute. At 15, it would return 0, 15, 30, 45 options #1085 [ordwaye@evergreen.edu] + * Fixed that an exception would be thrown when an empty form was submitted #1090 [jan@ulbrich-boerwang.de] * Moved TextHelper#human_size to NumberHelper#number_to_human_size, but kept an deprecated alias to the old method name diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 9ffafe70b424135d48cc7be278a80583bae4870b..6f9545983c6e62f99be4d2b81d98552e49af818f 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -114,11 +114,12 @@ def select_second(datetime, options = {}) end # Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected. + # Also can return a select tag with options by minute_step from 0 through 59 with the 00 minute selected # The minute can also be substituted for a minute number. def select_minute(datetime, options = {}) minute_options = [] - 0.upto(59) do |minute| + 0.step(59, options[:minute_step] || 1) do |minute| minute_options << ((datetime && (datetime.kind_of?(Fixnum) ? datetime : datetime.min) == minute) ? "\n" : "\n" diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb index fa51ef8253a0787fcdfbd0612a90045e7e9a1894..ab5cfc1c7ab7a5cb2ec7fa309c0b9d2ed915f89f 100755 --- a/actionpack/test/template/date_helper_test.rb +++ b/actionpack/test/template/date_helper_test.rb @@ -164,6 +164,14 @@ def test_select_minute_with_blank assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :include_blank => true) end + def test_select_minute_with_blank_and_step + expected = %(\n" + + assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), { :include_blank => true , :minute_step => 15 }) + end + def test_select_minute_nil_with_blank expected = %(\n) + expected << %(\n\n\n\n\n) + expected << "\n" + + assert_equal expected, select_minute(nil, { :include_blank => true , :minute_step => 15 }) + end + def test_select_second expected = %(