actionpack 1.9.1 → 1.10.1

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.

Files changed (123) hide show
  1. data/CHANGELOG +237 -0
  2. data/README +12 -12
  3. data/lib/action_controller.rb +17 -12
  4. data/lib/action_controller/assertions.rb +119 -67
  5. data/lib/action_controller/base.rb +184 -102
  6. data/lib/action_controller/benchmarking.rb +35 -6
  7. data/lib/action_controller/caching.rb +115 -58
  8. data/lib/action_controller/cgi_ext/cgi_methods.rb +54 -21
  9. data/lib/action_controller/cgi_ext/cookie_performance_fix.rb +39 -35
  10. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +34 -21
  11. data/lib/action_controller/cgi_process.rb +23 -20
  12. data/lib/action_controller/components.rb +11 -2
  13. data/lib/action_controller/dependencies.rb +0 -5
  14. data/lib/action_controller/deprecated_redirects.rb +17 -0
  15. data/lib/action_controller/filters.rb +13 -9
  16. data/lib/action_controller/flash.rb +7 -7
  17. data/lib/action_controller/helpers.rb +1 -14
  18. data/lib/action_controller/layout.rb +40 -29
  19. data/lib/action_controller/macros/auto_complete.rb +52 -0
  20. data/lib/action_controller/macros/in_place_editing.rb +32 -0
  21. data/lib/action_controller/pagination.rb +44 -28
  22. data/lib/action_controller/request.rb +54 -40
  23. data/lib/action_controller/rescue.rb +8 -6
  24. data/lib/action_controller/routing.rb +77 -28
  25. data/lib/action_controller/scaffolding.rb +10 -14
  26. data/lib/action_controller/session/active_record_store.rb +36 -7
  27. data/lib/action_controller/session_management.rb +126 -0
  28. data/lib/action_controller/streaming.rb +14 -5
  29. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +1 -1
  30. data/lib/action_controller/templates/rescues/_trace.rhtml +24 -0
  31. data/lib/action_controller/templates/rescues/diagnostics.rhtml +2 -13
  32. data/lib/action_controller/templates/rescues/template_error.rhtml +4 -2
  33. data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
  34. data/lib/action_controller/test_process.rb +35 -17
  35. data/lib/action_controller/upload_progress.rb +52 -0
  36. data/lib/action_controller/url_rewriter.rb +21 -16
  37. data/lib/action_controller/vendor/html-scanner/html/document.rb +2 -2
  38. data/lib/action_controller/vendor/html-scanner/html/node.rb +30 -3
  39. data/lib/action_pack/version.rb +9 -0
  40. data/lib/action_view.rb +1 -1
  41. data/lib/action_view/base.rb +204 -60
  42. data/lib/action_view/compiled_templates.rb +70 -0
  43. data/lib/action_view/helpers/active_record_helper.rb +7 -3
  44. data/lib/action_view/helpers/asset_tag_helper.rb +22 -12
  45. data/lib/action_view/helpers/capture_helper.rb +2 -10
  46. data/lib/action_view/helpers/date_helper.rb +21 -13
  47. data/lib/action_view/helpers/form_helper.rb +14 -10
  48. data/lib/action_view/helpers/form_options_helper.rb +4 -4
  49. data/lib/action_view/helpers/form_tag_helper.rb +59 -25
  50. data/lib/action_view/helpers/java_script_macros_helper.rb +188 -0
  51. data/lib/action_view/helpers/javascript_helper.rb +68 -133
  52. data/lib/action_view/helpers/javascripts/controls.js +427 -165
  53. data/lib/action_view/helpers/javascripts/dragdrop.js +256 -277
  54. data/lib/action_view/helpers/javascripts/effects.js +766 -277
  55. data/lib/action_view/helpers/javascripts/prototype.js +906 -218
  56. data/lib/action_view/helpers/javascripts/slider.js +258 -0
  57. data/lib/action_view/helpers/number_helper.rb +4 -3
  58. data/lib/action_view/helpers/pagination_helper.rb +42 -27
  59. data/lib/action_view/helpers/tag_helper.rb +25 -11
  60. data/lib/action_view/helpers/text_helper.rb +119 -13
  61. data/lib/action_view/helpers/upload_progress_helper.rb +2 -2
  62. data/lib/action_view/helpers/url_helper.rb +68 -21
  63. data/lib/action_view/partials.rb +17 -6
  64. data/lib/action_view/template_error.rb +19 -24
  65. data/rakefile +4 -3
  66. data/test/abstract_unit.rb +2 -1
  67. data/test/controller/action_pack_assertions_test.rb +62 -2
  68. data/test/controller/active_record_assertions_test.rb +5 -6
  69. data/test/controller/active_record_store_test.rb +23 -1
  70. data/test/controller/addresses_render_test.rb +4 -0
  71. data/test/controller/{base_tests.rb → base_test.rb} +4 -3
  72. data/test/controller/benchmark_test.rb +36 -0
  73. data/test/controller/caching_filestore.rb +22 -40
  74. data/test/controller/capture_test.rb +10 -1
  75. data/test/controller/cgi_test.rb +145 -23
  76. data/test/controller/components_test.rb +50 -0
  77. data/test/controller/custom_handler_test.rb +3 -3
  78. data/test/controller/fake_controllers.rb +24 -0
  79. data/test/controller/filters_test.rb +6 -6
  80. data/test/controller/flash_test.rb +6 -6
  81. data/test/controller/fragment_store_setting_test.rb +45 -0
  82. data/test/controller/helper_test.rb +1 -3
  83. data/test/controller/new_render_test.rb +119 -7
  84. data/test/controller/redirect_test.rb +11 -1
  85. data/test/controller/render_test.rb +34 -1
  86. data/test/controller/request_test.rb +14 -5
  87. data/test/controller/routing_test.rb +238 -42
  88. data/test/controller/send_file_test.rb +11 -10
  89. data/test/controller/session_management_test.rb +94 -0
  90. data/test/controller/test_test.rb +194 -5
  91. data/test/controller/url_rewriter_test.rb +46 -0
  92. data/test/fixtures/layouts/talk_from_action.rhtml +2 -0
  93. data/test/fixtures/layouts/yield.rhtml +2 -0
  94. data/test/fixtures/multipart/binary_file +0 -0
  95. data/test/fixtures/multipart/large_text_file +10 -0
  96. data/test/fixtures/multipart/mixed_files +0 -0
  97. data/test/fixtures/multipart/single_parameter +5 -0
  98. data/test/fixtures/multipart/text_file +10 -0
  99. data/test/fixtures/test/_customer_greeting.rhtml +1 -0
  100. data/test/fixtures/test/_hash_object.rhtml +1 -0
  101. data/test/fixtures/test/_person.rhtml +2 -0
  102. data/test/fixtures/test/action_talk_to_layout.rhtml +2 -0
  103. data/test/fixtures/test/content_for.rhtml +2 -0
  104. data/test/fixtures/test/potential_conflicts.rhtml +4 -0
  105. data/test/template/active_record_helper_test.rb +15 -8
  106. data/test/template/asset_tag_helper_test.rb +40 -16
  107. data/test/template/compiled_templates_tests.rb +63 -0
  108. data/test/template/date_helper_test.rb +80 -4
  109. data/test/template/form_helper_test.rb +48 -42
  110. data/test/template/form_options_helper_test.rb +40 -40
  111. data/test/template/form_tag_helper_test.rb +21 -15
  112. data/test/template/java_script_macros_helper_test.rb +56 -0
  113. data/test/template/javascript_helper_test.rb +70 -47
  114. data/test/template/number_helper_test.rb +2 -0
  115. data/test/template/tag_helper_test.rb +9 -0
  116. data/test/template/text_helper_test.rb +146 -1
  117. data/test/template/upload_progress_helper_testx.rb +11 -147
  118. data/test/template/url_helper_test.rb +90 -22
  119. data/test/testing_sandbox.rb +26 -0
  120. metadata +37 -7
  121. data/lib/action_controller/auto_complete.rb +0 -47
  122. data/lib/action_controller/deprecated_renders_and_redirects.rb +0 -76
  123. data/lib/action_controller/session.rb +0 -14
