actionpack 0.9.5 → 1.0.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 (53) hide show
  1. data/CHANGELOG +177 -0
  2. data/README +0 -1
  3. data/install.rb +1 -0
  4. data/lib/action_controller.rb +6 -1
  5. data/lib/action_controller/assertions/active_record_assertions.rb +2 -2
  6. data/lib/action_controller/base.rb +53 -41
  7. data/lib/action_controller/benchmarking.rb +1 -1
  8. data/lib/action_controller/cgi_ext/cgi_methods.rb +14 -16
  9. data/lib/action_controller/cgi_process.rb +16 -6
  10. data/lib/action_controller/cookies.rb +70 -0
  11. data/lib/action_controller/dependencies.rb +106 -0
  12. data/lib/action_controller/helpers.rb +14 -3
  13. data/lib/action_controller/layout.rb +16 -2
  14. data/lib/action_controller/request.rb +17 -7
  15. data/lib/action_controller/rescue.rb +33 -3
  16. data/lib/action_controller/support/class_inheritable_attributes.rb +4 -0
  17. data/lib/action_controller/support/inflector.rb +14 -12
  18. data/lib/action_controller/support/misc.rb +6 -0
  19. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +2 -2
  20. data/lib/action_controller/templates/rescues/diagnostics.rhtml +4 -6
  21. data/lib/action_controller/templates/rescues/template_error.rhtml +1 -9
  22. data/lib/action_controller/templates/scaffolds/edit.rhtml +2 -1
  23. data/lib/action_controller/templates/scaffolds/layout.rhtml +36 -0
  24. data/lib/action_controller/templates/scaffolds/new.rhtml +1 -0
  25. data/lib/action_controller/test_process.rb +27 -8
  26. data/lib/action_controller/url_rewriter.rb +15 -4
  27. data/lib/action_view/base.rb +4 -3
  28. data/lib/action_view/helpers/active_record_helper.rb +29 -15
  29. data/lib/action_view/helpers/date_helper.rb +6 -5
  30. data/lib/action_view/helpers/form_helper.rb +31 -4
  31. data/lib/action_view/helpers/form_options_helper.rb +13 -3
  32. data/lib/action_view/helpers/tag_helper.rb +14 -16
  33. data/lib/action_view/helpers/url_helper.rb +46 -1
  34. data/lib/action_view/partials.rb +8 -1
  35. data/lib/action_view/template_error.rb +10 -3
  36. data/lib/action_view/vendor/builder/blankslate.rb +33 -1
  37. data/lib/action_view/vendor/builder/xmlevents.rb +1 -1
  38. data/lib/action_view/vendor/builder/xmlmarkup.rb +1 -1
  39. data/rakefile +4 -13
  40. data/test/controller/action_pack_assertions_test.rb +39 -1
  41. data/test/controller/active_record_assertions_test.rb +6 -5
  42. data/test/controller/cgi_test.rb +33 -3
  43. data/test/controller/cookie_test.rb +43 -2
  44. data/test/controller/helper_test.rb +1 -1
  45. data/test/controller/render_test.rb +9 -0
  46. data/test/controller/url_test.rb +16 -0
  47. data/test/fixtures/scope/test/modgreet.rhtml +1 -0
  48. data/test/template/active_record_helper_test.rb +34 -8
  49. data/test/template/date_helper_test.rb +164 -20
  50. data/test/template/form_helper_test.rb +12 -0
  51. data/test/template/form_options_helper_test.rb +7 -16
  52. data/test/template/url_helper_test.rb +12 -0
  53. metadata +8 -2
@@ -67,7 +67,7 @@ class HelperTest < Test::Unit::TestCase
67
67
 
68
68
  def test_declare_missing_helper
69
69
  assert_equal helper_methods, missing_methods
70
- assert_raise(ArgumentError) { @controller_class.helper :missing }
70
+ assert_raise(LoadError) { @controller_class.helper :missing }
71
71
  end
72
72
 
73
73
  def test_helper_block
@@ -52,6 +52,9 @@ class RenderTest < Test::Unit::TestCase
52
52
  render_action "list"
53
53
  end
54
54
 
