actionpack 1.7.0 → 1.8.0

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 (65) hide show
  1. data/CHANGELOG +109 -0
  2. data/README +2 -2
  3. data/RUNNING_UNIT_TESTS +1 -1
  4. data/install.rb +8 -77
  5. data/lib/action_controller/assertions.rb +203 -0
  6. data/lib/action_controller/base.rb +15 -7
  7. data/lib/action_controller/benchmarking.rb +10 -4
  8. data/lib/action_controller/caching.rb +28 -17
  9. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +5 -9
  10. data/lib/action_controller/cgi_process.rb +5 -1
  11. data/lib/action_controller/cookies.rb +3 -2
  12. data/lib/action_controller/deprecated_assertions.rb +204 -0
  13. data/lib/action_controller/flash.rb +30 -36
  14. data/lib/action_controller/pagination.rb +4 -4
  15. data/lib/action_controller/request.rb +18 -2
  16. data/lib/action_controller/routing.rb +6 -2
  17. data/lib/action_controller/scaffolding.rb +1 -1
  18. data/lib/action_controller/templates/rescues/diagnostics.rhtml +1 -1
  19. data/lib/action_controller/templates/rescues/routing_error.rhtml +4 -2
  20. data/lib/action_controller/templates/rescues/template_error.rhtml +5 -4
  21. data/lib/action_controller/templates/scaffolds/list.rhtml +3 -0
  22. data/lib/action_controller/test_process.rb +60 -17
  23. data/lib/action_controller/url_rewriter.rb +3 -3
  24. data/lib/action_controller/vendor/html-scanner/html/document.rb +63 -0
  25. data/lib/action_controller/vendor/html-scanner/html/node.rb +431 -0
  26. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +95 -0
  27. data/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
  28. data/lib/action_controller/verification.rb +13 -4
  29. data/lib/action_view/base.rb +3 -2
  30. data/lib/action_view/helpers/active_record_helper.rb +1 -1
  31. data/lib/action_view/helpers/asset_tag_helper.rb +31 -9
  32. data/lib/action_view/helpers/date_helper.rb +25 -22
  33. data/lib/action_view/helpers/form_helper.rb +6 -5
  34. data/lib/action_view/helpers/form_options_helper.rb +4 -4
  35. data/lib/action_view/helpers/javascript_helper.rb +28 -6
  36. data/lib/action_view/helpers/javascripts/prototype.js +340 -30
  37. data/lib/action_view/helpers/number_helper.rb +110 -0
  38. data/lib/action_view/helpers/pagination_helper.rb +1 -1
  39. data/lib/action_view/helpers/text_helper.rb +8 -21
  40. data/lib/action_view/helpers/url_helper.rb +21 -4
  41. data/lib/action_view/partials.rb +39 -9
  42. data/rakefile +29 -5
  43. data/test/abstract_unit.rb +1 -0
  44. data/test/controller/action_pack_assertions_test.rb +1 -2
  45. data/test/controller/active_record_assertions_test.rb +1 -1
  46. data/test/controller/cgi_test.rb +0 -1
  47. data/test/controller/cookie_test.rb +11 -1
  48. data/test/controller/helper_test.rb +0 -12
  49. data/test/controller/render_test.rb +9 -0
  50. data/test/controller/request_test.rb +44 -1
  51. data/test/controller/routing_tests.rb +4 -1
  52. data/test/controller/test_test.rb +62 -0
  53. data/test/controller/verification_test.rb +21 -0
  54. data/test/fixtures/test/_partial_only.rhtml +1 -0
  55. data/test/template/active_record_helper_test.rb +2 -2
  56. data/test/template/asset_tag_helper_test.rb +52 -4
  57. data/test/template/date_helper_test.rb +163 -32
  58. data/test/template/form_helper_test.rb +9 -6
  59. data/test/template/form_options_helper_test.rb +18 -15
  60. data/test/template/number_helper_test.rb +51 -0
  61. data/test/template/text_helper_test.rb +17 -20
  62. data/test/template/url_helper_test.rb +7 -1
  63. metadata +15 -6
  64. data/lib/action_controller/assertions/action_pack_assertions.rb +0 -260
  65. data/lib/action_controller/assertions/active_record_assertions.rb +0 -65
@@ -1,6 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'erb'
3
3
  require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper'
4
+ require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/hash' #for stringify keys
4
5
 
5
6
  class FormHelperTest < Test::Unit::TestCase
6
7
  include ActionView::Helpers::FormHelper
@@ -64,13 +65,15 @@ class FormHelperTest < Test::Unit::TestCase
64
65
  '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
65
66
  check_box("post", "secret")
66
67
  )
67
-
68
68
  @post.secret = 0
69
69
  assert_equal(
70
70
  '<input id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
71
71
  check_box("post", "secret")
72
72
  )
73
-
73
+ assert_equal(
74
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
75
+ check_box("post", "secret" ,{"checked"=>"checked"})
76
+ )
74
77
  @post.secret = true
