Skip to content
This repository
Browse code

Added prompt options to date helpers [#561 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 389534c38c3baaa63ce5cc2ba3bd169415419167 1 parent 858a420
Sam Oliver authored December 21, 2008 lifo committed December 21, 2008
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *2.3.0 [Edge]*
2 2
 
  3
+* Add :prompt option to date/time select helpers. #561 [Sam Oliver]
  4
+
3 5
 * Fixed that send_file shouldn't set an etag #1578 [Hongli Lai]
4 6
 
5 7
 * Allow users to opt out of the spoofing checks in Request#remote_ip.  Useful for sites whose traffic regularly triggers false positives. [Darren Boyd]
79  actionpack/lib/action_view/helpers/date_helper.rb
@@ -136,6 +136,10 @@ def time_ago_in_words(from_time, include_seconds = false)
136 136
       #   dates.
137 137
       # * <tt>:default</tt>           - Set a default date if the affected date isn't set or is nil.
138 138
       # * <tt>:disabled</tt>          - Set to true if you want show the select fields as disabled.
  139
+      # * <tt>:prompt</tt>            - Set to true (for a generic prompt), a prompt string or a hash of prompt strings
  140
+      #   for <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:minute</tt> and <tt>:second</tt>.
  141
+      #   Setting this option prepends a select option with a generic prompt  (Day, Month, Year, Hour, Minute, Seconds)
  142
+      #   or the given prompt string.
139 143
       #
140 144
       # If anything is passed in the +html_options+ hash it will be applied to every select tag in the set.
141 145
       #
@@ -171,6 +175,9 @@ def time_ago_in_words(from_time, include_seconds = false)
171 175
       #   # that will have a default day of 20.
172 176
       #   date_select("credit_card", "bill_due", :default => { :day => 20 })
173 177
       #
  178
+      #   # Generates a date select with custom prompts
  179
+      #   date_select("post", "written_on", :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year' })
  180
+      #
174 181
       # The selects are prepared for multi-parameter assignment to an Active Record object.
175 182
       #
176 183
       # Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
@@ -210,6 +217,11 @@ def date_select(object_name, method, options = {}, html_options = {})
210 217
       #   # You can set the :minute_step to 15 which will give you: 00, 15, 30 and 45.
211 218
       #   time_select 'game', 'game_time', {:minute_step => 15}
212 219
       #
  220
+      #   # Creates a time select tag with a custom prompt. Use :prompt => true for generic prompts.
  221
+      #   time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})
  222
+      #   time_select("post", "written_on", :prompt => {:hour => true}) # generic prompt for hours
  223
+      #   time_select("post", "written_on", :prompt => true) # generic prompts for all
  224
+      #
213 225
       # The selects are prepared for multi-parameter assignment to an Active Record object.
214 226
       #
215 227
       # Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
@@ -241,6 +253,11 @@ def time_select(object_name, method, options = {}, html_options = {})
241 253
       #   # as the written_on attribute.
242 254
       #   datetime_select("post", "written_on", :discard_type => true)
243 255
       #
  256
+      #   # Generates a datetime select with a custom prompt. Use :prompt=>true for generic prompts.
  257
+      #   datetime_select("post", "written_on", :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
  258
+      #   datetime_select("post", "written_on", :prompt => {:hour => true}) # generic prompt for hours
  259
+      #   datetime_select("post", "written_on", :prompt => true) # generic prompts for all
  260
+      #
244 261
       # The selects are prepared for multi-parameter assignment to an Active Record object.
245 262
       def datetime_select(object_name, method, options = {}, html_options = {})
246 263
         InstanceTag.new(object_name, method, self, options.delete(:object)).to_datetime_select_tag(options, html_options)
@@ -285,6 +302,11 @@ def datetime_select(object_name, method, options = {}, html_options = {})
285 302
       #   # prefixed with 'payday' rather than 'date'
286 303
       #   select_datetime(my_date_time, :prefix => 'payday')
287 304
       #
  305
+      #   # Generates a datetime select with a custom prompt. Use :prompt=>true for generic prompts.
  306
+      #   select_datetime(my_date_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
  307
+      #   select_datetime(my_date_time, :prompt => {:hour => true}) # generic prompt for hours
  308
+      #   select_datetime(my_date_time, :prompt => true) # generic prompts for all
  309
+      #
288 310
       def select_datetime(datetime = Time.current, options = {}, html_options = {})
289 311
         DateTimeSelector.new(datetime, options, html_options).select_datetime
290 312
       end
@@ -321,6 +343,11 @@ def select_datetime(datetime = Time.current, options = {}, html_options = {})
321 343
       #   # prefixed with 'payday' rather than 'date'
322 344
       #   select_date(my_date, :prefix => 'payday')
323 345
       #
  346
+      #   # Generates a date select with a custom prompt. Use :prompt=>true for generic prompts.
  347
+      #   select_date(my_date, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
  348
+      #   select_date(my_date, :prompt => {:hour => true}) # generic prompt for hours
  349
+      #   select_date(my_date, :prompt => true) # generic prompts for all
  350
+      #
324 351
       def select_date(date = Date.current, options = {}, html_options = {})
325 352
         DateTimeSelector.new(date, options, html_options).select_date
326 353
       end
@@ -352,6 +379,11 @@ def select_date(date = Date.current, options = {}, html_options = {})
352 379
       #   # separated by ':' and includes an input for seconds
353 380
       #   select_time(my_time, :time_separator => ':', :include_seconds => true)
354 381
       #
  382
+      #   # Generates a time select with a custom prompt. Use :prompt=>true for generic prompts.
  383
+      #   select_time(my_time, :prompt => {:day => 'Choose day', :month => 'Choose month', :year => 'Choose year'})
  384
+      #   select_time(my_time, :prompt => {:hour => true}) # generic prompt for hours
  385
+      #   select_time(my_time, :prompt => true) # generic prompts for all
  386
+      #
355 387
       def select_time(datetime = Time.current, options = {}, html_options = {})
356 388
         DateTimeSelector.new(datetime, options, html_options).select_time
357 389
       end
@@ -373,6 +405,10 @@ def select_time(datetime = Time.current, options = {}, html_options = {})
373 405
       #   # that is named 'interval' rather than 'second'
374 406
       #   select_second(my_time, :field_name => 'interval')
375 407
       #
  408
+      #   # Generates a select field for seconds with a custom prompt.  Use :prompt=>true for a
  409
+      #   # generic prompt.
  410
+      #   select_minute(14, :prompt => 'Choose seconds')
  411
+      #
376 412
       def select_second(datetime, options = {}, html_options = {})
377 413
         DateTimeSelector.new(datetime, options, html_options).select_second
378 414
       end
@@ -395,6 +431,10 @@ def select_second(datetime, options = {}, html_options = {})
395 431
       #   # that is named 'stride' rather than 'second'
396 432
       #   select_minute(my_time, :field_name => 'stride')
397 433
       #
  434
+      #   # Generates a select field for minutes with a custom prompt.  Use :prompt=>true for a
  435
+      #   # generic prompt.
  436
+      #   select_minute(14, :prompt => 'Choose minutes')
  437
+      #
398 438
       def select_minute(datetime, options = {}, html_options = {})
399 439
         DateTimeSelector.new(datetime, options, html_options).select_minute
400 440
       end
@@ -416,6 +456,10 @@ def select_minute(datetime, options = {}, html_options = {})
416 456
       #   # that is named 'stride' rather than 'second'
417 457
       #   select_hour(my_time, :field_name => 'stride')
418 458
       #
  459
+      #   # Generates a select field for hours with a custom prompt.  Use :prompt => true for a
  460
+      #   # generic prompt.
  461
+      #   select_hour(13, :prompt =>'Choose hour')
  462
+      #
419 463
       def select_hour(datetime, options = {}, html_options = {})
420 464
         DateTimeSelector.new(datetime, options, html_options).select_hour
421 465
       end
@@ -437,6 +481,10 @@ def select_hour(datetime, options = {}, html_options = {})
437 481
       #   # that is named 'due' rather than 'day'
438 482
       #   select_day(my_time, :field_name => 'due')
439 483
       #
  484
+      #   # Generates a select field for days with a custom prompt.  Use :prompt => true for a
  485
+      #   # generic prompt.
  486
+      #   select_day(5, :prompt => 'Choose day')
  487
+      #
440 488
       def select_day(date, options = {}, html_options = {})
441 489
         DateTimeSelector.new(date, options, html_options).select_day
442 490
       end
@@ -475,6 +523,10 @@ def select_day(date, options = {}, html_options = {})
475 523
       #   # will use keys like "Januar", "Marts."
476 524
       #   select_month(Date.today, :use_month_names => %w(Januar Februar Marts ...))
477 525
       #
  526
+      #   # Generates a select field for months with a custom prompt.  Use :prompt => true for a
  527
+      #   # generic prompt.
  528
+      #   select_month(14, :prompt => 'Choose month')
  529
+      #
478 530
       def select_month(date, options = {}, html_options = {})
479 531
         DateTimeSelector.new(date, options, html_options).select_month
480 532
       end
@@ -502,6 +554,10 @@ def select_month(date, options = {}, html_options = {})
502 554
       #   # has ascending year values
503 555
       #   select_year(2006, :start_year => 2000, :end_year => 2010)
504 556
       #
  557
+      #   # Generates a select field for years with a custom prompt.  Use :prompt => true for a
  558
+      #   # generic prompt.
  559
+      #   select_year(14, :prompt => 'Choose year')
  560
+      #
505 561
       def select_year(date, options = {}, html_options = {})
506 562
         DateTimeSelector.new(date, options, html_options).select_year
507 563
       end
@@ -516,6 +572,10 @@ class DateTimeSelector #:nodoc:
516 572
         :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6
517 573
       }.freeze unless const_defined?('POSITION')