55
+ def modgreet
56
+ end
57
+
55
58
  def rescue_action(e) raise end
56
59
 
57
60
  private
@@ -162,6 +165,12 @@ class RenderTest < Test::Unit::TestCase
162
165
  assert_equal "Hello: davidHello: mary", process_request.body
163
166
  end
164
167
 
168
+ def test_module_rendering
169
+ @request.action = "modgreet"
170
+ @request.parameters["module"] = "scope"
171
+ assert_equal "<p>Beautiful modules!</p>", process_request.body
172
+ end
173
+
165
174
  private
166
175
  def process_request
167
176
  TestController.process(@request, @response)
@@ -22,6 +22,14 @@ class UrlTest < Test::Unit::TestCase
22
22
  { "type" => "ISBN", "code" => "0743536703" }
23
23
  ), "books", "show")
24
24
 
25
+ @library_url_using_module = ActionController::UrlRewriter.new(MockRequest.new(
26
+ "http://",
27
+ "www.singlefile.com",
28
+ 80,
29
+ "/library/books/ISBN/0743536703/show",
30
+ { "type" => "ISBN", "code" => "0743536703", "module" => "library" }
31
+ ), "books", "show")
32
+
25
33
  @library_url_on_index = ActionController::UrlRewriter.new(MockRequest.new(
26
34
  "http://",
27
35
  "www.singlefile.com",
@@ -99,6 +107,14 @@ class UrlTest < Test::Unit::TestCase
99
107
  assert_equal "http://www.singlefile.com/shop/", @library_url.rewrite(:controller_prefix => "shop")
100
108
  end
101
109
 
110
+ def test_clean_controller_with_module
111
+ assert_equal "http://www.singlefile.com/shop/purchases/", @library_url.rewrite(:module => "shop", :controller => "purchases")
112
+ end
113
+
114
+ def test_getting_out_of_a_module
115
+ assert_equal "http://www.singlefile.com/purchases/", @library_url_using_module.rewrite(:module => false, :controller => "purchases")
116
+ end
117
+
102
118
  def test_controller_and_action
103
119
  assert_equal "http://www.singlefile.com/library/settings/show", @library_url.rewrite(:controller => "settings", :action => "show")
104
120
  end
@@ -0,0 +1 @@
1
+ <p>Beautiful modules!</p>
@@ -1,18 +1,32 @@
1
1
  require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper'
3
3
  require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper'
4
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/text_helper'
5
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/tag_helper'
6
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/url_helper'
4
7
  # require File.dirname(__FILE__) + '/../../lib/action_view/helpers/active_record_helper'
5
8
 
6
9
  class ActiveRecordHelperTest < Test::Unit::TestCase
7
10
  include ActionView::Helpers::FormHelper
8
11
  include ActionView::Helpers::ActiveRecordHelper
12
+ include ActionView::Helpers::TextHelper
13
+ include ActionView::Helpers::TagHelper
14
+ include ActionView::Helpers::UrlHelper
9
15
 
10
16
  Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on)
11
17
  Column = Struct.new("Column", :type, :name, :human_name)
12
18
 
13
19
  def setup
14
20
  @post = Post.new
15
- def @post.errors() Class.new{ def on(field) field == "author_name" || field == "body" end }.new end
21
+ def @post.errors
22
+ Class.new {
23
+ def on(field) field == "author_name" || field == "body" end
24
+ def empty?() false end
25
+ def count() 1 end
26
+ def full_messages() [ "Author name can't be empty" ] end
27
+ }.new
28
+ end
29
+
16
30
  def @post.new_record?() true end
17
31
 
18
32
  def @post.column_for_attribute(attr_name)
@@ -26,31 +40,38 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
26
40
  @post.body = "Back to the hill and over it again!"
27
41
  @post.secret = 1
28
42
  @post.written_on = Date.new(2004, 6, 15)
43
+
44
+ @controller = Class.new do
45
+ def url_for(options, *parameters_for_method_reference)
46
+ options[:action]
47
+ end
48
+ end
49
+ @controller = @controller.new
29
50
  end
30
51
 
31
52
  def test_generic_input_tag
32
53
  assert_equal(
33
- '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', input("post", "title")
54
+ %(<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />), input("post", "title")
34
55
  )
35
56
  end
36
57
 
37
58
  def test_text_area_with_errors
38
59
  assert_equal(
39
- "<div class=\"fieldWithErrors\"><textarea cols=\"40\" id=\"post_body\" name=\"post[body]\" rows=\"20\" wrap=\"virtual\">Back to the hill and over it again!</textarea></div>",
60
+ %(<div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea></div>),
40
61
  text_area("post", "body")
41
62
  )
42
63
  end
43
64
 
44
65
  def test_text_field_with_errors
45
66
  assert_equal(
46
- '<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>',
67
+ %(<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>),
47
68
  text_field("post", "author_name")
48
69
  )
49
70
  end
50
71
 
51
72
  def test_form_with_string
52
73
  assert_equal(
53
- "<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\" wrap=\"virtual\">Back to the hill and over it again!</textarea></div></p><input type='submit' value='Create' /></form>",
74
+ %(<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" wrap="virtual">Back to the hill and over it again!</textarea></div></p><input type="submit" value="Create" /></form>),
54
75
  form("post")
55
76
  )
56
77
  end
@@ -59,7 +80,7 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
59
80
  def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end
60
81
 
61
82
  assert_equal(
62
- "<form action='create' method='POST'><p><label for=\"post_written_on\">Written on</label><br /><select name='post[written_on(1i)]'>\n<option>1999</option>\n<option>2000</option>\n<option>2001</option>\n<option>2002</option>\n<option>2003</option>\n<option selected=\"selected\">2004</option>\n<option>2005</option>\n<option>2006</option>\n<option>2007</option>\n<option>2008</option>\n<option>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>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option selected=\"selected\">15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n</select>\n</p><input type='submit' value='Create' /></form>",
83
+ %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select name="post[written_on(1i)]">\n<option>1999</option>\n<option>2000</option>\n<option>2001</option>\n<option>2002</option>\n<option>2003</option>\n<option selected="selected">2004</option>\n<option>2005</option>\n<option>2006</option>\n<option>2007</option>\n<option>2008</option>\n<option>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>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option selected="selected">15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n</select>\n</p><input type="submit" value="Create" /></form>),
63
84
  form("post")
64
85
  )
65
86
  end
@@ -69,8 +90,13 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
69
90
  @post.written_on = Time.gm(2004, 6, 15, 16, 30)
70
91
 
71
92
  assert_equal(
72
- "<form action='create' method='POST'><p><label for=\"post_written_on\">Written on</label><br /><select name='post[written_on(1i)]'>\n<option>1999</option>\n<option>2000</option>\n<option>2001</option>\n<option>2002</option>\n<option>2003</option>\n<option selected=\"selected\">2004</option>\n<option>2005</option>\n<option>2006</option>\n<option>2007</option>\n<option>2008</option>\n<option>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>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option selected=\"selected\">15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n</select>\n &mdash; <select name='post[written_on(4i)]'>\n<option>00</option>\n<option>01</option>\n<option>02</option>\n<option>03</option>\n<option>04</option>\n<option>05</option>\n<option>06</option>\n<option>07</option>\n<option>08</option>\n<option>09</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected=\"selected\">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n</select>\n : <select name='post[written_on(5i)]'>\n<option>00</option>\n<option>01</option>\n<option>02</option>\n<option>03</option>\n<option>04</option>\n<option>05</option>\n<option>06</option>\n<option>07</option>\n<option>08</option>\n<option>09</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option selected=\"selected\">30</option>\n<option>31</option>\n<option>32</option>\n<option>33</option>\n<option>34</option>\n<option>35</option>\n<option>36</option>\n<option>37</option>\n<option>38</option>\n<option>39</option>\n<option>40</option>\n<option>41</option>\n<option>42</option>\n<option>43</option>\n<option>44</option>\n<option>45</option>\n<option>46</option>\n<option>47</option>\n<option>48</option>\n<option>49</option>\n<option>50</option>\n<option>51</option>\n<option>52</option>\n<option>53</option>\n<option>54</option>\n<option>55</option>\n<option>56</option>\n<option>57</option>\n<option>58</option>\n<option>59</option>\n</select>\n</p><input type='submit' value='Create' /></form>",
93
+ %(<form action="create" method="post"><p><label for="post_written_on">Written on</label><br /><select name="post[written_on(1i)]">\n<option>1999</option>\n<option>2000</option>\n<option>2001</option>\n<option>2002</option>\n<option>2003</option>\n<option selected="selected">2004</option>\n<option>2005</option>\n<option>2006</option>\n<option>2007</option>\n<option>2008</option>\n<option>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>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option selected="selected">15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n</select>\n &mdash; <select name="post[written_on(4i)]">\n<option>00</option>\n<option>01</option>\n<option>02</option>\n<option>03</option>\n<option>04</option>\n<option>05</option>\n<option>06</option>\n<option>07</option>\n<option>08</option>\n<option>09</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n</select>\n : <select name="post[written_on(5i)]">\n<option>00</option>\n<option>01</option>\n<option>02</option>\n<option>03</option>\n<option>04</option>\n<option>05</option>\n<option>06</option>\n<option>07</option>\n<option>08</option>\n<option>09</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option selected="selected">30</option>\n<option>31</option>\n<option>32</option>\n<option>33</option>\n<option>34</option>\n<option>35</option>\n<option>36</option>\n<option>37</option>\n<option>38</option>\n<option>39</option>\n<option>40</option>\n<option>41</option>\n<option>42</option>\n<option>43</option>\n<option>44</option>\n<option>45</option>\n<option>46</option>\n<option>47</option>\n<option>48</option>\n<option>49</option>\n<option>50</option>\n<option>51</option>\n<option>52</option>\n<option>53</option>\n<option>54</option>\n<option>55</option>\n<option>56</option>\n<option>57</option>\n<option>58</option>\n<option>59</option>\n</select>\n</p><input type="submit" value="Create" /></form>),
73
94
  form("post")
74
95
  )
75
96
  end
76
- end
97
+
98
+ def test_error_for_block
99
+ 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")
100
+ 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")
101
+ end
102
+ end
@@ -16,9 +16,9 @@ class DateHelperTest < Test::Unit::TestCase
16
16
  end
17
17
 
18
18
  def test_select_day
19
- expected = "<select name='date[day]'>\n"
19
+ expected = %(<select name="date[day]">\n)
20
20
  expected <<
21
- "<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected=\"selected\">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n"
21
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
22
22
  expected << "</select>\n"
23
23
 
24
24
  assert_equal expected, select_day(Time.mktime(2003, 8, 16))
@@ -26,9 +26,9 @@ class DateHelperTest < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def test_select_day_with_blank
29
- expected = "<select name='date[day]'>\n"
29
+ expected = %(<select name="date[day]">\n)
30
30
  expected <<
31
- "<option></option>\n<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected=\"selected\">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n"
31
+ %(<option></option>\n<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
32
32
  expected << "</select>\n"
33
33
 
34
34
  assert_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true)
@@ -36,8 +36,8 @@ class DateHelperTest < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  def test_select_month
39
- expected = "<select name='date[month]'>\n"
40
- 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"
39
+ expected = %(<select name="date[month]">\n)
40
+ 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)
41
41
  expected << "</select>\n"