75
78
  assert_equal(
76
79
  '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
@@ -79,10 +82,10 @@ class FormHelperTest < Test::Unit::TestCase
79
82
  end
80
83
 
81
84
  def test_radio_button
82
- assert_equal('<input checked="checked" id="post_title" name="post[title]" size="30" type="radio" value="Hello World" />',
85
+ assert_equal('<input checked="checked" id="post_title" name="post[title]" type="radio" value="Hello World" />',
83
86
  radio_button("post", "title", "Hello World")
84
87
  )
85
- assert_equal('<input id="post_title" name="post[title]" size="30" type="radio" value="Goodbye World" />',
88
+ assert_equal('<input id="post_title" name="post[title]" type="radio" value="Goodbye World" />',
86
89
  radio_button("post", "title", "Goodbye World")
87
90
  )
88
91
  end
@@ -163,10 +166,10 @@ class FormHelperTest < Test::Unit::TestCase
163
166
  check_box("post[]", "secret")
164
167
  )
165
168
  assert_equal(
166
- "<input checked=\"checked\" id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"radio\" value=\"Hello World\" />",
169
+ "<input checked=\"checked\" id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />",
167
170
  radio_button("post[]", "title", "Hello World")
168
171
  )
169
- assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" size=\"30\" type=\"radio\" value=\"Goodbye World\" />",
172
+ assert_equal("<input id=\"post_#{pid}_title\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Goodbye World\" />",
170
173
  radio_button("post[]", "title", "Goodbye World")
171
174
  )
172
175
  end
@@ -75,32 +75,32 @@ class FormOptionsHelperTest < Test::Unit::TestCase
75
75
 
76
76
  def test_array_options_for_select
77
77
  assert_equal(
78
- "<option>&lt;Denmark&gt;</option>\n<option>USA</option>\n<option>Sweden</option>",
78
+ "<option value=\"&lt;Denmark&gt;\">&lt;Denmark&gt;</option>\n<option value=\"USA\">USA</option>\n<option value=\"Sweden\">Sweden</option>",
79
79
  options_for_select([ "<Denmark>", "USA", "Sweden" ])
80
80
  )
81
81
  end
82
82
 
83
83
  def test_array_options_for_select_with_selection
84
84
  assert_equal(
85
- "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option>Sweden</option>",
85
+ "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\">Sweden</option>",
86
86
  options_for_select([ "Denmark", "<USA>", "Sweden" ], "<USA>")
87
87
  )
88
88
  end
89
89
 
90
90
  def test_array_options_for_select_with_selection_array
91
91
  assert_equal(
92
- "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option selected=\"selected\">Sweden</option>",
92
+ "<option value=\"Denmark\">Denmark</option>\n<option value=\"&lt;USA&gt;\" selected=\"selected\">&lt;USA&gt;</option>\n<option value=\"Sweden\" selected=\"selected\">Sweden</option>",
93
93
  options_for_select([ "Denmark", "<USA>", "Sweden" ], [ "<USA>", "Sweden" ])
94
94
  )
95
95
  end
96
96
 
97
97
  def test_array_options_for_string_include_in_other_string_bug_fix
98
98
  assert_equal(
99
- "<option>ruby</option>\n<option selected=\"selected\">rubyonrails</option>",
99
+ "<option value=\"ruby\">ruby</option>\n<option value=\"rubyonrails\" selected=\"selected\">rubyonrails</option>",
100
100
  options_for_select([ "ruby", "rubyonrails" ], "rubyonrails")
101
101
  )
102
102
  assert_equal(
103
- "<option selected=\"selected\">ruby</option>\n<option>rubyonrails</option>",
103
+ "<option value=\"ruby\" selected=\"selected\">ruby</option>\n<option value=\"rubyonrails\">rubyonrails</option>",
104
104
  options_for_select([ "ruby", "rubyonrails" ], "ruby")
105
105
  )
106
106
  end
@@ -173,7 +173,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
173
173
  opts = time_zone_options_for_select( nil, zones )
174
174
  assert_equal "<option value=\"B\">B</option>\n" +
175
175
  "<option value=\"E\">E</option>" +
176
- "<option>-------------</option>\n" +
176
+ "<option value=\"\">-------------</option>\n" +
177
177
  "<option value=\"A\">A</option>\n" +
178
178
  "<option value=\"C\">C</option>\n" +
179
179
  "<option value=\"D\">D</option>",
@@ -185,7 +185,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
185
185
  opts = time_zone_options_for_select( "E", zones )
186
186
  assert_equal "<option value=\"B\">B</option>\n" +
187
187
  "<option value=\"E\" selected=\"selected\">E</option>" +
188
- "<option>-------------</option>\n" +
188
+ "<option value=\"\">-------------</option>\n" +
189
189
  "<option value=\"A\">A</option>\n" +
190
190
  "<option value=\"C\">C</option>\n" +
191
191
  "<option value=\"D\">D</option>",
@@ -197,7 +197,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
197
197
  opts = time_zone_options_for_select( "C", zones )
198
198
  assert_equal "<option value=\"B\">B</option>\n" +
199
199
  "<option value=\"E\">E</option>" +
200
- "<option>-------------</option>\n" +
200
+ "<option value=\"\">-------------</option>\n" +
201
201
  "<option value=\"A\">A</option>\n" +
202
202
  "<option value=\"C\" selected=\"selected\">C</option>\n" +
203
203
  "<option value=\"D\">D</option>",
@@ -208,7 +208,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
208
208
  @post = Post.new
209
209
  @post.category = "<mus>"
210
210
  assert_equal(
211
- "<select id=\"post_category\" name=\"post[category]\"><option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
211
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>",
212
212
  select("post", "category", %w( abe <mus> hest))
213
213
  )
214
214
  end
@@ -217,7 +217,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
217
217
  @post = Post.new
218
218
  @post.category = "<mus>"
219
219
  assert_equal(
220
- "<select id=\"post_category\" name=\"post[category]\"><option></option>\n<option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
220
+ "<select id=\"post_category\" name=\"post[category]\"><option value=\"\"></option>\n<option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>",
221
221
  select("post", "category", %w( abe <mus> hest), :include_blank => true)
222
222
  )
223
223
  end
@@ -249,7 +249,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
249
249
  @post.author_name = "Babe"
250
250
 
251
251
  assert_equal(
252
- "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
252
+ "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option value=\"\"></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
253
253
  collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true }, "style" => "width: 200px")
254
254
  )
255
255
  end
@@ -258,7 +258,10 @@ class FormOptionsHelperTest < Test::Unit::TestCase
258
258
  @post = Post.new
259
259
  @post.origin = "Denmark"