518 574
 
  575
+      DEFAULT_PROMPTS = {
  576
+        :year => 'Year', :month => 'Month', :day => 'Day', :hour => 'Hour', :minute => 'Minute', :second => 'Seconds'
  577
+      }.freeze unless const_defined?('DEFAULT_PROMPTS')
  578
+
519 579
       def initialize(datetime, options = {}, html_options = {})
520 580
         @options      = options.dup
521 581
         @html_options = html_options.dup
@@ -764,11 +824,30 @@ def build_select(type, select_options_as_html)
764 824
 
765 825
           select_html = "\n"
766 826
           select_html << content_tag(:option, '', :value => '') + "\n" if @options[:include_blank]
  827
+          select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
767 828
           select_html << select_options_as_html.to_s
768 829
 
769 830
           content_tag(:select, select_html, select_options) + "\n"
770 831
         end
771 832
 
  833
+        # Builds a prompt option tag with supplied options or from default options
  834
+        #  prompt_option_tag(:month, :prompt => 'Select month')
  835
+        #  => "<option value="">Select month</option>"
  836
+        def prompt_option_tag(type, options)
  837
+          default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false}
  838
+
  839
+          case options
  840
+          when Hash
  841
+            prompt = default_options.merge(options)[type.to_sym]
  842
+          when String
  843