42
42
 
43
43
  assert_equal expected, select_month(Time.mktime(2003, 8, 16))
@@ -45,8 +45,8 @@ class DateHelperTest < Test::Unit::TestCase
45
45
  end
46
46
 
47
47
  def test_select_month_with_numbers
48
- expected = "<select name='date[month]'>\n"
49
- 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' selected=\"selected\">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"
48
+ expected = %(<select name="date[month]">\n)
49
+ 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" selected="selected">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)
50
50
  expected << "</select>\n"
51
51
 
52
52
  assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true)
@@ -54,8 +54,8 @@ class DateHelperTest < Test::Unit::TestCase
54
54
  end
55
55
 
56
56
  def test_select_month_with_numbers_and_names
57
- expected = "<select name='date[month]'>\n"
58
- expected << "<option value='1'>1 - January</option>\n<option value='2'>2 - February</option>\n<option value='3'>3 - March</option>\n<option value='4'>4 - April</option>\n<option value='5'>5 - May</option>\n<option value='6'>6 - June</option>\n<option value='7'>7 - July</option>\n<option value='8' selected=\"selected\">8 - August</option>\n<option value='9'>9 - September</option>\n<option value='10'>10 - October</option>\n<option value='11'>11 - November</option>\n<option value='12'>12 - December</option>\n"
57
+ expected = %(<select name="date[month]">\n)
58
+ expected << %(<option value="1">1 - January</option>\n<option value="2">2 - February</option>\n<option value="3">3 - March</option>\n<option value="4">4 - April</option>\n<option value="5">5 - May</option>\n<option value="6">6 - June</option>\n<option value="7">7 - July</option>\n<option value="8" selected="selected">8 - August</option>\n<option value="9">9 - September</option>\n<option value="10">10 - October</option>\n<option value="11">11 - November</option>\n<option value="12">12 - December</option>\n)
59
59
  expected << "</select>\n"