260
260
  assert_equal(
261
- "<select id=\"post_origin\" name=\"post[origin]\"><option>Afghanistan</option>\n<option>Albania</option>\n<option>Algeria</option>\n<option>American Samoa</option>\n<option>Andorra</option>\n<option>Angola</option>\n<option>Anguilla</option>\n<option>Antarctica</option>\n<option>Antigua And Barbuda</option>\n<option>Argentina</option>\n<option>Armenia</option>\n<option>Aruba</option>\n<option>Australia</option>\n<option>Austria</option>\n<option>Azerbaijan</option>\n<option>Bahamas</option>\n<option>Bahrain</option>\n<option>Bangladesh</option>\n<option>Barbados</option>\n<option>Belarus</option>\n<option>Belgium</option>\n<option>Belize</option>\n<option>Benin</option>\n<option>Bermuda</option>\n<option>Bhutan</option>\n<option>Bolivia</option>\n<option>Bosnia and Herzegowina</option>\n<option>Botswana</option>\n<option>Bouvet Island</option>\n<option>Brazil</option>\n<option>British Indian Ocean Territory</option>\n<option>Brunei Darussalam</option>\n<option>Bulgaria</option>\n<option>Burkina Faso</option>\n<option>Burma</option>\n<option>Burundi</option>\n<option>Cambodia</option>\n<option>Cameroon</option>\n<option>Canada</option>\n<option>Cape Verde</option>\n<option>Cayman Islands</option>\n<option>Central African Republic</option>\n<option>Chad</option>\n<option>Chile</option>\n<option>China</option>\n<option>Christmas Island</option>\n<option>Cocos (Keeling) Islands</option>\n<option>Colombia</option>\n<option>Comoros</option>\n<option>Congo</option>\n<option>Congo, the Democratic Republic of the</option>\n<option>Cook Islands</option>\n<option>Costa Rica</option>\n<option>Cote d'Ivoire</option>\n<option>Croatia</option>\n<option>Cyprus</option>\n<option>Czech Republic</option>\n<option selected=\"selected\">Denmark</option>\n<option>Djibouti</option>\n<option>Dominica</option>\n<option>Dominican Republic</option>\n<option>East Timor</option>\n<option>Ecuador</option>\n<option>Egypt</option>\n<option>El Salvador</option>\n<option>England</option>\n<option>Equatorial Guinea</option>\n<option>Eritrea</option>\n<option>Espana</option>\n<option>Estonia</option>\n<option>Ethiopia</option>\n<option>Falkland Islands</option>\n<option>Faroe Islands</option>\n<option>Fiji</option>\n<option>Finland</option>\n<option>France</option>\n<option>French Guiana</option>\n<option>French Polynesia</option>\n<option>French Southern Territories</option>\n<option>Gabon</option>\n<option>Gambia</option>\n<option>Georgia</option>\n<option>Germany</option>\n<option>Ghana</option>\n<option>Gibraltar</option>\n<option>Great Britain</option>\n<option>Greece</option>\n<option>Greenland</option>\n<option>Grenada</option>\n<option>Guadeloupe</option>\n<option>Guam</option>\n<option>Guatemala</option>\n<option>Guinea</option>\n<option>Guinea-Bissau</option>\n<option>Guyana</option>\n<option>Haiti</option>\n<option>Heard and Mc Donald Islands</option>\n<option>Honduras</option>\n<option>Hong Kong</option>\n<option>Hungary</option>\n<option>Iceland</option>\n<option>India</option>\n<option>Indonesia</option>\n<option>Ireland</option>\n<option>Israel</option>\n<option>Italy</option>\n<option>Iran</option>\n<option>Irak</option>\n<option>Jamaica</option>\n<option>Japan</option>\n<option>Jordan</option>\n<option>Kazakhstan</option>\n<option>Kenya</option>\n<option>Kiribati</option>\n<option>Korea, Republic of</option>\n<option>Korea (South)</option>\n<option>Kuwait</option>\n<option>Kyrgyzstan</option>\n<option>Lao People's Democratic Republic</option>\n<option>Latvia</option>\n<option>Lebanon</option>\n<option>Lesotho</option>\n<option>Liberia</option>\n<option>Liechtenstein</option>\n<option>Lithuania</option>\n<option>Luxembourg</option>\n<option>Macau</option>\n<option>Macedonia</option>\n<option>Madagascar</option>\n<option>Malawi</option>\n<option>Malaysia</option>\n<option>Maldives</option>\n<option>Mali</option>\n<option>Malta</option>\n<option>Marshall Islands</option>\n<option>Martinique</option>\n<option>Mauritania</option>\n<option>Mauritius</option>\n<option>Mayotte</option>\n<option>Mexico</option>\n<option>Micronesia, Federated States of</option>\n<option>Moldova, Republic of</option>\n<option>Monaco</option>\n<option>Mongolia</option>\n<option>Montserrat</option>\n<option>Morocco</option>\n<option>Mozambique</option>\n<option>Myanmar</option>\n<option>Namibia</option>\n<option>Nauru</option>\n<option>Nepal</option>\n<option>Netherlands</option>\n<option>Netherlands Antilles</option>\n<option>New Caledonia</option>\n<option>New Zealand</option>\n<option>Nicaragua</option>\n<option>Niger</option>\n<option>Nigeria</option>\n<option>Niue</option>\n<option>Norfolk Island</option>\n<option>Northern Ireland</option>\n<option>Northern Mariana Islands</option>\n<option>Norway</option>\n<option>Oman</option>\n<option>Pakistan</option>\n<option>Palau</option>\n<option>Panama</option>\n<option>Papua New Guinea</option>\n<option>Paraguay</option>\n<option>Peru</option>\n<option>Philippines</option>\n<option>Pitcairn</option>\n<option>Poland</option>\n<option>Portugal</option>\n<option>Puerto Rico</option>\n<option>Qatar</option>\n<option>Reunion</option>\n<option>Romania</option>\n<option>Russia</option>\n<option>Rwanda</option>\n<option>Saint Kitts and Nevis</option>\n<option>Saint Lucia</option>\n<option>Saint Vincent and the Grenadines</option>\n<option>Samoa (Independent)</option>\n<option>San Marino</option>\n<option>Sao Tome and Principe</option>\n<option>Saudi Arabia</option>\n<option>Scotland</option>\n<option>Senegal</option>\n<option>Seychelles</option>\n<option>Sierra Leone</option>\n<option>Singapore</option>\n<option>Slovakia</option>\n<option>Slovenia</option>\n<option>Solomon Islands</option>\n<option>Somalia</option>\n<option>South Africa</option>\n<option>South Georgia and the South Sandwich Islands</option>\n<option>South Korea</option>\n<option>Spain</option>\n<option>Sri Lanka</option>\n<option>St. Helena</option>\n<option>St. Pierre and Miquelon</option>\n<option>Suriname</option>\n<option>Svalbard and Jan Mayen Islands</option>\n<option>Swaziland</option>\n<option>Sweden</option>\n<option>Switzerland</option>\n<option>Taiwan</option>\n<option>Tajikistan</option>\n<option>Tanzania</option>\n<option>Thailand</option>\n<option>Togo</option>\n<option>Tokelau</option>\n<option>Tonga</option>\n<option>Trinidad</option>\n<option>Trinidad and Tobago</option>\n<option>Tunisia</option>\n<option>Turkey</option>\n<option>Turkmenistan</option>\n<option>Turks and Caicos Islands</option>\n<option>Tuvalu</option>\n<option>Uganda</option>\n<option>Ukraine</option>\n<option>United Arab Emirates</option>\n<option>United Kingdom</option>\n<option>United States</option>\n<option>United States Minor Outlying Islands</option>\n<option>Uruguay</option>\n<option>Uzbekistan</option>\n<option>Vanuatu</option>\n<option>Vatican City State (Holy See)</option>\n<option>Venezuela</option>\n<option>Viet Nam</option>\n<option>Virgin Islands (British)</option>\n<option>Virgin Islands (U.S.)</option>\n<option>Wales</option>\n<option>Wallis and Futuna Islands</option>\n<option>Western Sahara</option>\n<option>Yemen</option>\n<option>Zambia</option>\n<option>Zimbabwe</option></select>",
261
+ "<select id=\"post_origin\" name=\"post[origin]\"><option value=\"Afghanistan\">Afghanistan</option>\n<option value=\"Albania\">Albania</option>\n<option value=\"Algeria\">Algeria</option>\n<option value=\"American Samoa\">American Samoa</option>\n<option value=\"Andorra\">Andorra</option>\n<option value=\"Angola\">Angola</option>\n<option value=\"Anguilla\">Anguilla</option>\n<option value=\"Antarctica\">Antarctica</option>\n<option value=\"Antigua And Barbuda\">Antigua And Barbuda</option>\n<option value=\"Argentina\">Argentina</option>\n<option value=\"Armenia\">Armenia</option>\n<option value=\"Aruba\">Aruba</option>\n<option value=\"Australia\">Australia</option>\n<option value=\"Austria\">Austria</option>\n<option value=\"Azerbaijan\">Azerbaijan</option>\n<option value=\"Bahamas\">Bahamas</option>\n<option value=\"Bahrain\">Bahrain</option>\n<option value=\"Bangladesh\">Bangladesh</option>\n<option value=\"Barbados\">Barbados</option>\n<option value=\"Belarus\">Belarus</option>\n<option value=\"Belgium\">Belgium</option>\n<option value=\"Belize\">Belize</option>\n<option value=\"Benin\">Benin</option>\n<option value=\"Bermuda\">Bermuda</option>\n<option value=\"Bhutan\">Bhutan</option>\n<option value=\"Bolivia\">Bolivia</option>\n<option value=\"Bosnia and Herzegowina\">Bosnia and Herzegowina</option>\n<option value=\"Botswana\">Botswana</option>\n<option value=\"Bouvet Island\">Bouvet Island</option>\n<option value=\"Brazil\">Brazil</option>\n<option value=\"British Indian Ocean Territory\">British Indian Ocean Territory</option>\n<option value=\"Brunei Darussalam\">Brunei Darussalam</option>\n<option value=\"Bulgaria\">Bulgaria</option>\n<option value=\"Burkina Faso\">Burkina Faso</option>\n<option value=\"Burma\">Burma</option>\n<option value=\"Burundi\">Burundi</option>\n<option value=\"Cambodia\">Cambodia</option>\n<option value=\"Cameroon\">Cameroon</option>\n<option value=\"Canada\">Canada</option>\n<option value=\"Cape Verde\">Cape Verde</option>\n<option value=\"Cayman Islands\">Cayman Islands</option>\n<option value=\"Central African Republic\">Central African Republic</option>\n<option value=\"Chad\">Chad</option>\n<option value=\"Chile\">Chile</option>\n<option value=\"China\">China</option>\n<option value=\"Christmas Island\">Christmas Island</option>\n<option value=\"Cocos (Keeling) Islands\">Cocos (Keeling) Islands</option>\n<option value=\"Colombia\">Colombia</option>\n<option value=\"Comoros\">Comoros</option>\n<option value=\"Congo\">Congo</option>\n<option value=\"Congo, the Democratic Republic of the\">Congo, the Democratic Republic of the</option>\n<option value=\"Cook Islands\">Cook Islands</option>\n<option value=\"Costa Rica\">Costa Rica</option>\n<option value=\"Cote d'Ivoire\">Cote d'Ivoire</option>\n<option value=\"Croatia\">Croatia</option>\n<option value=\"Cyprus\">Cyprus</option>\n<option value=\"Czech Republic\">Czech Republic</option>\n<option value=\"Denmark\" selected=\"selected\">Denmark</option>\n<option value=\"Djibouti\">Djibouti</option>\n<option value=\"Dominica\">Dominica</option>\n<option value=\"Dominican Republic\">Dominican Republic</option>\n<option value=\"East Timor\">East Timor</option>\n<option value=\"Ecuador\">Ecuador</option>\n<option value=\"Egypt\">Egypt</option>\n<option value=\"El Salvador\">El Salvador</option>\n<option value=\"England\">England" +
262
+ "</option>\n<option value=\"Equatorial Guinea\">Equatorial Guinea</option>\n<option value=\"Eritrea\">Eritrea</option>\n<option value=\"Espana\">Espana</option>\n<option value=\"Estonia\">Estonia</option>\n<option value=\"Ethiopia\">Ethiopia</option>\n<option value=\"Falkland Islands\">Falkland Islands</option>\n<option value=\"Faroe Islands\">Faroe Islands</option>\n<option value=\"Fiji\">Fiji</option>\n<option value=\"Finland\">Finland</option>\n<option value=\"France\">France</option>\n<option value=\"French Guiana\">French Guiana</option>\n<option value=\"French Polynesia\">French Polynesia</option>\n<option value=\"French Southern Territories\">French Southern Territories</option>\n<option value=\"Gabon\">Gabon</option>\n<option value=\"Gambia\">Gambia</option>\n<option value=\"Georgia\">Georgia</option>\n<option value=\"Germany\">Germany</option>\n<option value=\"Ghana\">Ghana</option>\n<option value=\"Gibraltar\">Gibraltar</option>\n<option value=\"Great Britain\">Great Britain</option>\n<option value=\"Greece\">Greece</option>\n<option value=\"Greenland\">Greenland</option>\n<option value=\"Grenada\">Grenada</option>\n<option value=\"Guadeloupe\">Guadeloupe</option>\n<option value=\"Guam\">Guam</option>\n<option value=\"Guatemala\">Guatemala</option>\n<option value=\"Guinea\">Guinea</option>\n<option value=\"Guinea-Bissau\">Guinea-Bissau</option>\n<option value=\"Guyana\">Guyana</option>\n<option value=\"Haiti\">Haiti</option>\n<option value=\"Heard and Mc Donald Islands\">Heard and Mc Donald Islands</option>\n<option value=\"Honduras\">Honduras</option>\n<option value=\"Hong Kong\">Hong Kong</option>\n<option value=\"Hungary\">Hungary</option>\n<option value=\"Iceland\">Iceland</option>\n<option value=\"India\">India</option>\n<option value=\"Indonesia\">Indonesia</option>\n<option value=\"Ireland\">Ireland</option>\n<option value=\"Israel\">Israel</option>\n<option value=\"Italy\">Italy</option>\n<option value=\"Iran\">Iran</option>\n<option value=\"Irak\">Irak</option>\n<option value=\"Jamaica\">Jamaica</option>\n<option value=\"Japan\">Japan</option>\n<option value=\"Jordan\">Jordan</option>\n<option value=\"Kazakhstan\">Kazakhstan</option>\n<option value=\"Kenya\">Kenya</option>\n<option value=\"Kiribati\">Kiribati</option>\n<option value=\"Korea, Republic of\">Korea, Republic of</option>\n<option value=\"Korea (South)\">Korea (South)</option>\n<option value=\"Kuwait\">Kuwait</option>\n<option value=\"Kyrgyzstan\">Kyrgyzstan</option>\n<option value=\"Lao People's Democratic Republic\">Lao People's Democratic Republic</option>\n<option value=\"Latvia\">Latvia</option>\n<option value=\"Lebanon\">Lebanon</option>\n<option value=\"Lesotho\">Lesotho</option>\n<option value=\"Liberia\">Liberia</option>\n<option value=\"Liechtenstein\">Liechtenstein</option>\n<option value=\"Lithuania\">Lithuania</option>\n<option value=\"Luxembourg\">Luxembourg</option>\n<option value=\"Macau\">Macau</option>\n<option value=\"Macedonia\">Macedonia</option>\n<option value=\"Madagascar\">Madagascar</option>\n<option value=\"Malawi\">Malawi</option>\n<option value=\"Malaysia\">Malaysia</option>\n<option value=\"Maldives\">Maldives</option>\n<option value=\"Mali\">Mali</option>\n<option value=\"Malta\">Malta</option>\n<option value=\"Marshall Islands\">Marshall Islands</option>\n<option value=\"Martinique\">Martinique</option>\n<option value=\"Mauritania\">Mauritania</option>\n<option value=\"Mauritius\">Mauritius</option>\n<option value=\"Mayotte\">Mayotte</option>\n<option value=\"Mexico\">Mexico</option>\n<option value=\"Micronesia, Federated States of\">Micronesia, Federated States of</option>\n<option value=\"Moldova, Republic of\">Moldova, Republic of</option>\n<option value=\"Monaco\">Monaco</option>\n<option value=\"Mongolia\">Mongolia</option>\n<option value=\"Montserrat\">Montserrat</option>\n<option value=\"Morocco\">Morocco</option>\n<option value=\"Mozambique\">Mozambique</option>\n<option value=\"Myanmar\">Myanmar</option>\n<option value=\"Namibia\">Namibia</option>\n<option value=\"Nauru\">Nauru</option>\n<option value=\"Nepal\">Nepal</option>\n<option value=\"Netherlands\">Netherlands</option>\n<option value=\"Netherlands Antilles\">Netherlands Antilles</option>\n<option value=\"New Caledonia\">New Caledonia</option>" +
263
+ "\n<option value=\"New Zealand\">New Zealand</option>\n<option value=\"Nicaragua\">Nicaragua</option>\n<option value=\"Niger\">Niger</option>\n<option value=\"Nigeria\">Nigeria</option>\n<option value=\"Niue\">Niue</option>\n<option value=\"Norfolk Island\">Norfolk Island</option>\n<option value=\"Northern Ireland\">Northern Ireland</option>\n<option value=\"Northern Mariana Islands\">Northern Mariana Islands</option>\n<option value=\"Norway\">Norway</option>\n<option value=\"Oman\">Oman</option>\n<option value=\"Pakistan\">Pakistan</option>\n<option value=\"Palau\">Palau</option>\n<option value=\"Panama\">Panama</option>\n<option value=\"Papua New Guinea\">Papua New Guinea</option>\n<option value=\"Paraguay\">Paraguay</option>\n<option value=\"Peru\">Peru</option>\n<option value=\"Philippines\">Philippines</option>\n<option value=\"Pitcairn\">Pitcairn</option>\n<option value=\"Poland\">Poland</option>\n<option value=\"Portugal\">Portugal</option>\n<option value=\"Puerto Rico\">Puerto Rico</option>\n<option value=\"Qatar\">Qatar</option>\n<option value=\"Reunion\">Reunion</option>\n<option value=\"Romania\">Romania</option>\n<option value=\"Russia\">Russia</option>\n<option value=\"Rwanda\">Rwanda</option>\n<option value=\"Saint Kitts and Nevis\">Saint Kitts and Nevis</option>\n<option value=\"Saint Lucia\">Saint Lucia</option>\n<option value=\"Saint Vincent and the Grenadines\">Saint Vincent and the Grenadines</option>\n<option value=\"Samoa (Independent)\">Samoa (Independent)</option>\n<option value=\"San Marino\">San Marino</option>\n<option value=\"Sao Tome and Principe\">Sao Tome and Principe</option>\n<option value=\"Saudi Arabia\">Saudi Arabia</option>\n<option value=\"Scotland\">Scotland</option>\n<option value=\"Senegal\">Senegal</option>\n<option value=\"Seychelles\">Seychelles</option>\n<option value=\"Sierra Leone\">Sierra Leone</option>\n<option value=\"Singapore\">Singapore</option>\n<option value=\"Slovakia\">Slovakia</option>\n<option value=\"Slovenia\">Slovenia</option>\n<option value=\"Solomon Islands\">Solomon Islands</option>\n<option value=\"Somalia\">Somalia</option>\n<option value=\"South Africa\">South Africa</option>\n<option value=\"South Georgia and the South Sandwich Islands\">South Georgia and the South Sandwich Islands</option>\n<option value=\"South Korea\">South Korea</option>\n<option value=\"Spain\">Spain</option>\n<option value=\"Sri Lanka\">Sri Lanka</option>\n<option value=\"St. Helena\">St. Helena</option>\n<option value=\"St. Pierre and Miquelon\">St. Pierre and Miquelon</option>\n<option value=\"Suriname\">Suriname</option>\n<option value=\"Svalbard and Jan Mayen Islands\">Svalbard and Jan Mayen Islands</option>\n<option value=\"Swaziland\">Swaziland</option>\n<option value=\"Sweden\">Sweden</option>\n<option value=\"Switzerland\">Switzerland</option>\n<option value=\"Taiwan\">Taiwan</option>\n<option value=\"Tajikistan\">Tajikistan</option>\n<option value=\"Tanzania\">Tanzania</option>\n<option value=\"Thailand\">Thailand</option>\n<option value=\"Togo\">Togo</option>\n<option value=\"Tokelau\">Tokelau</option>\n<option value=\"Tonga\">Tonga</option>\n<option value=\"Trinidad\">Trinidad</option>\n<option value=\"Trinidad and Tobago\">Trinidad and Tobago</option>\n<option value=\"Tunisia\">Tunisia</option>\n<option value=\"Turkey\">Turkey</option>\n<option value=\"Turkmenistan\">" +
264
+ "Turkmenistan</option>\n<option value=\"Turks and Caicos Islands\">Turks and Caicos Islands</option>\n<option value=\"Tuvalu\">Tuvalu</option>\n<option value=\"Uganda\">Uganda</option>\n<option value=\"Ukraine\">Ukraine</option>\n<option value=\"United Arab Emirates\">United Arab Emirates</option>\n<option value=\"United Kingdom\">United Kingdom</option>\n<option value=\"United States\">United States</option>\n<option value=\"United States Minor Outlying Islands\">United States Minor Outlying Islands</option>\n<option value=\"Uruguay\">Uruguay</option>\n<option value=\"Uzbekistan\">Uzbekistan</option>\n<option value=\"Vanuatu\">Vanuatu</option>\n<option value=\"Vatican City State (Holy See)\">Vatican City State (Holy See)</option>\n<option value=\"Venezuela\">Venezuela</option>\n<option value=\"Viet Nam\">Viet Nam</option>\n<option value=\"Virgin Islands (British)\">Virgin Islands (British)</option>\n<option value=\"Virgin Islands (U.S.)\">Virgin Islands (U.S.)</option>\n<option value=\"Wales\">Wales</option>\n<option value=\"Wallis and Futuna Islands\">Wallis and Futuna Islands</option>\n<option value=\"Western Sahara\">Western Sahara</option>\n<option value=\"Yemen\">Yemen</option>\n<option value=\"Zambia\">Zambia</option>\n<option value=\"Zimbabwe\">Zimbabwe</option></select>",
262
265
  country_select("post", "origin")
263
266
  )