+            prompt = options
  844
+          else
  845
+            prompt = ActionView::Helpers::DateTimeSelector::DEFAULT_PROMPTS[type.to_sym]
  846
+          end
  847
+
  848
+          prompt ? content_tag(:option, prompt, :value => '')  : ''
  849
+        end
  850
+
772 851
         # Builds hidden input tag for date part and value
773 852
         #  build_hidden(:year, 2008)
774 853
         #  => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
321  actionpack/test/template/date_helper_test.rb
@@ -153,6 +153,22 @@ def test_select_day_with_html_options
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 @@ def test_select_month_with_html_options
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 @@ def test_select_year_with_html_options
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 @@ def test_select_hour_with_html_options
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 @@ def test_select_minute_with_html_options
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 @@ def test_select_second_with_html_options
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 @@ def test_select_datetime_should_work_with_date
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 @@ def test_select_time_should_work_with_date
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)
@@ -1277,6 +1458,46 @@ def test_date_select_with_separator
1277 1458
     assert_dom_equal expected, date_select("post", "written_on", { :date_separator => " / " })
1278 1459
   end
1279 1460
 
  1461
+  def test_date_select_with_default_prompt
  1462
+    @post = Post.new
  1463
+    @post.written_on = Date.new(2004, 6, 15)
  1464
+
  1465
+    expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
  1466
+    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}
  1467
+    expected << "</select>\n"
  1468
+
  1469
+    expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
  1470
+    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}
  1471
+    expected << "</select>\n"
  1472
+
  1473
+    expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
  1474
+    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}
  1475
+
  1476
+    expected << "</select>\n"
  1477
+
  1478
+    assert_dom_equal expected, date_select("post", "written_on", :prompt => true)
  1479
+  end
  1480
+
  1481
+  def test_date_select_with_custom_prompt
  1482
+    @post = Post.new
  1483
+    @post.written_on = Date.new(2004, 6, 15)
  1484
+
  1485
+    expected = %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
  1486
+    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}
  1487
+    expected << "</select>\n"
  1488
+
  1489
+    expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
  1490
+    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}
  1491
+    expected << "</select>\n"
  1492
+
  1493
+    expected << %{<select id="post_written_on_3i" name="post[written_on(3i)]">\n}
  1494
+    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}
  1495
+
  1496
+    expected << "</select>\n"
  1497
+
  1498