60
60
 
61
61
  assert_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true)
@@ -63,8 +63,8 @@ class DateHelperTest < Test::Unit::TestCase
63
63
  end
64
64
 
65
65
  def test_select_year
66
- expected = "<select name='date[year]'>\n"
67
- expected << "<option selected=\"selected\">2003</option>\n<option>2004</option>\n<option>2005</option>\n"
66
+ expected = %(<select name="date[year]">\n)
67
+ expected << %(<option selected="selected">2003</option>\n<option>2004</option>\n<option>2005</option>\n)
68
68
  expected << "</select>\n"
69
69
 
70
70
  assert_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005)
@@ -72,8 +72,8 @@ class DateHelperTest < Test::Unit::TestCase
72
72
  end
73
73
 
74
74
  def test_select_year_with_type_discarding
75
- expected = "<select name='date_year'>\n"
76
- expected << "<option selected=\"selected\">2003</option>\n<option>2004</option>\n<option>2005</option>\n"
75
+ expected = %(<select name="date_year">\n)
76
+ expected << %(<option selected="selected">2003</option>\n<option>2004</option>\n<option>2005</option>\n)
77
77
  expected << "</select>\n"
78
78
 
79
79
  assert_equal expected, select_year(
@@ -84,21 +84,165 @@ class DateHelperTest < Test::Unit::TestCase
84
84
 
85
85
 
86
86
  def test_select_date
87
- expected = "<select name='date[first][year]'>\n"
88
- expected << "<option selected=\"selected\">2003</option>\n<option>2004</option>\n<option>2005</option>\n"
87
+ expected = %(<select name="date[first][year]">\n)
88
+ expected << %(<option selected="selected">2003</option>\n<option>2004</option>\n<option>2005</option>\n)
89
89
  expected << "</select>\n"
90
90
 
91
- expected << "<select name='date[first][month]'>\n"
92
- 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"
91
+ expected << %(<select name="date[first][month]">\n)
92
+ 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)
93
93
  expected << "</select>\n"