264
267
  end
@@ -280,7 +283,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
280
283
  @firm = Firm.new("D")
281
284
  html = time_zone_select("firm", "time_zone", nil, :include_blank => true)
282
285
  assert_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" +
283
- "<option></option>\n" +
286
+ "<option value=\"\"></option>\n" +
284
287
  "<option value=\"A\">A</option>\n" +
285
288
  "<option value=\"B\">B</option>\n" +
286
289
  "<option value=\"C\">C</option>\n" +
@@ -311,7 +314,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
311
314
  html = time_zone_select("firm", "time_zone", nil,
312
315
  { :include_blank => true }, "style" => "color: red")
313
316
  assert_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\" style=\"color: red\">" +
314
- "<option></option>\n" +
317
+ "<option value=\"\"></option>\n" +
315
318
  "<option value=\"A\">A</option>\n" +
316
319
  "<option value=\"B\">B</option>\n" +
317
320
  "<option value=\"C\">C</option>\n" +
@@ -330,7 +333,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
330
333
  assert_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" +
331
334
  "<option value=\"A\">A</option>\n" +
332
335
  "<option value=\"D\" selected=\"selected\">D</option>" +
333
- "<option>-------------</option>\n" +
336
+ "<option value=\"\">-------------</option>\n" +
334
337
  "<option value=\"B\">B</option>\n" +
