actionpack 0.9.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 (100) hide show
  1. data/CHANGELOG +604 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +418 -0
  4. data/RUNNING_UNIT_TESTS +14 -0
  5. data/examples/.htaccess +24 -0
  6. data/examples/address_book/index.rhtml +33 -0
  7. data/examples/address_book/layout.rhtml +8 -0
  8. data/examples/address_book_controller.cgi +9 -0
  9. data/examples/address_book_controller.fcgi +6 -0
  10. data/examples/address_book_controller.rb +52 -0
  11. data/examples/address_book_controller.rbx +4 -0
  12. data/examples/benchmark.rb +52 -0
  13. data/examples/benchmark_with_ar.fcgi +89 -0
  14. data/examples/blog_controller.cgi +53 -0
  15. data/examples/debate/index.rhtml +14 -0
  16. data/examples/debate/new_topic.rhtml +22 -0
  17. data/examples/debate/topic.rhtml +32 -0
  18. data/examples/debate_controller.cgi +57 -0
  19. data/install.rb +93 -0
  20. data/lib/action_controller.rb +47 -0
  21. data/lib/action_controller/assertions/action_pack_assertions.rb +166 -0
  22. data/lib/action_controller/assertions/active_record_assertions.rb +65 -0
  23. data/lib/action_controller/base.rb +626 -0
  24. data/lib/action_controller/benchmarking.rb +49 -0
  25. data/lib/action_controller/cgi_ext/cgi_ext.rb +43 -0
  26. data/lib/action_controller/cgi_ext/cgi_methods.rb +91 -0
  27. data/lib/action_controller/cgi_process.rb +123 -0
  28. data/lib/action_controller/filters.rb +279 -0
  29. data/lib/action_controller/flash.rb +65 -0
  30. data/lib/action_controller/layout.rb +143 -0
  31. data/lib/action_controller/request.rb +92 -0
  32. data/lib/action_controller/rescue.rb +94 -0
  33. data/lib/action_controller/response.rb +15 -0
  34. data/lib/action_controller/scaffolding.rb +183 -0
  35. data/lib/action_controller/session/active_record_store.rb +72 -0
  36. data/lib/action_controller/session/drb_server.rb +9 -0
  37. data/lib/action_controller/session/drb_store.rb +31 -0
  38. data/lib/action_controller/support/class_attribute_accessors.rb +57 -0
  39. data/lib/action_controller/support/class_inheritable_attributes.rb +37 -0
  40. data/lib/action_controller/support/clean_logger.rb +10 -0
  41. data/lib/action_controller/support/cookie_performance_fix.rb +121 -0
  42. data/lib/action_controller/support/inflector.rb +70 -0
  43. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +28 -0
  44. data/lib/action_controller/templates/rescues/diagnostics.rhtml +22 -0
  45. data/lib/action_controller/templates/rescues/layout.rhtml +29 -0
  46. data/lib/action_controller/templates/rescues/missing_template.rhtml +2 -0
  47. data/lib/action_controller/templates/rescues/template_error.rhtml +26 -0
  48. data/lib/action_controller/templates/rescues/unknown_action.rhtml +2 -0
  49. data/lib/action_controller/templates/scaffolds/edit.rhtml +6 -0
  50. data/lib/action_controller/templates/scaffolds/layout.rhtml +29 -0
  51. data/lib/action_controller/templates/scaffolds/list.rhtml +24 -0
  52. data/lib/action_controller/templates/scaffolds/new.rhtml +5 -0
  53. data/lib/action_controller/templates/scaffolds/show.rhtml +9 -0
  54. data/lib/action_controller/test_process.rb +194 -0
  55. data/lib/action_controller/url_rewriter.rb +153 -0
  56. data/lib/action_view.rb +40 -0
  57. data/lib/action_view/base.rb +253 -0
  58. data/lib/action_view/helpers/active_record_helper.rb +171 -0
  59. data/lib/action_view/helpers/date_helper.rb +223 -0
  60. data/lib/action_view/helpers/debug_helper.rb +17 -0
  61. data/lib/action_view/helpers/form_helper.rb +176 -0
  62. data/lib/action_view/helpers/form_options_helper.rb +169 -0
  63. data/lib/action_view/helpers/tag_helper.rb +59 -0
  64. data/lib/action_view/helpers/text_helper.rb +129 -0
  65. data/lib/action_view/helpers/url_helper.rb +72 -0
  66. data/lib/action_view/partials.rb +61 -0
  67. data/lib/action_view/template_error.rb +84 -0
  68. data/lib/action_view/vendor/builder.rb +13 -0
  69. data/lib/action_view/vendor/builder/blankslate.rb +21 -0
  70. data/lib/action_view/vendor/builder/xmlbase.rb +143 -0
  71. data/lib/action_view/vendor/builder/xmlevents.rb +63 -0
  72. data/lib/action_view/vendor/builder/xmlmarkup.rb +288 -0
  73. data/rakefile +105 -0
  74. data/test/abstract_unit.rb +9 -0
  75. data/test/controller/action_pack_assertions_test.rb +295 -0
  76. data/test/controller/active_record_assertions_test.rb +118 -0
  77. data/test/controller/cgi_test.rb +142 -0
  78. data/test/controller/cookie_test.rb +38 -0
  79. data/test/controller/filters_test.rb +159 -0
  80. data/test/controller/flash_test.rb +69 -0
  81. data/test/controller/layout_test.rb +49 -0
  82. data/test/controller/redirect_test.rb +44 -0
  83. data/test/controller/render_test.rb +169 -0
  84. data/test/controller/url_test.rb +318 -0
  85. data/test/fixtures/layouts/builder.rxml +3 -0
  86. data/test/fixtures/layouts/standard.rhtml +1 -0
  87. data/test/fixtures/test/_customer.rhtml +1 -0
  88. data/test/fixtures/test/greeting.rhtml +1 -0
  89. data/test/fixtures/test/hello.rxml +4 -0
  90. data/test/fixtures/test/hello_world.rhtml +1 -0
  91. data/test/fixtures/test/hello_xml_world.rxml +11 -0
  92. data/test/fixtures/test/list.rhtml +1 -0
  93. data/test/template/active_record_helper_test.rb +76 -0
  94. data/test/template/date_helper_test.rb +103 -0
  95. data/test/template/form_helper_test.rb +115 -0
  96. data/test/template/form_options_helper_test.rb +174 -0
  97. data/test/template/tag_helper_test.rb +18 -0
  98. data/test/template/text_helper_test.rb +62 -0
  99. data/test/template/url_helper_test.rb +35 -0
  100. metadata +154 -0