94
94
 
95
- expected << "<select name='date[first][day]'>\n"
95
+ expected << %(<select name="date[first][day]">\n)
96
96
  expected <<
97
- "<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected=\"selected\">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n"
97
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
98
98
  expected << "</select>\n"
99
99
 
100
100
  assert_equal expected, select_date(
101
101
  Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]"
102
102
  )
103
103
  end
104
+
105
+ def test_select_date_with_no_start_year
106
+ expected = %(<select name="date[first][year]">\n)
107
+ (Date.today.year-5).upto(Date.today.year+1) do |y|
108
+ if y == Date.today.year
109
+ expected << %(<option selected="selected">#{y}</option>\n)
110
+ else
111
+ expected << %(<option>#{y}</option>\n)
112
+ end
113
+ end
114
+ expected << "</select>\n"
115
+
116
+ expected << %(<select name="date[first][month]">\n)
117
+ 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)
118
+ expected << "</select>\n"
119
+
120
+ expected << %(<select name="date[first][day]">\n)
121
+ expected <<
122
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
123
+ expected << "</select>\n"
124
+
125
+ assert_equal expected, select_date(
126
+ Time.mktime(Date.today.year, 8, 16), :end_year => Date.today.year+1, :prefix => "date[first]"
127
+ )
128
+ end
129
+
130
+ def test_select_date_with_no_end_year
131
+ expected = %(<select name="date[first][year]">\n)
132
+ 2003.upto(2008) do |y|
133
+ if y == 2003
134
+ expected << %(<option selected="selected">#{y}</option>\n)
135
+ else
136
+ expected << %(<option>#{y}</option>\n)
137
+ end
138
+ end
139
+ expected << "</select>\n"
140
+
141
+ expected << %(<select name="date[first][month]">\n)
142
+ 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)
143
+ expected << "</select>\n"
144
+
145
+ expected << %(<select name="date[first][day]">\n)
146
+ expected <<
147
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
148
+ expected << "</select>\n"
149
+
150
+ assert_equal expected, select_date(
151
+ Time.mktime(2003, 8, 16), :start_year => 2003, :prefix => "date[first]"
152
+ )
153
+ end
154
+
155
+ def test_select_date_with_no_start_or_end_year
156
+ expected = %(<select name="date[first][year]">\n)
157
+ (Date.today.year-5).upto(Date.today.year+5) do |y|
158
+ if y == Date.today.year
159
+ expected << %(<option selected="selected">#{y}</option>\n)
160
+ else
161
+ expected << %(<option>#{y}</option>\n)
162
+ end
163
+ end
164
+ expected << "</select>\n"
165
+
166
+ expected << %(<select name="date[first][month]">\n)
167
+ 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)
168
+ expected << "</select>\n"
169
+
170
+ expected << %(<select name="date[first][day]">\n)
171
+ expected <<
172
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option selected="selected">16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
173
+ expected << "</select>\n"
174
+
175
+ assert_equal expected, select_date(
176
+ Time.mktime(Date.today.year, 8, 16), :prefix => "date[first]"
177
+ )
178
+ end
179
+
180
+ def test_date_select_with_zero_value
181
+ expected = %(<select name="date[first][year]">\n)
182
+ expected << %(<option>2003</option>\n<option>2004</option>\n<option>2005</option>\n)
183
+ expected << "</select>\n"
184
+
185
+ expected << %(<select name="date[first][month]">\n)
186
+ 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">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)
187
+ expected << "</select>\n"
188
+
189
+ expected << %(<select name="date[first][day]">\n)
190
+ expected <<
191
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
192
+ expected << "</select>\n"
193
+
194
+ assert_equal expected, select_date(0, :start_year => 2003, :end_year => 2005, :prefix => "date[first]")
195
+ end
196
+
197
+ def test_date_select_with_zero_value_and_no_start_year
198
+ expected = %(<select name="date[first][year]">\n)
199
+ (Date.today.year-5).upto(Date.today.year+1) { |y| expected << %(<option>#{y}</option>\n) }
200
+ expected << "</select>\n"
201
+
202
+ expected << %(<select name="date[first][month]">\n)
203
+ 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">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)
204
+ expected << "</select>\n"
205
+
206
+ expected << %(<select name="date[first][day]">\n)
207
+ expected <<
208
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
209
+ expected << "</select>\n"
210
+
211
+ assert_equal expected, select_date(0, :end_year => Date.today.year+1, :prefix => "date[first]")
212
+ end
213
+
214
+ def test_date_select_with_zero_value_and_no_end_year
215
+ expected = %(<select name="date[first][year]">\n)
216
+ 2003.upto(2009) { |y| expected << %(<option>#{y}</option>\n) }
217
+ expected << "</select>\n"
218
+
219
+ expected << %(<select name="date[first][month]">\n)
220
+ 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">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)
221
+ expected << "</select>\n"
222
+
223
+ expected << %(<select name="date[first][day]">\n)
224
+ expected <<
225
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
226
+ expected << "</select>\n"
227
+
228
+ assert_equal expected, select_date(0, :start_year => 2003, :prefix => "date[first]")
229
+ end
230
+
231
+ def test_date_select_with_zero_value_and_no_start_and_end_year
232
+ expected = %(<select name="date[first][year]">\n)
233
+ (Date.today.year-5).upto(Date.today.year+5) { |y| expected << %(<option>#{y}</option>\n) }
234
+ expected << "</select>\n"
235
+
236
+ expected << %(<select name="date[first][month]">\n)
237
+ 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">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)
238
+ expected << "</select>\n"
239
+
240
+ expected << %(<select name="date[first][day]">\n)
241
+ expected <<
242
+ %(<option>1</option>\n<option>2</option>\n<option>3</option>\n<option>4</option>\n<option>5</option>\n<option>6</option>\n<option>7</option>\n<option>8</option>\n<option>9</option>\n<option>10</option>\n<option>11</option>\n<option>12</option>\n<option>13</option>\n<option>14</option>\n<option>15</option>\n<option>16</option>\n<option>17</option>\n<option>18</option>\n<option>19</option>\n<option>20</option>\n<option>21</option>\n<option>22</option>\n<option>23</option>\n<option>24</option>\n<option>25</option>\n<option>26</option>\n<option>27</option>\n<option>28</option>\n<option>29</option>\n<option>30</option>\n<option>31</option>\n)
243
+ expected << "</select>\n"
244
+
245
+ assert_equal expected, select_date(0, :prefix => "date[first]")
246
+ end
247
+
104
248
  end
@@ -1,10 +1,13 @@
1
1
  require 'test/unit'
2
+ require 'erb'
2
3
  require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper'
3
4
 
4
5
  class FormHelperTest < Test::Unit::TestCase
5
6
  include ActionView::Helpers::FormHelper
6
7
 
8
+ old_verbose, $VERBOSE = $VERBOSE, nil
7
9
  Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on)
10
+ $VERBOSE = old_verbose
8
11
 
9
12
  def setup
10
13
  @post = Post.new
@@ -68,6 +71,15 @@ class FormHelperTest < Test::Unit::TestCase
68
71
  check_box("post", "secret")
69
72
  )
70
73
  end
74
+
75
+ def test_radio_button
76
+ assert_equal('<input checked="checked" id="post_title" name="post[title]" size="30" type="radio" value="Hello World" />',
77
+ radio_button("post", "title", "Hello World")
78
+ )
79
+ assert_equal('<input id="post_title" name="post[title]" size="30" type="radio" value="Goodbye World" />',
80
+ radio_button("post", "title", "Goodbye World")
81
+ )
82
+ end
71
83
 
72
84
  def test_text_area
73
85
  assert_equal(
@@ -1,24 +1,15 @@
1
1
  require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_options_helper'
3
3
 
4
- class Continent
5
- def initialize(p_name, p_countries) @continent_name = p_name; @countries = p_countries; end
6
- def continent_name() @continent_name; end
7
- def countries() @countries; end
8
- end
9
-
10
- class Country
11
- def initialize(id, name) @id = id; @name = name end
12
- def country_id() @id; end
13
- def country_name() @name; end
14
- end
15
-
16
-
17
4
  class FormOptionsHelperTest < Test::Unit::TestCase
18
5
  include ActionView::Helpers::FormOptionsHelper
19
6
 
20
- Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :category, :origin)
21
-
7
+ old_verbose, $VERBOSE = $VERBOSE, nil
8
+ Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin)
9
+ Continent = Struct.new('Continent', :continent_name, :countries)
10
+ Country = Struct.new('Country', :country_id, :country_name)
11
+ $VERBOSE = old_verbose
12
+
22
13
  def test_collection_options
23
14
  @posts = [
24
15
  Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
@@ -105,7 +96,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
105
96
  @continents = [
106
97
  Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ),
107
98
  Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] )
108
- ]
99
+ ]
109
100
 
110
101
  assert_equal(
111
102
  "<optgroup label=\"&lt;Africa&gt;\"><option value=\"&lt;sa&gt;\">&lt;South Africa&gt;</option>\n<option value=\"so\">Somalia</option></optgroup><optgroup label=\"Europe\"><option value=\"dk\" selected=\"selected\">Denmark</option>\n<option value=\"ie\">Ireland</option></optgroup>",