335
338
  "<option value=\"C\">C</option>\n" +
336
339
  "<option value=\"E\">E</option>" +
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/number_helper'
3
+ require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/hash' # for stringify_keys
4
+ require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/numeric' # for human_size
5
+
6
+ class NumberHelperTest < Test::Unit::TestCase
7
+ include ActionView::Helpers::NumberHelper
8
+ include ActiveSupport::CoreExtensions::Hash
9
+
10
+ def test_number_to_phone
11
+ assert_equal("123-555-1234", number_to_phone(1235551234))
12
+ assert_equal("(123) 555-1234", number_to_phone(1235551234, {:area_code => true}))
13
+ assert_equal("123 555 1234", number_to_phone(1235551234, {:delimiter => " "}))
14
+ end
15
+
16
+ def test_number_to_currency
17
+ assert_equal("$1,234,567,890.50", number_to_currency(1234567890.50))
18
+ assert_equal("$1,234,567,890.51", number_to_currency(1234567890.506))
19
+ assert_equal("&pound;1234567890,50", number_to_currency(1234567890.50, {:unit => "&pound;", :separator => ",", :delimiter => ""}))
20
+ end
21
+
22
+ def test_number_to_percentage
23
+ assert_equal("100.000%", number_to_percentage(100))
24
+ assert_equal("100%", number_to_percentage(100, {:precision => 0}))
25
+ assert_equal("302.06%", number_to_percentage(302.0574, {:precision => 2}))
26
+ end
27
+
28
+ def test_number_with_delimiter
29
+ assert_equal("12,345,678", number_with_delimiter(12345678))
30
+ end
31
+
32
+ def test_number_to_human_size
33
+ assert_equal("0 Bytes", number_to_human_size(0))
34
+ assert_equal("3 Bytes", number_to_human_size(3.14159265))
35
+ assert_equal("123 Bytes", number_to_human_size(123.0))
36
+ assert_equal("123 Bytes", number_to_human_size(123))
37
+ assert_equal("1.2 KB", number_to_human_size(1234))
38
+ assert_equal("12.1 KB", number_to_human_size(12345))
39
+ assert_equal("1.2 MB", number_to_human_size(1234567))
40
+ assert_equal("1.1 GB", number_to_human_size(1234567890))
41
+ assert_equal("1.1 TB", number_to_human_size(1234567890123))
42
+ assert_equal("444.0 KB", number_to_human_size(444.kilobytes))
43
+ assert_equal("1023.0 MB", number_to_human_size(1023.megabytes))
44
+ assert_equal("3.0 TB", number_to_human_size(3.terabytes))
45
+ assert_nil number_to_human_size('x')
46
+ end
47
+
48
+ def test_number_with_precision
49
+ assert_equal("111.235", number_with_precision(111.2346))
50
+ end
51
+ end
@@ -53,22 +53,6 @@ class TextHelperTest < Test::Unit::TestCase
53
53
  highlight("This is a beautiful? morning", "beautiful? morning")