+    assert_dom_equal expected, date_select("post", "written_on", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day'})
  1499
+  end
  1500
+
1280 1501
   def test_time_select
1281 1502
     @post = Post.new
1282 1503
     @post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
@@ -1403,6 +1624,48 @@ def test_time_select_with_separator
1403 1624
     assert_dom_equal expected, time_select("post", "written_on", { :time_separator => " - ", :include_seconds => true })
1404 1625
   end
1405 1626
 
  1627
+  def test_time_select_with_default_prompt
  1628
+    @post = Post.new
  1629
+    @post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
  1630
+
  1631
+    expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
  1632
+    expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
  1633
+    expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
  1634
+
  1635
+    expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
  1636
+    expected << %(<option value="">Hour</option>\n)
  1637
+    0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
  1638
+    expected << "</select>\n"
  1639
+    expected << " : "
  1640
+    expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
  1641
+        expected << %(<option value="">Minute</option>\n)
  1642
+    0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
  1643
+    expected << "</select>\n"
  1644
+
  1645
+    assert_dom_equal expected, time_select("post", "written_on", :prompt => true)
  1646
+  end
  1647
+
  1648
+  def test_time_select_with_custom_prompt
  1649
+    @post = Post.new
  1650
+    @post.written_on = Time.local(2004, 6, 15, 15, 16, 35)
  1651
+
  1652
+    expected = %{<input type="hidden" id="post_written_on_1i" name="post[written_on(1i)]" value="2004" />\n}
  1653
+    expected << %{<input type="hidden" id="post_written_on_2i" name="post[written_on(2i)]" value="6" />\n}
  1654
+    expected << %{<input type="hidden" id="post_written_on_3i" name="post[written_on(3i)]" value="15" />\n}
  1655
+
  1656
+    expected << %(<select id="post_written_on_4i" name="post[written_on(4i)]">\n)
  1657
+    expected << %(<option value="">Choose hour</option>\n)
  1658
+    0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
  1659
+    expected << "</select>\n"
  1660
+    expected << " : "
  1661
+    expected << %(<select id="post_written_on_5i" name="post[written_on(5i)]">\n)
  1662
+        expected << %(<option value="">Choose minute</option>\n)
  1663
+    0.upto(59) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 16}>#{sprintf("%02d", i)}</option>\n) }
  1664
+    expected << "</select>\n"
  1665
+
  1666
+    assert_dom_equal expected, time_select("post", "written_on", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute'})
  1667
+  end
  1668
+
1406 1669
   def test_datetime_select
1407 1670
     @post = Post.new
1408 1671
     @post.updated_at = Time.local(2004, 6, 15, 16, 35)
@@ -1526,6 +1789,64 @@ def test_datetime_select_with_separators
1526 1789
     assert_dom_equal expected, datetime_select("post", "updated_at", { :date_separator => " / ", :datetime_separator => " , ", :time_separator => " - ", :include_seconds => true })
1527 1790
   end
1528 1791
 
  1792
+  def test_datetime_select_with_default_prompt
  1793
+    @post = Post.new
  1794
+    @post.updated_at = Time.local(2004, 6, 15, 16, 35)
  1795
+
  1796
+    expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
  1797
+    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}
  1798
+    expected << "</select>\n"
  1799
+
  1800
+    expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
  1801
+    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}
  1802
+    expected << "</select>\n"
  1803
+
  1804
+    expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
  1805
+    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}
  1806
+    expected << "</select>\n"
  1807
+
  1808
+    expected << " &mdash; "
  1809
+
  1810
+    expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
  1811
+    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" 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}
  1812
+    expected << "</select>\n"
  1813
+    expected << " : "
  1814
+    expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
  1815
+    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" 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}
  1816
+    expected << "</select>\n"
  1817
+
  1818
+    assert_dom_equal expected, datetime_select("post", "updated_at", :prompt => true)
  1819
+  end
  1820
+
  1821
+  def test_datetime_select_with_custom_prompt
  1822
+    @post = Post.new
  1823
+    @post.updated_at = Time.local(2004, 6, 15, 16, 35)
  1824
+
  1825
+    expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
  1826
+    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}
  1827
+    expected << "</select>\n"
  1828
+
  1829
+    expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
  1830
+    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}
  1831
+    expected << "</select>\n"
  1832
+
  1833
+    expected << %{<select id="post_updated_at_3i" name="post[updated_at(3i)]">\n}
  1834
+    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}
  1835
+    expected << "</select>\n"
  1836
+
  1837
+    expected << " &mdash; "
  1838
+
  1839
+    expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
  1840
+    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" 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}
  1841
+    expected << "</select>\n"
  1842
+    expected << " : "
  1843
+    expected << %{<select id="post_updated_at_5i" name="post[updated_at(5i)]">\n}
  1844
+    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" 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}
  1845
+    expected << "</select>\n"
  1846
+
  1847
+    assert_dom_equal expected, datetime_select("post", "updated_at", :prompt => {:year => 'Choose year', :month => 'Choose month', :day => 'Choose day', :hour => 'Choose hour', :minute => 'Choose minute'})
  1848
+  end
  1849
+
1529 1850
   def test_date_select_with_zero_value_and_no_start_year
1530 1851
     expected =  %(<select id="date_first_year" name="date[first][year]">\n)
1531 1852
     (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option value="#{y}">#{y}</option>\n) }

3 notes on commit 389534c

Pratik
Owner

Patch please!

Sam Oliver

Patch added to the lighthouse ticket #561

Yaroslav Markin

@samoli thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.