@@ -0,0 +1,115 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper'
3
+
4
+ class FormHelperTest < Test::Unit::TestCase
5
+ include ActionView::Helpers::FormHelper
6
+
7
+ Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on)
8
+
9
+ def setup
10
+ @post = Post.new
11
+ def @post.errors() Class.new{ def on(field) field == "author_name" end }.new end
12
+
13
+ @post.title = "Hello World"
14
+ @post.author_name = ""
15
+ @post.body = "Back to the hill and over it again!"
16
+ @post.secret = 1
17
+ @post.written_on = Date.new(2004, 6, 15)
18
+ end
19
+
20
+ def test_text_field
21
+ assert_equal(
22
+ '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title")
23
+ )
24
+ assert_equal(
25
+ '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />', password_field("post", "title")
26
+ )
27
+ assert_equal(
28
+ '<input id="person_name" name="person[name]" size="30" type="password" value="" />', password_field("person", "name")
29
+ )
30
+ end
31
+
32
+ def test_text_field_with_escapes
33
+ @post.title = "<b>Hello World</b>"
34
+ assert_equal(
35
+ '<input id="post_title" name="post[title]" size="30" type="text" value="&lt;b&gt;Hello World&lt;/b&gt;" />', text_field("post", "title")
36
+ )
37
+ end
38
+
39
+ def test_text_field_with_options
40
+ assert_equal(
41
+ '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />',
42
+ text_field("post", "title", "size" => "35")
43
+ )
44
+ end
45
+
46
+ def test_text_field_assuming_size
47
+ assert_equal(
48
+ '<input id="post_title" maxlength="35" name="post[title]" size="35" type="text" value="Hello World" />',
49
+ text_field("post", "title", "maxlength" => 35)
50
+ )
51
+ end
52
+
53
+ def test_check_box
54
+ assert_equal(
55
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', check_box("post", "secret")
56
+ )
57
+
58
+ @post.secret = 0
59
+ assert_equal '<input id="post_secret" name="post[secret]" type="checkbox" value="1" />', check_box("post", "secret")
60
+
61
+ @post.secret = true
62
+ assert_equal(
63
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', check_box("post", "secret")
64
+ )
65
+ end
66
+
67
+ def test_text_area
68
+ assert_equal(
69
+ '<textarea cols="40" id="post_body" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>',
70
+ text_area("post", "body")
71
+ )
72
+ end
73
+
74
+ def test_text_area_with_escapes
75
+ @post.body = "Back to <i>the</i> hill and over it again!"
76
+ assert_equal(
77
+ '<textarea cols="40" id="post_body" name="post[body]" rows="20" wrap="virtual">Back to &lt;i&gt;the&lt;/i&gt; hill and over it again!</textarea>',
78
+ text_area("post", "body")
79
+ )
80
+ end
81
+
82
+ def test_date_selects
83
+ assert_equal(
84
+ '<textarea cols="40" id="post_body" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>',
85
+ text_area("post", "body")
86
+ )
87
+ end
88
+
89
+
90
+ def test_explicit_name
91
+ assert_equal(
92
+ '<input id="post_title" name="dont guess" size="30" type="text" value="Hello World" />', text_field("post", "title", "name" => "dont guess")
93
+ )
94
+ assert_equal(
95
+ '<textarea cols="40" id="post_body" name="really!" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>',
96
+ text_area("post", "body", "name" => "really!")
97
+ )
98
+ assert_equal(
99
+ '<input checked="checked" id="post_secret" name="i mean it" type="checkbox" value="1" />', check_box("post", "secret", "name" => "i mean it")
100
+ )
101
+ end
102
+
103
+ def test_explicit_id
104
+ assert_equal(
105
+ '<input id="dont guess" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title", "id" => "dont guess")
106
+ )
107
+ assert_equal(
108
+ '<textarea cols="40" id="really!" name="post[body]" rows="20" wrap="virtual">Back to the hill and over it again!</textarea>',
109
+ text_area("post", "body", "id" => "really!")
110
+ )
111
+ assert_equal(
112
+ '<input checked="checked" id="i mean it" name="post[secret]" type="checkbox" value="1" />', check_box("post", "secret", "id" => "i mean it")
113
+ )
114
+ end
115
+ end
@@ -0,0 +1,174 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_options_helper'
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
+ class FormOptionsHelperTest < Test::Unit::TestCase
18
+ include ActionView::Helpers::FormOptionsHelper
19
+
20
+ Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :category, :origin)
21
+
22
+ def test_collection_options
23
+ @posts = [
24
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
25
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
26
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
27
+ ]
28
+
29
+ assert_equal(
30
+ "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>",
31
+ options_from_collection_for_select(@posts, "author_name", "title")
32
+ )
33
+ end
34
+
35
+
36
+ def test_collection_options_with_preselected_value
37
+ @posts = [
38
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
39
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
40
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
41
+ ]
42
+
43
+ assert_equal(
44
+ "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\">Cabe went home</option>",
45
+ options_from_collection_for_select(@posts, "author_name", "title", "Babe")
46
+ )
47
+ end
48
+
49
+ def test_collection_options_with_preselected_value_array
50
+ @posts = [
51
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
52
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
53
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
54
+ ]
55
+
56
+ assert_equal(
57
+ "<option value=\"&lt;Abe&gt;\">&lt;Abe&gt; went home</option>\n<option value=\"Babe\" selected=\"selected\">Babe went home</option>\n<option value=\"Cabe\" selected=\"selected\">Cabe went home</option>",
58
+ options_from_collection_for_select(@posts, "author_name", "title", [ "Babe", "Cabe" ])
59
+ )
60
+ end
61
+
62
+ def test_array_options_for_select
63
+ assert_equal(
64
+ "<option>&lt;Denmark&gt;</option>\n<option>USA</option>\n<option>Sweden</option>",
65
+ options_for_select([ "<Denmark>", "USA", "Sweden" ])
66
+ )
67
+ end
68
+
69
+ def test_array_options_for_select_with_selection
70
+ assert_equal(
71
+ "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option>Sweden</option>",
72
+ options_for_select([ "Denmark", "<USA>", "Sweden" ], "<USA>")
73
+ )
74
+ end
75
+
76
+ def test_array_options_for_select_with_selection_array
77
+ assert_equal(
78
+ "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option selected=\"selected\">Sweden</option>",
79
+ options_for_select([ "Denmark", "<USA>", "Sweden" ], [ "<USA>", "Sweden" ])
80
+ )
81
+ end
82
+
83
+ def test_hash_options_for_select
84
+ assert_equal(
85
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
86
+ options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
87
+ )
88
+ end
89
+
90
+ def test_hash_options_for_select_with_selection
91
+ assert_equal(
92
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
93
+ options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
94
+ )
95
+ end
96
+
97
+ def test_hash_options_for_select_with_selection
98
+ assert_equal(
99
+ "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
100
+ options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
101
+ )
102
+ end
103
+
104
+ def test_html_option_groups_from_collection
105
+ @continents = [
106
+ Continent.new("<Africa>", [Country.new("<sa>", "<South Africa>"), Country.new("so", "Somalia")] ),
107
+ Continent.new("Europe", [Country.new("dk", "Denmark"), Country.new("ie", "Ireland")] )
108
+ ]
109
+
110
+ assert_equal(
111
+ "<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>",
112
+ option_groups_from_collection_for_select(@continents, "countries", "continent_name", "country_id", "country_name", "dk")
113
+ )
114
+ end
115
+
116
+ def test_select
117
+ @post = Post.new
118
+ @post.category = "<mus>"
119
+ assert_equal(
120
+ "<select id=\"post_category\" name=\"post[category]\"><option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
121
+ select("post", "category", %w( abe <mus> hest))
122
+ )
123
+ end
124
+
125
+ def test_select_with_blank
126
+ @post = Post.new
127
+ @post.category = "<mus>"
128
+ assert_equal(
129
+ "<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>",
130
+ select("post", "category", %w( abe <mus> hest), :include_blank => true)
131
+ )
132
+ end
133
+
134
+ def test_collection_select
135
+ @posts = [
136
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
137
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
138
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
139
+ ]
140
+
141
+ @post = Post.new
142
+ @post.author_name = "Babe"
143
+
144
+ assert_equal(
145
+ "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
146
+ collection_select("post", "author_name", @posts, "author_name", "author_name")
147
+ )
148
+ end
149
+
150
+ def test_collection_select_with_blank_and_style
151
+ @posts = [
152
+ Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
153
+ Post.new("Babe went home", "Babe", "To a little house", "shh!"),
154
+ Post.new("Cabe went home", "Cabe", "To a little house", "shh!")
155
+ ]
156
+
157
+ @post = Post.new
158
+ @post.author_name = "Babe"
159
+
160
+ assert_equal(
161
+ "<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>",
162
+ collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true }, "style" => "width: 200px")
163
+ )
164
+ end
165
+
166
+ def test_country_select
167
+ @post = Post.new
168
+ @post.origin = "Denmark"
169
+ assert_equal(
170
+ "<select id=\"post_origin\" name=\"post[origin]\"><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>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>Russian Federation</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>",
171
+ country_select("post", "origin")
172
+ )
173
+ end
174
+ end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/tag_helper'
3
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/url_helper'
4
+
5
+ class TagHelperTest < Test::Unit::TestCase
6
+ include ActionView::Helpers::TagHelper
7
+ include ActionView::Helpers::UrlHelper
8
+
9
+ def test_tag
10
+ assert_equal "<p class=\"show\" />", tag("p", "class" => "show")
11
+ end
12
+
13
+ def test_content_tag
14
+ assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create")
15
+ end
16
+
17
+ # FIXME: Test form tag
18
+ end
@@ -0,0 +1,62 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/text_helper'
3
+
4
+ class TextHelperTest < Test::Unit::TestCase
5
+ include ActionView::Helpers::TextHelper
6
+
7
+ def test_truncate
8
+ assert_equal "Hello World!", truncate("Hello World!", 12)
9
+ assert_equal "Hello Worl...", truncate("Hello World!!", 12)
10
+ end
11
+
12
+ def test_strip_links
13
+ assert_equal "on my mind", strip_links("<a href='almost'>on my mind</a>")
14
+ end
15
+
16
+ def test_highlighter
17
+ assert_equal(
18
+ "This is a <strong class=\"highlight\">beautiful</strong> morning",
19
+ highlight("This is a beautiful morning", "beautiful")
20
+ )
21
+
22
+ assert_equal(
23
+ "This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day",
24
+ highlight("This is a beautiful morning, but also a beautiful day", "beautiful")
25
+ )
26
+
27
+ assert_equal(
28
+ "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day",
29
+ highlight("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\1</b>')
30
+ )
31
+ end
32
+
33
+ def test_highlighter_with_regexp
34
+ assert_equal(
35
+ "This is a <strong class=\"highlight\">beautiful!</strong> morning",
36
+ highlight("This is a beautiful! morning", "beautiful!")
37
+ )
38
+
39
+ assert_equal(
40
+ "This is a <strong class=\"highlight\">beautiful! morning</strong>",
41
+ highlight("This is a beautiful! morning", "beautiful! morning")
42
+ )
43
+
44
+ assert_equal(
45
+ "This is a <strong class=\"highlight\">beautiful? morning</strong>",
46
+ highlight("This is a beautiful? morning", "beautiful? morning")
47
+ )
48
+ end
49
+
50
+ def test_excerpt
51
+ assert_equal("...is a beautiful morni...", excerpt("This is a beautiful morning", "beautiful", 5))
52
+ assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5))
53
+ assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5))
54
+ assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5))
55
+ assert_nil excerpt("This is a beautiful morning", "day")
56
+ end
57
+
58
+ def test_pluralization
59
+ assert_equal("1 count", pluralize(1, "count"))
60
+ assert_equal("2 counts", pluralize(2, "count"))
61
+ end
62
+ end
@@ -0,0 +1,35 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/url_helper'
3
+ require File.dirname(__FILE__) + '/../../lib/action_view/helpers/tag_helper'
4
+
5
+ class UrlHelperTest < Test::Unit::TestCase
6
+ include ActionView::Helpers::UrlHelper
7
+ include ActionView::Helpers::TagHelper
8
+
9
+ def setup
10
+ @controller = Class.new do
11
+ def url_for(options, *parameters_for_method_reference)
12
+ "http://www.world.com"
13
+ end
14
+ end
15
+ @controller = @controller.new
16
+ end
17
+
18
+ # todo: missing test cases
19
+ def test_link_tag_with_straight_url
20
+ assert "<a href=\"http://www.world.com\">Hello</a>", link_to("Hello", "http://www.world.com")
21
+ end
22
+
23
+ def test_link_tag_with_javascript_confirm
24
+ assert(
25
+ "<a href=\"http://www.world.com\" onClick=\"return confirm('Are you sure?')\">Hello</a>",
26
+ link_to("Hello", "http://www.world.com", :confirm => "Are you sure?")
27
+ )
28
+ end
29
+
30
+ def test_link_unless_current
31
+ @params = { "controller" => "weblog", "action" => "show"}
32
+ assert "<b>Showing</b>", link_to_unless_current("Showing", :action => "show", :controller => "weblog")
33
+ assert "<a href=\"http://www.world.com\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog")
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.1
3
+ specification_version: 1
4
+ name: actionpack
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.9.0
7
+ date: 2004-10-25
8
+ summary: Web-flow and rendering framework putting the VC in MVC.
9
+ require_paths:
10
+ - lib
11
+ author: David Heinemeier Hansson
12
+ email: david@loudthinking.com
13
+ homepage: http://actionpack.rubyonrails.org
14
+ rubyforge_project: actionpack
15
+ description: "Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser."
16
+ autorequire: action_controller
17
+ default_executable:
18
+ bindir: bin
19
+ has_rdoc: true
20
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
21
+ requirements:
22
+ -
23
+ - ">"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.0.0
26
+ version:
27
+ platform: ruby
28
+ files:
29
+ - rakefile
30
+ - install.rb
31
+ - README
32
+ - RUNNING_UNIT_TESTS
33
+ - CHANGELOG
34
+ - MIT-LICENSE
35
+ - examples/.htaccess
36
+ - lib/action_controller
37
+ - lib/action_controller.rb
38
+ - lib/action_view
39
+ - lib/action_view.rb
40
+ - lib/action_controller/assertions
41
+ - lib/action_controller/base.rb
42
+ - lib/action_controller/benchmarking.rb
43
+ - lib/action_controller/cgi_ext
44
+ - lib/action_controller/cgi_process.rb
45
+ - lib/action_controller/filters.rb
46
+ - lib/action_controller/flash.rb
47
+ - lib/action_controller/layout.rb
48
+ - lib/action_controller/request.rb
49
+ - lib/action_controller/rescue.rb
50
+ - lib/action_controller/response.rb
51
+ - lib/action_controller/scaffolding.rb
52
+ - lib/action_controller/session
53
+ - lib/action_controller/support
54
+ - lib/action_controller/templates
55
+ - lib/action_controller/test_process.rb
56
+ - lib/action_controller/url_rewriter.rb
57
+ - lib/action_controller/assertions/action_pack_assertions.rb
58
+ - lib/action_controller/assertions/active_record_assertions.rb
59
+ - lib/action_controller/cgi_ext/cgi_ext.rb
60
+ - lib/action_controller/cgi_ext/cgi_methods.rb
61
+ - lib/action_controller/session/active_record_store.rb
62
+ - lib/action_controller/session/drb_server.rb
63
+ - lib/action_controller/session/drb_store.rb
64
+ - lib/action_controller/support/class_attribute_accessors.rb
65
+ - lib/action_controller/support/class_inheritable_attributes.rb
66
+ - lib/action_controller/support/clean_logger.rb
67
+ - lib/action_controller/support/cookie_performance_fix.rb
68
+ - lib/action_controller/support/inflector.rb
69
+ - lib/action_controller/templates/rescues
70
+ - lib/action_controller/templates/scaffolds
71
+ - lib/action_controller/templates/rescues/_request_and_response.rhtml
72
+ - lib/action_controller/templates/rescues/diagnostics.rhtml
73
+ - lib/action_controller/templates/rescues/layout.rhtml
74
+ - lib/action_controller/templates/rescues/missing_template.rhtml
75
+ - lib/action_controller/templates/rescues/template_error.rhtml
76
+ - lib/action_controller/templates/rescues/unknown_action.rhtml
77
+ - lib/action_controller/templates/scaffolds/edit.rhtml
78
+ - lib/action_controller/templates/scaffolds/layout.rhtml
79
+ - lib/action_controller/templates/scaffolds/list.rhtml
80
+ - lib/action_controller/templates/scaffolds/new.rhtml
81
+ - lib/action_controller/templates/scaffolds/show.rhtml
82
+ - lib/action_view/base.rb
83
+ - lib/action_view/helpers
84
+ - lib/action_view/partials.rb
85
+ - lib/action_view/template_error.rb
86
+ - lib/action_view/vendor
87
+ - lib/action_view/helpers/active_record_helper.rb
88
+ - lib/action_view/helpers/date_helper.rb
89
+ - lib/action_view/helpers/debug_helper.rb
90
+ - lib/action_view/helpers/form_helper.rb
91
+ - lib/action_view/helpers/form_options_helper.rb
92
+ - lib/action_view/helpers/tag_helper.rb
93
+ - lib/action_view/helpers/text_helper.rb
94
+ - lib/action_view/helpers/url_helper.rb
95
+ - lib/action_view/vendor/builder
96
+ - lib/action_view/vendor/builder.rb
97
+ - lib/action_view/vendor/builder/blankslate.rb
98
+ - lib/action_view/vendor/builder/xmlbase.rb
99
+ - lib/action_view/vendor/builder/xmlevents.rb
100
+ - lib/action_view/vendor/builder/xmlmarkup.rb
101
+ - test/abstract_unit.rb
102
+ - test/controller
103
+ - test/fixtures
104
+ - test/template
105
+ - test/controller/action_pack_assertions_test.rb
106
+ - test/controller/active_record_assertions_test.rb
107
+ - test/controller/cgi_test.rb
108
+ - test/controller/cookie_test.rb
109
+ - test/controller/filters_test.rb
110
+ - test/controller/flash_test.rb
111
+ - test/controller/layout_test.rb
112
+ - test/controller/redirect_test.rb
113
+ - test/controller/render_test.rb
114
+ - test/controller/url_test.rb
115
+ - test/fixtures/layouts
116
+ - test/fixtures/test
117
+ - test/fixtures/layouts/builder.rxml
118
+ - test/fixtures/layouts/standard.rhtml
119
+ - test/fixtures/test/_customer.rhtml
120
+ - test/fixtures/test/greeting.rhtml
121
+ - test/fixtures/test/hello.rxml
122
+ - test/fixtures/test/hello_world.rhtml
123
+ - test/fixtures/test/hello_xml_world.rxml
124
+ - test/fixtures/test/list.rhtml
125
+ - test/template/active_record_helper_test.rb
126
+ - test/template/date_helper_test.rb
127
+ - test/template/form_helper_test.rb
128
+ - test/template/form_options_helper_test.rb
129
+ - test/template/tag_helper_test.rb
130
+ - test/template/text_helper_test.rb
131
+ - test/template/url_helper_test.rb
132
+ - examples/address_book
133
+ - examples/address_book_controller.cgi
134
+ - examples/address_book_controller.fcgi
135
+ - examples/address_book_controller.rb
136
+ - examples/address_book_controller.rbx
137
+ - examples/benchmark.rb
138
+ - examples/benchmark_with_ar.fcgi
139
+ - examples/blog_controller.cgi
140
+ - examples/debate
141
+ - examples/debate_controller.cgi
142
+ - examples/address_book/index.rhtml
143
+ - examples/address_book/layout.rhtml
144
+ - examples/debate/index.rhtml
145
+ - examples/debate/new_topic.rhtml
146
+ - examples/debate/topic.rhtml
147
+ test_files: []
148
+ rdoc_options: []
149
+ extra_rdoc_files: []
150
+ executables: []
151
+ extensions: []
152
+ requirements:
153
+ - none
154
+ dependencies: []