54
54
  )
55
55
  end
56
-
57
- def test_human_size
58
- assert_equal("0 Bytes", human_size(0))
59
- assert_equal("3 Bytes", human_size(3.14159265))
60
- assert_equal("123 Bytes", human_size(123.0))
61
- assert_equal("123 Bytes", human_size(123))
62
- assert_equal("1.2 KB", human_size(1234))
63
- assert_equal("12.1 KB", human_size(12345))
64
- assert_equal("1.2 MB", human_size(1234567))
65
- assert_equal("1.1 GB", human_size(1234567890))
66
- assert_equal("1.1 TB", human_size(1234567890123))
67
- assert_equal("444.0 KB", human_size(444.kilobytes))
68
- assert_equal("1023.0 MB", human_size(1023.megabytes))
69
- assert_equal("3.0 TB", human_size(3.terabytes))
70
- assert_nil human_size('x')
71
- end
72
56
 
73
57
  def test_excerpt
74
58
  assert_equal("...is a beautiful morni...", excerpt("This is a beautiful morning", "beautiful", 5))
@@ -84,10 +68,23 @@ class TextHelperTest < Test::Unit::TestCase
84
68
  end
85
69
 
86
70
  def test_auto_linking
87
- assert_equal %(hello <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>), auto_link("hello david@loudthinking.com", :email_addresses)
88
- assert_equal %(Go to <a href="http://www.rubyonrails.com">http://www.rubyonrails.com</a>), auto_link("Go to http://www.rubyonrails.com", :urls)
89
- assert_equal %(Go to http://www.rubyonrails.com), auto_link("Go to http://www.rubyonrails.com", :email_addresses)
90
- assert_equal %(Go to <a href="http://www.rubyonrails.com">http://www.rubyonrails.com</a> and say hello to <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>), auto_link("Go to http://www.rubyonrails.com and say hello to david@loudthinking.com")
71
+ email_raw = 'david@loudthinking.com'
72
+ email_result = %{<a href="mailto:#{email_raw}">#{email_raw}</a>}
73
+ link_raw = 'http://www.rubyonrails.com'
74
+ link_result = %{<a href="#{link_raw}">#{link_raw}</a>}
75
+ link2_raw = 'www.rubyonrails.com'
76
+ link2_result = %{<a href="http://#{link2_raw}">#{link2_raw}</a>}
77
+
78
+ assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses)
79
+ assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls)
80
+ assert_equal %(Go to #{link_raw}), auto_link("Go to #{link_raw}", :email_addresses)
81
+ assert_equal %(Go to #{link_result} and say hello to #{email_result}), auto_link("Go to #{link_raw} and say hello to #{email_raw}")
82
+ assert_equal %(<p>Link #{link_result}</p>), auto_link("<p>Link #{link_raw}</p>")
83
+ assert_equal %(<p>#{link_result} Link</p>), auto_link("<p>#{link_raw} Link</p>")
84
+ assert_equal %(Go to #{link2_result}), auto_link("Go to #{link2_raw}", :urls)
85
+ assert_equal %(Go to #{link2_raw}), auto_link("Go to #{link2_raw}", :email_addresses)
86
+ assert_equal %(<p>Link #{link2_result}</p>), auto_link("<p>Link #{link2_raw}</p>")
87
+ assert_equal %(<p>#{link2_result} Link</p>), auto_link("<p>#{link2_raw} Link</p>")
91
88
  end
92
89
 
93
90
  end
@@ -79,10 +79,16 @@ class UrlHelperTest < Test::Unit::TestCase
79
79
  mail_to("david@loudthinking.com", "David Heinemeier Hansson", :class => "admin")
80
80
  end
81
81
 
82
-
83
82
  def test_mail_to_with_javascript
84
83
  assert_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript")
85
84
  end
85
+
86
+ def test_mail_with_options
87
+ assert_equal(
88
+ %(<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>),
89
+ mail_to("me@example.com", "My email", :cc => "ccaddress@example.com", :bcc => "bccaddress@example.com", :subject => "This is an example email", :body => "This is the body of the message.")
90
+ )
91
+ end
86
92
 
87
93
  def test_mail_to_with_hex
88
94
  assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex")
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.8
3
3
  specification_version: 1
4
4
  name: actionpack
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.7.0
7
- date: 2005-03-27
6
+ version: 1.8.0
7
+ date: 2005-04-19
8
8
  summary: Web-flow and rendering framework putting the VC in MVC.
9
9
  require_paths:
10
10
  - lib
@@ -40,7 +40,7 @@ files:
40
40
  - lib/action_controller.rb
41
41
  - lib/action_view
42
42
  - lib/action_view.rb
43
- - lib/action_controller/assertions
43
+ - lib/action_controller/assertions.rb
44
44
  - lib/action_controller/base.rb
45
45
  - lib/action_controller/benchmarking.rb
46
46
  - lib/action_controller/caching.rb
@@ -49,6 +49,7 @@ files:
49
49
  - lib/action_controller/components.rb
50
50
  - lib/action_controller/cookies.rb
51
51
  - lib/action_controller/dependencies.rb
52
+ - lib/action_controller/deprecated_assertions.rb
52
53
  - lib/action_controller/filters.rb
53
54
  - lib/action_controller/flash.rb
54
55
  - lib/action_controller/helpers.rb
@@ -64,9 +65,8 @@ files:
64
65
  - lib/action_controller/templates
65
66
  - lib/action_controller/test_process.rb
66
67
  - lib/action_controller/url_rewriter.rb
68
+ - lib/action_controller/vendor
67
69
  - lib/action_controller/verification.rb
68
- - lib/action_controller/assertions/action_pack_assertions.rb
69
- - lib/action_controller/assertions/active_record_assertions.rb
70
70
  - lib/action_controller/cgi_ext/cgi_ext.rb
71
71
  - lib/action_controller/cgi_ext/cgi_methods.rb
72
72
  - lib/action_controller/cgi_ext/cookie_performance_fix.rb
@@ -89,6 +89,12 @@ files:
89
89
  - lib/action_controller/templates/scaffolds/list.rhtml
90
90
  - lib/action_controller/templates/scaffolds/new.rhtml
91
91
  - lib/action_controller/templates/scaffolds/show.rhtml
92
+ - lib/action_controller/vendor/html-scanner
93
+ - lib/action_controller/vendor/html-scanner/html
94
+ - lib/action_controller/vendor/html-scanner/html/document.rb
95
+ - lib/action_controller/vendor/html-scanner/html/node.rb
96
+ - lib/action_controller/vendor/html-scanner/html/tokenizer.rb
97
+ - lib/action_controller/vendor/html-scanner/html/version.rb
92
98
  - lib/action_view/base.rb
93
99
  - lib/action_view/helpers
94
100
  - lib/action_view/partials.rb
@@ -105,6 +111,7 @@ files:
105
111
  - lib/action_view/helpers/form_tag_helper.rb
106
112
  - lib/action_view/helpers/javascript_helper.rb
107
113
  - lib/action_view/helpers/javascripts
114
+ - lib/action_view/helpers/number_helper.rb
108
115
  - lib/action_view/helpers/pagination_helper.rb
109
116
  - lib/action_view/helpers/tag_helper.rb
110
117
  - lib/action_view/helpers/text_helper.rb
@@ -154,6 +161,7 @@ files:
154
161
  - test/fixtures/scope/test
155
162
  - test/fixtures/scope/test/modgreet.rhtml
156
163
  - test/fixtures/test/_customer.rhtml
164
+ - test/fixtures/test/_partial_only.rhtml
157
165
  - test/fixtures/test/greeting.rhtml
158
166
  - test/fixtures/test/hello.rxml
159
167
  - test/fixtures/test/hello_world.rhtml
@@ -166,6 +174,7 @@ files:
166
174
  - test/template/form_options_helper_test.rb
167
175
  - test/template/form_tag_helper_test.rb
168
176
  - test/template/javascript_helper.rb
177
+ - test/template/number_helper_test.rb
169
178
  - test/template/tag_helper_test.rb
170
179
  - test/template/text_helper_test.rb
171
180
  - test/template/url_helper_test.rb
@@ -200,5 +209,5 @@ dependencies:
200
209
  -
201
210
  - "="
202
211
  - !ruby/object:Gem::Version
203
- version: 1.0.3
212
+ version: 1.0.4
204
213
  version:
@@ -1,260 +0,0 @@
1
- require 'test/unit'
2
- require 'test/unit/assertions'
3
- require 'rexml/document'
4
-
5
- module Test #:nodoc:
6
- module Unit #:nodoc:
7
- # Adds a wealth of assertions to do functional testing of Action Controllers.
8
- module Assertions
9
- # -- basic assertions ---------------------------------------------------
10
-
11
- # ensure that the web request has been serviced correctly
12
- def assert_success(message=nil)
13
- response = acquire_assertion_target
14
- if response.success?
15
- # to count the assertion
16
- assert_block("") { true }
17
- else
18
- if response.redirect?
19
- msg = build_message(message, "Response unexpectedly redirect to <?>", response.redirect_url)
20
- else
21
- msg = build_message(message, "unsuccessful request (response code = <?>)",
22
- response.response_code)
23
- end
24
- assert_block(msg) { false }
25
- end
26
- end
27
-
28
- # ensure the request was rendered with the appropriate template file
29
- def assert_rendered_file(expected=nil, message=nil)
30
- response = acquire_assertion_target
31
- rendered = expected ? response.rendered_file(!expected.include?('/')) : response.rendered_file
32
- msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
33
- assert_block(msg) do
34
- if expected.nil?
35
- response.rendered_with_file?
36
- else
37
- expected == rendered
38
- end
39
- end
40
- end
41
-
42
- # -- session assertions -------------------------------------------------
43
-
44
- # ensure that the session has an object with the specified name
45
- def assert_session_has(key=nil, message=nil)
46
- response = acquire_assertion_target
47
- msg = build_message(message, "<?> is not in the session <?>", key, response.session)
48
- assert_block(msg) { response.has_session_object?(key) }
49
- end
50
-
51
- # ensure that the session has no object with the specified name
52
- def assert_session_has_no(key=nil, message=nil)
53
- response = acquire_assertion_target
54
- msg = build_message(message, "<?> is in the session <?>", key, response.session)
55
- assert_block(msg) { !response.has_session_object?(key) }
56
- end
57
-
58
- def assert_session_equal(expected = nil, key = nil, message = nil)
59
- response = acquire_assertion_target
60
- msg = build_message(message, "<?> expected in session['?'] but was <?>", expected, key, response.session[key])
61
- assert_block(msg) { expected == response.session[key] }
62
- end
63
-
64
- # -- cookie assertions ---------------------------------------------------
65
-
66
- def assert_cookie_equal(expected = nil, key = nil, message = nil)
67
- response = acquire_assertion_target
68
- msg = build_message(message, "<?> expected in cookies['?'] but was <?>", expected, key, response.cookies[key.to_s].first)
69
- assert_block(msg) { expected == response.cookies[key.to_s].first }
70
- end
71
-
72
- # -- flash assertions ---------------------------------------------------
73
-
74
- # ensure that the flash has an object with the specified name
75
- def assert_flash_has(key=nil, message=nil)
76
- response = acquire_assertion_target
77
- msg = build_message(message, "<?> is not in the flash <?>", key, response.flash)
78
- assert_block(msg) { response.has_flash_object?(key) }
79
- end
80
-
81
- # ensure that the flash has no object with the specified name
82
- def assert_flash_has_no(key=nil, message=nil)
83
- response = acquire_assertion_target
84
- msg = build_message(message, "<?> is in the flash <?>", key, response.flash)
85
- assert_block(msg) { !response.has_flash_object?(key) }
86
- end
87
-
88
- # ensure the flash exists
89
- def assert_flash_exists(message=nil)
90
- response = acquire_assertion_target
91
- msg = build_message(message, "the flash does not exist <?>", response.session['flash'] )
92
- assert_block(msg) { response.has_flash? }
93
- end
94
-
95
- # ensure the flash does not exist
96
- def assert_flash_not_exists(message=nil)
97
- response = acquire_assertion_target
98
- msg = build_message(message, "the flash exists <?>", response.flash)
99
- assert_block(msg) { !response.has_flash? }
100
- end
101
-
102
- # ensure the flash is empty but existent
103
- def assert_flash_empty(message=nil)
104
- response = acquire_assertion_target
105
- msg = build_message(message, "the flash is not empty <?>", response.flash)
106
- assert_block(msg) { !response.has_flash_with_contents? }
107
- end
108
-
109
- # ensure the flash is not empty
110
- def assert_flash_not_empty(message=nil)
111
- response = acquire_assertion_target
112
- msg = build_message(message, "the flash is empty")
113
- assert_block(msg) { response.has_flash_with_contents? }
114
- end
115
-
116
- def assert_flash_equal(expected = nil, key = nil, message = nil)
117
- response = acquire_assertion_target
118
- msg = build_message(message, "<?> expected in flash['?'] but was <?>", expected, key, response.flash[key])
119
- assert_block(msg) { expected == response.flash[key] }
120
- end
121
-
122
- # -- redirection assertions ---------------------------------------------
123
-
124
- # ensure we have be redirected
125
- def assert_redirect(message=nil)
126
- response = acquire_assertion_target
127
- msg = build_message(message, "response is not a redirection (response code is <?>)", response.response_code)
128
- assert_block(msg) { response.redirect? }
129
- end
130
-
131
- def assert_redirected_to(options = {}, message=nil)
132
- assert_redirect(message)
133
- response = acquire_assertion_target
134
-
135
- msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)", response.redirected_to)
136
- assert_block(msg) do
137
- if options.is_a?(Symbol)
138
- response.redirected_to == options
139
- else
140
- options.keys.all? { |k| options[k] == ( response.redirected_to[k].respond_to?(:to_param) ? response.redirected_to[k].to_param : response.redirected_to[k] if response.redirected_to[k] ) }
141
- end
142
- end
143
- end
144
-
145
- # ensure our redirection url is an exact match
146
- def assert_redirect_url(url=nil, message=nil)
147
- assert_redirect(message)
148
- response = acquire_assertion_target
149
- msg = build_message(message, "<?> is not the redirected location <?>", url, response.redirect_url)
150
- assert_block(msg) { response.redirect_url == url }
151
- end
152
-
153
- # ensure our redirection url matches a pattern
154
- def assert_redirect_url_match(pattern=nil, message=nil)
155
- assert_redirect(message)
156
- response = acquire_assertion_target
157
- msg = build_message(message, "<?> was not found in the location: <?>", pattern, response.redirect_url)
158
- assert_block(msg) { response.redirect_url_match?(pattern) }
159
- end
160
-
161
- # -- routing assertions --------------------------------------------------
162
-
163
- # Asserts that the routing of the given path is handled correctly and that the parsed options match.
164
- def assert_recognizes(expected_options, path, extras={}, message=nil)
165
- # Load routes.rb if it hasn't been loaded.
166
- ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
167
-
168
- # Assume given controller
169
- request = ActionController::TestRequest.new({}, {}, nil)
170
- request.path = path
171
- ActionController::Routing::Routes.recognize!(request)
172
-
173
- expected_options = expected_options.clone
174
- extras.each_key { |key| expected_options.delete key } unless extras.nil?
175
-
176
- msg = build_message(message, "The recognized options <?> did not match <?>",
177
- request.path_parameters, expected_options)
178
- assert_block(msg) { request.path_parameters == expected_options }
179
- end
180
-
181
- # Asserts that the provided options can be used to generate the provided path.
182
- def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
183
- # Load routes.rb if it hasn't been loaded.
184
- ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
185
-
186
- # Assume given controller
187
- request = ActionController::TestRequest.new({}, {}, nil)
188
- request.path_parameters = (defaults or {}).clone
189
- request.path_parameters[:controller] ||= options[:controller]
190
-
191
- generated_path, found_extras = ActionController::Routing::Routes.generate(options, request)
192
- generated_path = generated_path.join('/')
193
- msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
194
- assert_block(msg) { found_extras == extras }
195
-
196
- msg = build_message(message, "The generated path <?> did not match <?>", generated_path,
197
- expected_path)
198
- assert_block(msg) { expected_path == generated_path }
199
- end
200
-
201
- # asserts that path and options match both ways, in other words, the URL generated from
202
- # options is same as path, and also that the options recognized from path are same as options
203
- def assert_routing(path, options, defaults={}, extras={}, message=nil)
204
- assert_recognizes(options, path, extras, message)
205
- assert_generates(path, options, defaults, extras, message)
206
- end
207
-
208
- # -- template assertions ------------------------------------------------
209
-
210
- # ensure that a template object with the given name exists
211
- def assert_template_has(key=nil, message=nil)
212
- response = acquire_assertion_target
213
- msg = build_message(message, "<?> is not a template object", key )
214
- assert_block(msg) { response.has_template_object?(key) }
215
- end
216
-
217
- # ensure that a template object with the given name does not exist
218
- def assert_template_has_no(key=nil,message=nil)
219
- response = acquire_assertion_target
220
- msg = build_message(message, "<?> is a template object <?>", key, response.template_objects[key])
221
- assert_block(msg) { !response.has_template_object?(key) }
222
- end
223
-
224
- # ensures that the object assigned to the template on +key+ is equal to +expected+ object.
225
- def assert_assigned_equal(expected = nil, key = nil, message = nil)
226
- response = acquire_assertion_target
227
- msg = build_message(message, "<?> expected in assigns['?'] but was <?>", expected, key, response.template.assigns[key.to_s])
228
- assert_block(msg) { expected == response.template.assigns[key.to_s] }
229
- end
230
-
231
- # Asserts that the template returns the +expected+ string or array based on the XPath +expression+.
232
- # This will only work if the template rendered a valid XML document.
233
- def assert_template_xpath_match(expression=nil, expected=nil, message=nil)
234
- response = acquire_assertion_target
235
- xml, matches = REXML::Document.new(response.body), []
236
- xml.elements.each(expression) { |e| matches << e.text }
237
- if matches.empty? then
238
- msg = build_message(message, "<?> not found in document", expression)
239
- flunk(msg)
240
- return
241
- elsif matches.length < 2 then
242
- matches = matches.first
243
- end
244
-
245
- msg = build_message(message, "<?> found <?>, not <?>", expression, matches, expected)
246
- assert_block(msg) { matches == expected }
247
- end
248
-
249
- # -- helper functions ---------------------------------------------------
250
-
251
- # get the TestResponse object that these assertions depend upon
252
- def acquire_assertion_target
253
- target = ActionController::TestResponse.assertion_target
254
- assert_block( "Unable to acquire the TestResponse.assertion_target. Please set this before calling this assertion." ) { !target.nil? }
255
- target
256
- end
257
-
258
- end # Assertions
259
- end # Unit
260
- end # Test