@@ -0,0 +1,5 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="foo"
3
+
4
+ bar
5
+ --AaB03x--
@@ -0,0 +1,10 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="foo"
3
+
4
+ bar
5
+ --AaB03x
6
+ Content-Disposition: form-data; name="file"; filename="file.txt"
7
+ Content-Type: text/plain
8
+
9
+ contents
10
+ --AaB03x--
@@ -0,0 +1 @@
1
+ <%= greeting %>: <%= customer_greeting.name %>
@@ -0,0 +1 @@
1
+ <%= hash_object[:first_name] %>
@@ -0,0 +1,2 @@
1
+ Second: <%= name %>
2
+ Third: <%= @name %>
@@ -0,0 +1,2 @@
1
+ <% @title = "Talking to the layout" -%>
2
+ Action was here!
@@ -0,0 +1,2 @@
1
+ <% content_for :title do %>Putting stuff in the title!<% end %>
2
+ Great stuff!
@@ -0,0 +1,4 @@
1
+ First: <%= @name %>
2
+ <%= render :partial => "person", :locals => { :name => "Stephan" } -%>
3
+ Fourth: <%= @name %>
4
+ Fifth: <%= name %>
@@ -60,27 +60,27 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
60
60
  end
61
61
 
62
62
  def test_generic_input_tag
63
- assert_equal(
63
+ assert_dom_equal(
64
64
  %(<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />), input("post", "title")
65
65
  )
66
66
  end
67
67
 
68
68
  def test_text_area_with_errors
69
- assert_equal(
69
+ assert_dom_equal(
70
70
  %(<div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div>),
71
71
  text_area("post", "body")
72
72
  )
73
73
  end
74
74
 
75
75
  def test_text_field_with_errors
76
- assert_equal(
76
+ assert_dom_equal(
77
77
  %(<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>),
78
78
  text_field("post", "author_name")
79
79
  )
80
80
  end
81
81
 
82
82
  def test_form_with_string
83
- assert_equal(
83
+ assert_dom_equal(
84
84
  %(<form action="create" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
85
85
  form("post")
86
86
  )
@@ -90,7 +90,7 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
90
90
  def to_param() id end
91
91
  def id() 1 end
92
92
  end
93
- assert_equal(
93
+ assert_dom_equal(
94
94
  %(<form action="update/1" method="post"><input id="post_id" name="post[id]" type="hidden" value="1" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Update" /></form>),
95
95
  form("post")
96
96
  )
@@ -99,7 +99,7 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
99
99
  def test_form_with_date
100
100
  def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end
101
101
 
102
- assert_equal(
102
+ assert_dom_equal(
103
103
  %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option 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</select>\n<select name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option 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</select>\n<select name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option 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</select>\n</p><input name="commit" type="submit" value="Create" /></form>),
104
104
  form("post")
105
105
  )
@@ -109,14 +109,21 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
109
109
  def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end
110
110
  @post.written_on = Time.gm(2004, 6, 15, 16, 30)
111
111
 
112
- assert_equal(
112
+ assert_dom_equal(
113
113
  %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select name="post[written_on(1i)]">\n<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option 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</select>\n<select name="post[written_on(2i)]">\n<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option 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</select>\n<select name="post[written_on(3i)]">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option 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</select>\n &mdash; <select name="post[written_on(4i)]">\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</select>\n : <select name="post[written_on(5i)]">\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" selected="selected">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</select>\n</p><input name="commit" type="submit" value="Create" /></form>),
114
114
  form("post")
115
115
  )
116
116
  end
117
117
 
118
118
  def test_error_for_block
119
- assert_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post")
119
+ assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post")
120
120
  assert_equal %(<div class="errorDeathByClass" id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1")
121
121
  end
122
+
123
+ def test_form_with_string_multipart
124
+ assert_dom_equal(
125
+ %(<form action="create" enctype="multipart/form-data" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
126
+ form("post", :multipart => true)
127
+ )
128
+ end
122
129
  end
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/asset_tag_helper'
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
3
2
 
4
3
  class AssetTagHelperTest < Test::Unit::TestCase
5
4
  include ActionView::Helpers::TagHelper
@@ -8,6 +7,8 @@ class AssetTagHelperTest < Test::Unit::TestCase
8
7
 
9
8
  def setup
10
9
  @controller = Class.new do
10
+
11
+ attr_accessor :request
11
12
 
12
13
  def url_for(options, *parameters_for_method_reference)
13
14
  "http://www.example.com"
@@ -20,6 +21,8 @@ class AssetTagHelperTest < Test::Unit::TestCase
20
21
  ""
21
22
  end
22
23
  end.new
24
+
25
+ @controller.request = @request
23
26
 
24
27
  end
25
28
 
@@ -27,6 +30,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
27
30
  %(auto_discovery_link_tag) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
28
31
  %(auto_discovery_link_tag(:atom)) => %(<link href="http://www.example.com" rel="alternate" title="ATOM" type="application/atom+xml" />),
29
32
  %(auto_discovery_link_tag(:rss, :action => "feed")) => %(<link href="http://www.example.com" rel="alternate" title="RSS" type="application/rss+xml" />),
33
+ %(auto_discovery_link_tag(:rss, "http://localhost/feed")) => %(<link href="http://localhost/feed" rel="alternate" title="RSS" type="application/rss+xml" />),
30
34
  %(auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
31
35
  %(auto_discovery_link_tag(:rss, {}, {:title => "My RSS"})) => %(<link href="http://www.example.com" rel="alternate" title="My RSS" type="application/rss+xml" />),
32
36
  %(auto_discovery_link_tag(nil, {}, {:type => "text/html"})) => %(<link href="http://www.example.com" rel="alternate" title="" type="text/html" />),
@@ -37,6 +41,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
37
41
 
38
42
  JavascriptPathToTag = {
39
43
  %(javascript_path("xmlhr")) => %(/javascripts/xmlhr.js),
44
+ %(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js)
40
45
  }
41
46
 
42
47
  JavascriptIncludeToTag = {
@@ -47,10 +52,14 @@ class AssetTagHelperTest < Test::Unit::TestCase
47
52
 
48
53
  StylePathToTag = {
49
54
  %(stylesheet_path("style")) => %(/stylesheets/style.css),
55
+ %(stylesheet_path('dir/file')) => %(/stylesheets/dir/file.css),
56
+ %(stylesheet_path('/dir/file')) => %(/dir/file.css)
50
57
  }
51
58
 
52
59
  StyleLinkToTag = {
53
60
  %(stylesheet_link_tag("style")) => %(<link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />),
61
+ %(stylesheet_link_tag("/dir/file")) => %(<link href="/dir/file.css" media="screen" rel="Stylesheet" type="text/css" />),
62
+ %(stylesheet_link_tag("dir/file")) => %(<link href="/stylesheets/dir/file.css" media="screen" rel="Stylesheet" type="text/css" />),
54
63
  %(stylesheet_link_tag("style", :media => "all")) => %(<link href="/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />),
55
64
  %(stylesheet_link_tag("random.styles", "/css/stylish")) => %(<link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />\n<link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />)
56
65
  }
@@ -66,31 +75,31 @@ class AssetTagHelperTest < Test::Unit::TestCase
66
75
  }
67
76
 
68
77
  def test_auto_discovery
69
- AutoDiscoveryToTag.each { |method, tag| assert_equal(tag, eval(method)) }
78
+ AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
70
79
  end
71
80
 
72
81
  def test_javascript_path
73
- JavascriptPathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
82
+ JavascriptPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
74
83
  end
75
84
 
76
85
  def test_javascript_include
77
- JavascriptIncludeToTag.each { |method, tag| assert_equal(tag, eval(method)) }
86
+ JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
78
87
  end
79
88
 
80
89
  def test_style_path
81
- StylePathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
90
+ StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
82
91
  end
83
92
 
84
93
  def test_style_link
85
- StyleLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
94
+ StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
86
95
  end
87
96
 
88
97
  def test_image_path
89
- ImagePathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
98
+ ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
90
99
  end
91
100
 
92
101
  def test_image_tag
93
- ImageLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
102
+ ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
94
103
  end
95
104
 
96
105
  end
@@ -103,6 +112,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
103
112
  def setup
104
113
  @controller = Class.new do
105
114
 
115
+ attr_accessor :request
116
+
106
117
  def url_for(options, *parameters_for_method_reference)
107
118
  "http://www.example.com/calloboration/hieraki"
108
119
  end
@@ -115,6 +126,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
115
126
  end
116
127
  end.new
117
128
 
129
+ @controller.request = @request
130
+
118
131
  end
119
132
 
120
133
  AutoDiscoveryToTag = {
@@ -130,6 +143,7 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
130
143
  JavascriptIncludeToTag = {
131
144
  %(javascript_include_tag("xmlhr")) => %(<script src="/calloboration/hieraki/javascripts/xmlhr.js" type="text/javascript"></script>),
132
145
  %(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/calloboration/hieraki/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/calloboration/hieraki/elsewhere/cools.js" type="text/javascript"></script>),
146
+ %(javascript_include_tag(:defaults)) => %(<script src='/calloboration/hieraki/javascripts/prototype.js' type='text/javascript'></script>\n<script src='/calloboration/hieraki/javascripts/scriptaculous.js' type='text/javascript'></script>),
133
147
  }
134
148
 
135
149
  StylePathToTag = {
@@ -153,33 +167,43 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
153
167
  }
154
168
 
155
169
  def test_auto_discovery
156
- AutoDiscoveryToTag.each { |method, tag| assert_equal(tag, eval(method)) }
170
+ AutoDiscoveryToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
157
171
  end
158
172
 
159
173
  def test_javascript_path
160
- JavascriptPathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
174
+ JavascriptPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
161
175
  end
162
176
 
163
177
  def test_javascript_include
164
- JavascriptIncludeToTag.each { |method, tag| assert_equal(tag, eval(method)) }
178
+ JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
165
179
  end
166
180
 
167
181
  def test_style_path
168
- StylePathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
182
+ StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
169
183
  end
170
184
 
171
185
  def test_style_link
172
- StyleLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
186
+ StyleLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
173
187
  end
174
188
 
175
189
  def test_image_path
176
- ImagePathToTag.each { |method, tag| assert_equal(tag, eval(method)) }
190
+ ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
177
191
  end
178
192
 
179
193
  def test_image_tag
180
- ImageLinkToTag.each { |method, tag| assert_equal(tag, eval(method)) }
194
+ ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
181
195
  # Assigning a default alt tag should not cause an exception to be raised
182
196
  assert_nothing_raised { image_tag('') }
183
197
  end
184
198
 
199
+ def test_stylesheet_with_asset_host_already_encoded
200
+ ActionController::Base.asset_host = "http://foo.example.com"
201
+ result = stylesheet_link_tag("http://bar.example.com/stylesheets/style.css")
202
+ assert_dom_equal(
203
+ %(<link href="http://bar.example.com/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />),
204
+ result)
205
+ ensure
206
+ ActionController::Base.asset_host = ""
207
+ end
208
+
185
209
  end
@@ -0,0 +1,63 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper'
3
+ require File.dirname(__FILE__) + "/../abstract_unit"
4
+
5
+ class CompiledTemplateTests < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @ct = ActionView::CompiledTemplates.new
9
+ @v = Class.new
10
+ @v.send :include, @ct
11
+ end
12
+ attr_reader :ct, :v
13
+
14
+ def test_name_allocation
15
+ hi_world = ct.method_names['hi world']
16
+ hi_sexy = ct.method_names['hi sexy']
17
+ wish_upon_a_star = ct.method_names['I love seeing decent error messages']
18
+
19
+ assert_equal hi_world, ct.method_names['hi world']
20
+ assert_equal hi_sexy, ct.method_names['hi sexy']
21
+ assert_equal wish_upon_a_star, ct.method_names['I love seeing decent error messages']
22
+ assert_equal 3, [hi_world, hi_sexy, wish_upon_a_star].uniq.length
23
+ end
24
+
25
+ def test_wrap_source
26
+ assert_equal(
27
+ "def aliased_assignment(value)\nself.value = value\nend",
28
+ @ct.wrap_source(:aliased_assignment, [:value], 'self.value = value')
29
+ )
30
+
31
+ assert_equal(
32
+ "def simple()\nnil\nend",
33
+ @ct.wrap_source(:simple, [], 'nil')
34
+ )
35
+ end
36
+
37
+ def test_compile_source_single_method
38
+ selector = ct.compile_source('doubling method', [:a], 'a + a')
39
+ assert_equal 2, @v.new.send(selector, 1)
40
+ assert_equal 4, @v.new.send(selector, 2)
41
+ assert_equal -4, @v.new.send(selector, -2)
42
+ assert_equal 0, @v.new.send(selector, 0)
43
+ selector
44
+ end
45
+
46
+ def test_compile_source_two_method
47
+ sel1 = test_compile_source_single_method # compile the method in the other test
48
+ sel2 = ct.compile_source('doubling method', [:a, :b], 'a + b + a + b')
49
+ assert_not_equal sel1, sel2
50
+
51
+ assert_equal 2, @v.new.send(sel1, 1)
52
+ assert_equal 4, @v.new.send(sel1, 2)
53
+
54
+ assert_equal 6, @v.new.send(sel2, 1, 2)
55
+ assert_equal 32, @v.new.send(sel2, 15, 1)
56
+ end
57
+
58
+ def test_mtime
59
+ t1 = Time.now
60
+ test_compile_source_single_method
61
+ assert (t1..Time.now).include?(ct.mtime('doubling method', [:a]))
62
+ end
63
+ end
@@ -42,8 +42,8 @@ class DateHelperTest < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_distance_in_words_date
45
- start_date = Date.new 1904, 1, 31
46
- end_date = Date.new 1906, 4, 17
45
+ start_date = Date.new 1975, 1, 31
46
+ end_date = Date.new 1977, 4, 17
47
47
  assert_not_equal("13 minutes",
48
48
  distance_of_time_in_words(start_date, end_date))
49
49
  end
@@ -86,6 +86,15 @@ class DateHelperTest < Test::Unit::TestCase
86
86
  assert_equal expected, select_month(8)
87
87
  end
88
88
 
89
+ def test_select_month_with_disabled
90
+ expected = %(<select name="date[month]" disabled="disabled">\n)
91
+ 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)
92
+ expected << "</select>\n"
93
+
94
+ assert_equal expected, select_month(Time.mktime(2003, 8, 16), :disabled => true)
95
+ assert_equal expected, select_month(8, :disabled => true)
96
+ end
97
+
89
98
  def test_select_month_with_field_name_override
90
99
  expected = %(<select name="date[mois]">\n)
91
100
  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)
@@ -130,6 +139,24 @@ class DateHelperTest < Test::Unit::TestCase
130
139
  assert_equal expected, select_month(8, :add_month_numbers => true)
131
140
  end
132
141
 
142
+ def test_select_month_with_numbers_and_names_with_abbv
143
+ expected = %(<select name="date[month]">\n)
144
+ expected << %(<option value="1">1 - Jan</option>\n<option value="2">2 - Feb</option>\n<option value="3">3 - Mar</option>\n<option value="4">4 - Apr</option>\n<option value="5">5 - May</option>\n<option value="6">6 - Jun</option>\n<option value="7">7 - Jul</option>\n<option value="8" selected="selected">8 - Aug</option>\n<option value="9">9 - Sep</option>\n<option value="10">10 - Oct</option>\n<option value="11">11 - Nov</option>\n<option value="12">12 - Dec</option>\n)
145
+ expected << "</select>\n"
146
+
147
+ assert_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true, :use_short_month => true)
148
+ assert_equal expected, select_month(8, :add_month_numbers => true, :use_short_month => true)
149
+ end
150
+
151
+ def test_select_month_with_abbv
152
+ expected = %(<select name="date[month]">\n)
153
+ expected << %(<option value="1">Jan</option>\n<option value="2">Feb</option>\n<option value="3">Mar</option>\n<option value="4">Apr</option>\n<option value="5">May</option>\n<option value="6">Jun</option>\n<option value="7">Jul</option>\n<option value="8" selected="selected">Aug</option>\n<option value="9">Sep</option>\n<option value="10">Oct</option>\n<option value="11">Nov</option>\n<option value="12">Dec</option>\n)
154
+ expected << "</select>\n"
155
+
156
+ assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_short_month => true)
157
+ assert_equal expected, select_month(8, :use_short_month => true)
158
+ end
159
+
133
160
  def test_select_year
134
161
  expected = %(<select name="date[year]">\n)
135
162
  expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
@@ -139,6 +166,15 @@ class DateHelperTest < Test::Unit::TestCase
139
166
  assert_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005)
140
167
  end
141
168
 
169
+ def test_select_year_with_disabled
170
+ expected = %(<select name="date[year]" disabled="disabled">\n)
171
+ expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
172
+ expected << "</select>\n"
173
+
174
+ assert_equal expected, select_year(Time.mktime(2003, 8, 16), :disabled => true, :start_year => 2003, :end_year => 2005)
175
+ assert_equal expected, select_year(2003, :disabled => true, :start_year => 2003, :end_year => 2005)
176
+ end
177
+
142
178
  def test_select_year_with_field_name_override
143
179
  expected = %(<select name="date[annee]">\n)
144
180
  expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
@@ -148,7 +184,6 @@ class DateHelperTest < Test::Unit::TestCase
148
184
  assert_equal expected, select_year(2003, :start_year => 2003, :end_year => 2005, :field_name => 'annee')
149
185
  end
150
186
 
151
-
152
187
  def test_select_year_with_type_discarding
153
188
  expected = %(<select name="date_year">\n)
154
189
  expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
@@ -159,7 +194,7 @@ class DateHelperTest < Test::Unit::TestCase
159
194
  assert_equal expected, select_year(
160
195
  2003, :prefix => "date_year", :discard_type => true, :start_year => 2003, :end_year => 2005)
161
196
  end
162
-
197
+
163
198
  def test_select_year_descending
164
199
  expected = %(<select name="date[year]">\n)
165
200
  expected << %(<option value="2005" selected="selected">2005</option>\n<option value="2004">2004</option>\n<option value="2003">2003</option>\n)
@@ -177,6 +212,14 @@ class DateHelperTest < Test::Unit::TestCase
177
212
  assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18))
178
213
  end
179
214
 
215
+ def test_select_hour_with_disabled
216
+ expected = %(<select name="date[hour]" disabled="disabled">\n)
217
+ 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)
218
+ expected << "</select>\n"
219
+
220
+ assert_equal expected, select_hour(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
221
+ end
222
+
180
223
  def test_select_hour_with_field_name_override
181
224
  expected = %(<select name="date[heure]">\n)
182
225
  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)
@@ -209,6 +252,14 @@ class DateHelperTest < Test::Unit::TestCase
209
252
  assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18))
210
253
  end
211
254
 
255
+ def test_select_minute_with_disabled
256
+ expected = %(<select name="date[minute]" disabled="disabled">\n)
257
+ 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)
258
+ expected << "</select>\n"
259
+
260
+ assert_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
261
+ end
262
+
212
263
  def test_select_minute_with_field_name_override
213
264
  expected = %(<select name="date[minuto]">\n)
214
265
  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)
@@ -257,6 +308,14 @@ class DateHelperTest < Test::Unit::TestCase
257
308
  assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18))
258
309
  end
259
310
 
311
+ def test_select_second_with_disabled
312
+ expected = %(<select name="date[second]" disabled="disabled">\n)
313
+ 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)
314
+ expected << "</select>\n"
315
+
316
+ assert_equal expected, select_second(Time.mktime(2003, 8, 16, 8, 4, 18), :disabled => true)
317
+ end
318
+
260
319
  def test_select_second_with_field_name_override
261
320
  expected = %(<select name="date[segundo]">\n)
262
321
  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)
@@ -299,6 +358,23 @@ class DateHelperTest < Test::Unit::TestCase
299
358
  Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]"
300
359
  )
301
360
  end
361
+
362
+ def test_select_date_with_disabled
363
+ expected = %(<select name="date[first][year]" disabled="disabled">\n)
364
+ expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
365
+ expected << "</select>\n"
366
+
367
+ expected << %(<select name="date[first][month]" disabled="disabled">\n)
368
+ 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)
369
+ expected << "</select>\n"
370
+
371
+ expected << %(<select name="date[first][day]" disabled="disabled">\n)
372
+ expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16" selected="selected">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
373
+ expected << "</select>\n"
374
+
375
+ assert_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :disabled => true)
376
+ end
377
+
302
378
 
303
379
  def test_select_date_with_no_start_year
304
380
  expected = %(<select name="date[first][year]">\n)