actionpack 2.0.5 → 2.1.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 (210) hide show
  1. data/CHANGELOG +149 -7
  2. data/MIT-LICENSE +1 -1
  3. data/README +1 -1
  4. data/Rakefile +5 -6
  5. data/lib/action_controller.rb +2 -2
  6. data/lib/action_controller/assertions/model_assertions.rb +2 -1
  7. data/lib/action_controller/assertions/response_assertions.rb +4 -2
  8. data/lib/action_controller/assertions/routing_assertions.rb +3 -3
  9. data/lib/action_controller/assertions/selector_assertions.rb +30 -27
  10. data/lib/action_controller/assertions/tag_assertions.rb +3 -3
  11. data/lib/action_controller/base.rb +103 -129
  12. data/lib/action_controller/benchmarking.rb +3 -3
  13. data/lib/action_controller/caching.rb +41 -652
  14. data/lib/action_controller/caching/actions.rb +144 -0
  15. data/lib/action_controller/caching/fragments.rb +138 -0
  16. data/lib/action_controller/caching/pages.rb +154 -0
  17. data/lib/action_controller/caching/sql_cache.rb +18 -0
  18. data/lib/action_controller/caching/sweeping.rb +97 -0
  19. data/lib/action_controller/cgi_ext/cookie.rb +27 -23
  20. data/lib/action_controller/cgi_ext/stdinput.rb +1 -0
  21. data/lib/action_controller/cgi_process.rb +6 -4
  22. data/lib/action_controller/components.rb +7 -6
  23. data/lib/action_controller/cookies.rb +31 -19
  24. data/lib/action_controller/dispatcher.rb +51 -84
  25. data/lib/action_controller/filters.rb +295 -421
  26. data/lib/action_controller/flash.rb +1 -6
  27. data/lib/action_controller/headers.rb +31 -0
  28. data/lib/action_controller/helpers.rb +26 -9
  29. data/lib/action_controller/http_authentication.rb +1 -1
  30. data/lib/action_controller/integration.rb +65 -13
  31. data/lib/action_controller/layout.rb +24 -39
  32. data/lib/action_controller/mime_responds.rb +7 -3
  33. data/lib/action_controller/mime_type.rb +25 -9
  34. data/lib/action_controller/mime_types.rb +1 -1
  35. data/lib/action_controller/polymorphic_routes.rb +32 -17
  36. data/lib/action_controller/record_identifier.rb +10 -4
  37. data/lib/action_controller/request.rb +46 -30
  38. data/lib/action_controller/request_forgery_protection.rb +10 -9
  39. data/lib/action_controller/request_profiler.rb +29 -8
  40. data/lib/action_controller/rescue.rb +24 -24
  41. data/lib/action_controller/resources.rb +66 -23
  42. data/lib/action_controller/response.rb +2 -2
  43. data/lib/action_controller/routing.rb +113 -1229
  44. data/lib/action_controller/routing/builder.rb +204 -0
  45. data/lib/action_controller/{routing_optimisation.rb → routing/optimisations.rb} +13 -12
  46. data/lib/action_controller/routing/recognition_optimisation.rb +158 -0
  47. data/lib/action_controller/routing/route.rb +240 -0
  48. data/lib/action_controller/routing/route_set.rb +435 -0
  49. data/lib/action_controller/routing/routing_ext.rb +46 -0
  50. data/lib/action_controller/routing/segments.rb +283 -0
  51. data/lib/action_controller/session/active_record_store.rb +13 -8
  52. data/lib/action_controller/session/cookie_store.rb +20 -17
  53. data/lib/action_controller/session_management.rb +10 -3
  54. data/lib/action_controller/streaming.rb +45 -31
  55. data/lib/action_controller/test_case.rb +33 -23
  56. data/lib/action_controller/test_process.rb +39 -35
  57. data/lib/action_controller/url_rewriter.rb +18 -12
  58. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +1 -1
  59. data/lib/action_pack.rb +1 -1
  60. data/lib/action_pack/version.rb +2 -2
  61. data/lib/action_view.rb +11 -3
  62. data/lib/action_view/base.rb +73 -390
  63. data/lib/action_view/helpers/active_record_helper.rb +83 -62
  64. data/lib/action_view/helpers/asset_tag_helper.rb +101 -44
  65. data/lib/action_view/helpers/atom_feed_helper.rb +35 -7
  66. data/lib/action_view/helpers/benchmark_helper.rb +5 -3
  67. data/lib/action_view/helpers/cache_helper.rb +3 -2
  68. data/lib/action_view/helpers/capture_helper.rb +1 -2
  69. data/lib/action_view/helpers/date_helper.rb +104 -82
  70. data/lib/action_view/helpers/form_helper.rb +148 -75
  71. data/lib/action_view/helpers/form_options_helper.rb +44 -23
  72. data/lib/action_view/helpers/form_tag_helper.rb +22 -13
  73. data/lib/action_view/helpers/javascripts/controls.js +1 -1
  74. data/lib/action_view/helpers/javascripts/dragdrop.js +1 -1
  75. data/lib/action_view/helpers/javascripts/effects.js +1 -1
  76. data/lib/action_view/helpers/number_helper.rb +10 -3
  77. data/lib/action_view/helpers/prototype_helper.rb +61 -29
  78. data/lib/action_view/helpers/record_tag_helper.rb +3 -3
  79. data/lib/action_view/helpers/sanitize_helper.rb +23 -17
  80. data/lib/action_view/helpers/scriptaculous_helper.rb +86 -60
  81. data/lib/action_view/helpers/text_helper.rb +153 -125
  82. data/lib/action_view/helpers/url_helper.rb +83 -28
  83. data/lib/action_view/inline_template.rb +20 -0
  84. data/lib/action_view/partial_template.rb +70 -0
  85. data/lib/action_view/partials.rb +31 -73
  86. data/lib/action_view/template.rb +127 -0
  87. data/lib/action_view/template_error.rb +8 -7
  88. data/lib/action_view/template_finder.rb +177 -0
  89. data/lib/action_view/template_handler.rb +18 -1
  90. data/lib/action_view/template_handlers/builder.rb +10 -2
  91. data/lib/action_view/template_handlers/compilable.rb +128 -0
  92. data/lib/action_view/template_handlers/erb.rb +37 -2
  93. data/lib/action_view/template_handlers/rjs.rb +14 -1
  94. data/lib/action_view/test_case.rb +58 -0
  95. data/test/abstract_unit.rb +1 -1
  96. data/test/active_record_unit.rb +3 -6
  97. data/test/activerecord/active_record_store_test.rb +1 -2
  98. data/test/activerecord/render_partial_with_record_identification_test.rb +158 -41
  99. data/test/adv_attr_test.rb +20 -0
  100. data/test/controller/action_pack_assertions_test.rb +16 -19
  101. data/test/controller/addresses_render_test.rb +1 -1
  102. data/test/controller/assert_select_test.rb +13 -6
  103. data/test/controller/base_test.rb +48 -2
  104. data/test/controller/benchmark_test.rb +1 -2
  105. data/test/controller/caching_test.rb +282 -21
  106. data/test/controller/capture_test.rb +1 -1
  107. data/test/controller/cgi_test.rb +1 -1
  108. data/test/controller/components_test.rb +1 -1
  109. data/test/controller/content_type_test.rb +2 -2
  110. data/test/controller/cookie_test.rb +13 -2
  111. data/test/controller/custom_handler_test.rb +14 -10
  112. data/test/controller/deprecation/deprecated_base_methods_test.rb +1 -1
  113. data/test/controller/dispatcher_test.rb +31 -49
  114. data/test/controller/fake_controllers.rb +17 -0
  115. data/test/controller/fake_models.rb +6 -0
  116. data/test/controller/filter_params_test.rb +14 -8
  117. data/test/controller/filters_test.rb +44 -16
  118. data/test/controller/flash_test.rb +2 -2
  119. data/test/controller/header_test.rb +14 -0
  120. data/test/controller/helper_test.rb +19 -15
  121. data/test/controller/html-scanner/document_test.rb +1 -2
  122. data/test/controller/html-scanner/node_test.rb +1 -2
  123. data/test/controller/html-scanner/sanitizer_test.rb +8 -5
  124. data/test/controller/html-scanner/tag_node_test.rb +1 -2
  125. data/test/controller/html-scanner/text_node_test.rb +2 -3
  126. data/test/controller/html-scanner/tokenizer_test.rb +8 -2
  127. data/test/controller/http_authentication_test.rb +1 -1
  128. data/test/controller/integration_test.rb +14 -16
  129. data/test/controller/integration_upload_test.rb +43 -0
  130. data/test/controller/layout_test.rb +26 -6
  131. data/test/controller/mime_responds_test.rb +39 -7
  132. data/test/controller/mime_type_test.rb +29 -5
  133. data/test/controller/new_render_test.rb +105 -34
  134. data/test/controller/polymorphic_routes_test.rb +32 -20
  135. data/test/controller/record_identifier_test.rb +38 -2
  136. data/test/controller/redirect_test.rb +21 -1
  137. data/test/controller/render_test.rb +59 -15
  138. data/test/controller/request_forgery_protection_test.rb +92 -5
  139. data/test/controller/request_test.rb +64 -6
  140. data/test/controller/rescue_test.rb +22 -6
  141. data/test/controller/resources_test.rb +102 -14
  142. data/test/controller/routing_test.rb +231 -19
  143. data/test/controller/selector_test.rb +2 -2
  144. data/test/controller/send_file_test.rb +14 -3
  145. data/test/controller/session/cookie_store_test.rb +16 -4
  146. data/test/controller/session/mem_cache_store_test.rb +3 -4
  147. data/test/controller/session_fixation_test.rb +1 -1
  148. data/test/controller/session_management_test.rb +23 -1
  149. data/test/controller/test_test.rb +39 -18
  150. data/test/controller/url_rewriter_test.rb +35 -1
  151. data/test/controller/verification_test.rb +1 -1
  152. data/test/controller/view_paths_test.rb +15 -12
  153. data/test/controller/webservice_test.rb +48 -3
  154. data/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
  155. data/test/fixtures/company.rb +1 -0
  156. data/test/fixtures/customers/_customer.html.erb +1 -0
  157. data/test/fixtures/db_definitions/sqlite.sql +6 -0
  158. data/test/fixtures/functional_caching/_partial.erb +3 -0
  159. data/test/fixtures/functional_caching/fragment_cached.html.erb +2 -0
  160. data/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
  161. data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +1 -0
  162. data/test/fixtures/good_customers/_good_customer.html.erb +1 -0
  163. data/test/fixtures/mascot.rb +3 -0
  164. data/test/fixtures/mascots.yml +4 -0
  165. data/test/fixtures/mascots/_mascot.html.erb +1 -0
  166. data/test/fixtures/multipart/boundary_problem_file +10 -0
  167. data/test/fixtures/public/javascripts/application.js +1 -0
  168. data/test/fixtures/public/javascripts/controls.js +1 -0
  169. data/test/fixtures/public/javascripts/dragdrop.js +1 -0
  170. data/test/fixtures/public/javascripts/effects.js +1 -0
  171. data/test/fixtures/public/javascripts/prototype.js +1 -0
  172. data/test/fixtures/public/javascripts/version.1.0.js +1 -0
  173. data/test/fixtures/public/stylesheets/version.1.0.css +1 -0
  174. data/test/fixtures/reply.rb +1 -0
  175. data/test/fixtures/shared.html.erb +1 -0
  176. data/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
  177. data/test/fixtures/test/_customer_counter.erb +1 -0
  178. data/test/fixtures/test/_form.erb +1 -0
  179. data/test/fixtures/test/_labelling_form.erb +1 -0
  180. data/test/fixtures/test/_raise.html.erb +1 -0
  181. data/test/fixtures/test/greeting.js.rjs +1 -0
  182. data/test/fixtures/topics/_topic.html.erb +1 -0
  183. data/test/template/active_record_helper_test.rb +25 -8
  184. data/test/template/asset_tag_helper_test.rb +100 -17
  185. data/test/template/atom_feed_helper_test.rb +29 -1
  186. data/test/template/benchmark_helper_test.rb +10 -22
  187. data/test/template/date_helper_test.rb +455 -153
  188. data/test/template/erb_util_test.rb +10 -42
  189. data/test/template/form_helper_test.rb +192 -66
  190. data/test/template/form_options_helper_test.rb +19 -8
  191. data/test/template/form_tag_helper_test.rb +11 -8
  192. data/test/template/javascript_helper_test.rb +3 -9
  193. data/test/template/number_helper_test.rb +6 -3
  194. data/test/template/prototype_helper_test.rb +27 -40
  195. data/test/template/record_tag_helper_test.rb +54 -0
  196. data/test/template/sanitize_helper_test.rb +5 -6
  197. data/test/template/scriptaculous_helper_test.rb +7 -13
  198. data/test/template/tag_helper_test.rb +3 -6
  199. data/test/template/template_finder_test.rb +73 -0
  200. data/test/template/template_object_test.rb +95 -0
  201. data/test/template/test_test.rb +56 -0
  202. data/test/template/text_helper_test.rb +46 -33
  203. data/test/template/url_helper_test.rb +8 -10
  204. metadata +65 -12
  205. data/lib/action_view/compiled_templates.rb +0 -69
  206. data/test/action_view_test.rb +0 -44
  207. data/test/activerecord/fixtures_test.rb +0 -24
  208. data/test/controller/fragment_store_setting_test.rb +0 -47
  209. data/test/template/compiled_templates_test.rb +0 -197
  210. data/test/template/deprecate_ivars_test.rb +0 -51
@@ -0,0 +1,95 @@
1
+ require 'abstract_unit'
2
+
3
+ class TemplateObjectTest < Test::Unit::TestCase
4
+ LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures')
5
+ ActionView::TemplateFinder.process_view_paths(LOAD_PATH_ROOT)
6
+
7
+ class TemplateTest < Test::Unit::TestCase
8
+ def setup
9
+ @view = ActionView::Base.new(LOAD_PATH_ROOT)
10
+ @path = "test/hello_world.erb"
11
+ end
12
+
13
+ def test_should_create_valid_template
14
+ template = ActionView::Template.new(@view, @path, true)
15
+
16
+ assert_kind_of ActionView::TemplateHandlers::ERB, template.handler
17
+ assert_equal "test/hello_world.erb", template.path
18
+ assert_nil template.instance_variable_get(:"@source")
19
+ assert_equal "erb", template.extension
20
+ end
21
+
22
+ uses_mocha 'Template preparation tests' do
23
+
24
+ def test_should_prepare_template_properly
25
+ template = ActionView::Template.new(@view, @path, true)
26
+ view = template.instance_variable_get(:"@view")
27
+
28
+ view.expects(:evaluate_assigns)
29
+ template.handler.expects(:compile_template).with(template)
30
+ view.expects(:method_names).returns({})
31
+
32
+ template.prepare!
33
+ end
34
+
35
+ end
36
+ end
37
+
38
+ class PartialTemplateTest < Test::Unit::TestCase
39
+ def setup
40
+ @view = ActionView::Base.new(LOAD_PATH_ROOT)
41
+ @path = "test/partial_only"
42
+ end
43
+
44
+ def test_should_create_valid_partial_template
45
+ template = ActionView::PartialTemplate.new(@view, @path, nil)
46
+
47
+ assert_equal "test/_partial_only", template.path
48
+ assert_equal :partial_only, template.variable_name
49
+
50
+ assert template.locals.has_key?(:object)
51
+ assert template.locals.has_key?(:partial_only)
52
+ end
53
+
54
+ def test_partial_with_errors
55
+ template = ActionView::PartialTemplate.new(@view, 'test/raise', nil)
56
+ assert_raise(ActionView::TemplateError) { template.render_template }
57
+ end
58
+
59
+ uses_mocha 'Partial template preparation tests' do
60
+ def test_should_prepare_on_initialization
61
+ ActionView::PartialTemplate.any_instance.expects(:prepare!)
62
+ template = ActionView::PartialTemplate.new(@view, @path, 1)
63
+ end
64
+ end
65
+ end
66
+
67
+ class PartialTemplateFallbackTest < Test::Unit::TestCase
68
+ def setup
69
+ @view = ActionView::Base.new(LOAD_PATH_ROOT)
70
+ @path = 'test/layout_for_partial'
71
+ end
72
+
73
+ def test_default
74
+ template = ActionView::PartialTemplate.new(@view, @path, nil)
75
+ assert_equal 'test/_layout_for_partial', template.path
76
+ assert_equal 'erb', template.extension
77
+ assert_equal :html, @view.template_format
78
+ end
79
+
80
+ def test_js
81
+ @view.template_format = :js
82
+ template = ActionView::PartialTemplate.new(@view, @path, nil)
83
+ assert_equal 'test/_layout_for_partial', template.path
84
+ assert_equal 'erb', template.extension
85
+ assert_equal :html, @view.template_format
86
+ end
87
+
88
+ def test_xml
89
+ @view.template_format = :xml
90
+ assert_raise ActionView::MissingTemplate do
91
+ ActionView::PartialTemplate.new(@view, @path, nil)
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,56 @@
1
+ require 'abstract_unit'
2
+
3
+ module PeopleHelper
4
+ def title(text)
5
+ content_tag(:h1, text)
6
+ end
7
+
8
+ def homepage_path
9
+ people_path
10
+ end
11
+
12
+ def homepage_url
13
+ people_url
14
+ end
15
+
16
+ def link_to_person(person)
17
+ link_to person.name, person
18
+ end
19
+ end
20
+
21
+ class PeopleHelperTest < ActionView::TestCase
22
+ def setup
23
+ ActionController::Routing::Routes.draw do |map|
24
+ map.people 'people', :controller => 'people', :action => 'index'
25
+ map.connect ':controller/:action/:id'
26
+ end
27
+ end
28
+
29
+ def test_title
30
+ assert_equal "<h1>Ruby on Rails</h1>", title("Ruby on Rails")
31
+ end
32
+
33
+ def test_homepage_path
34
+ assert_equal "/people", homepage_path
35
+ end
36
+
37
+ def test_homepage_url
38
+ assert_equal "http://test.host/people", homepage_url
39
+ end
40
+
41
+ uses_mocha "link_to_person" do
42
+ def test_link_to_person
43
+ person = mock(:name => "David")
44
+ expects(:mocha_mock_path).with(person).returns("/people/1")
45
+ assert_equal '<a href="/people/1">David</a>', link_to_person(person)
46
+ end
47
+ end
48
+ end
49
+
50
+ class CrazyHelperTest < ActionView::TestCase
51
+ tests PeopleHelper
52
+
53
+ def test_helper_class_can_be_set_manually_not_just_inferred
54
+ assert_equal PeopleHelper, self.class.helper_class
55
+ end
56
+ end
@@ -1,9 +1,8 @@
1
1
  require 'abstract_unit'
2
2
  require 'testing_sandbox'
3
3
 
4
- class TextHelperTest < Test::Unit::TestCase
5
- include ActionView::Helpers::TextHelper
6
- include ActionView::Helpers::TagHelper
4
+ class TextHelperTest < ActionView::TestCase
5
+ tests ActionView::Helpers::TextHelper
7
6
  include TestingSandbox
8
7
 
9
8
  def setup
@@ -24,6 +23,9 @@ class TextHelperTest < Test::Unit::TestCase
24
23
 
25
24
  text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze
26
25
  assert_equal "<p>A\n<br /> \n<br />B</p>\n\n<p>\t\n<br />C\n<br />D</p>", simple_format(text)
26
+
27
+ assert_equal %q(<p class="test">This is a classy test</p>), simple_format("This is a classy test", :class => 'test')
28
+ assert_equal %Q(<p class="test">para 1</p>\n\n<p class="test">para 2</p>), simple_format("para 1\n\npara 2", :class => 'test')
27
29
  end
28
30
 
29
31
  def test_truncate
@@ -39,7 +41,7 @@ class TextHelperTest < Test::Unit::TestCase
39
41
  if RUBY_VERSION < '1.9.0'
40
42
  def test_truncate_multibyte
41
43
  with_kcode 'none' do
42
- assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
44
+ assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
43
45
  end
44
46
  with_kcode 'u' do
45
47
  assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...",
@@ -71,7 +73,7 @@ class TextHelperTest < Test::Unit::TestCase
71
73
  "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day",
72
74
  highlight("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\1</b>')
73
75
  )
74
-
76
+
75
77
  assert_equal(
76
78
  "This text is not changed because we supplied an empty phrase",
77
79
  highlight("This text is not changed because we supplied an empty phrase", nil)
@@ -102,30 +104,47 @@ class TextHelperTest < Test::Unit::TestCase
102
104
  end
103
105
 
104
106
  def test_excerpt
105
- assert_equal("...is a beautiful morni...", excerpt("This is a beautiful morning", "beautiful", 5))
107
+ assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", 5))
106
108
  assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5))
107
109
  assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5))
108
110
  assert_nil excerpt("This is a beautiful morning", "day")
109
111
  end
110
112
 
113
+ def test_excerpt_in_borderline_cases
114
+ assert_equal("", excerpt("", "", 0))
115
+ assert_equal("a", excerpt("a", "a", 0))
116
+ assert_equal("...b...", excerpt("abc", "b", 0))
117
+ assert_equal("abc", excerpt("abc", "b", 1))
118
+ assert_equal("abc...", excerpt("abcd", "b", 1))
119
+ assert_equal("...abc", excerpt("zabc", "b", 1))
120
+ assert_equal("...abc...", excerpt("zabcd", "b", 1))
121
+ assert_equal("zabcd", excerpt("zabcd", "b", 2))
122
+
123
+ # excerpt strips the resulting string before ap-/prepending excerpt_string.
124
+ # whether this behavior is meaningful when excerpt_string is not to be
125
+ # appended is questionable.
126
+ assert_equal("zabcd", excerpt(" zabcd ", "b", 4))
127
+ assert_equal("...abc...", excerpt("z abc d", "b", 1))
128
+ end
129
+
111
130
  def test_excerpt_with_regex
112
- assert_equal('...is a beautiful! morn...', excerpt('This is a beautiful! morning', 'beautiful', 5))
113
- assert_equal('...is a beautiful? morn...', excerpt('This is a beautiful? morning', 'beautiful', 5))
131
+ assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', 5))
132
+ assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', 5))
114
133
  end
115
134
 
116
135
  if RUBY_VERSION < '1.9'
117
136
  def test_excerpt_with_utf8
118
137
  with_kcode('u') do
119
- assert_equal("...fficiency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
138
+ assert_equal("...\357\254\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8))
120
139
  end
121
140
  with_kcode('none') do
122
- assert_equal("...\203ciency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
141
+ assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8))
123
142
  end
124
143
  end
125
144
  else
126
145
  def test_excerpt_with_utf8
127
- assert_equal("...fficiency could not be h...".force_encoding('UTF-8'), excerpt("That's why efficiency could not be helped".force_encoding('UTF-8'), 'could', 8))
128
- assert_equal("...\203ciency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
146
+ assert_equal("...\357\254\203ciency could not be...".force_encoding('UTF-8'), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding('UTF-8'), 'could', 8))
147
+ assert_equal("...\203ciency could not be...", excerpt("That's why e\357\254\203ciency could not be helped", 'could', 8))
129
148
  end
130
149
  end
131
150
 
@@ -147,18 +166,9 @@ class TextHelperTest < Test::Unit::TestCase
147
166
  assert_equal("2 counters", pluralize(2, "count", "counters"))
148
167
  assert_equal("0 counters", pluralize(nil, "count", "counters"))
149
168
  assert_equal("2 people", pluralize(2, "person"))
150
- assert_equal("10 buffaloes", pluralize(10, "buffalo"))
151
- end
152
-
153
- uses_mocha("should_just_add_s_for_pluralize_without_inflector_loaded") do
154
- def test_should_just_add_s_for_pluralize_without_inflector_loaded
155
- Object.expects(:const_defined?).with("Inflector").times(4).returns(false)
156
- assert_equal("1 count", pluralize(1, "count"))
157
- assert_equal("2 persons", pluralize(2, "person"))
158
- assert_equal("2 personss", pluralize("2", "persons"))
159
- assert_equal("2 counts", pluralize(2, "count"))
160
- assert_equal("10 buffalos", pluralize(10, "buffalo"))
161
- end
169
+ assert_equal("10 buffaloes", pluralize(10, "buffalo"))
170
+ assert_equal("1 berry", pluralize(1, "berry"))
171
+ assert_equal("12 berries", pluralize(12, "berry"))
162
172
  end
163
173
 
164
174
  def test_auto_link_parsing
@@ -176,6 +186,7 @@ class TextHelperTest < Test::Unit::TestCase
176
186
  http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
177
187
  http://www.mail-archive.com/rails@lists.rubyonrails.org/
178
188
  http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1
189
+ http://en.wikipedia.org/wiki/Sprite_(computer_graphics)
179
190
  )
180
191
 
181
192
  urls.each do |url|
@@ -252,6 +263,8 @@ class TextHelperTest < Test::Unit::TestCase
252
263
  assert_equal email2_result, auto_link(email2_raw)
253
264
  assert_equal '', auto_link(nil)
254
265
  assert_equal '', auto_link('')
266
+ assert_equal "#{link_result} #{link_result} #{link_result}", auto_link("#{link_raw} #{link_raw} #{link_raw}")
267
+ assert_equal '<a href="http://www.rubyonrails.com">Ruby On Rails</a>', auto_link('<a href="http://www.rubyonrails.com">Ruby On Rails</a>')
255
268
  end
256
269
 
257
270
  def test_auto_link_at_eol
@@ -279,7 +292,7 @@ class TextHelperTest < Test::Unit::TestCase
279
292
  assert_equal("2", value.to_s)
280
293
  assert_equal("3", value.to_s)
281
294
  end
282
-
295
+
283
296
  def test_cycle_class_with_no_arguments
284
297
  assert_raise(ArgumentError) { value = Cycle.new() }
285
298
  end
@@ -292,11 +305,11 @@ class TextHelperTest < Test::Unit::TestCase
292
305
  assert_equal("2", cycle("one", 2, "3"))
293
306
  assert_equal("3", cycle("one", 2, "3"))
294
307
  end
295
-
308
+
296
309
  def test_cycle_with_no_arguments
297
310
  assert_raise(ArgumentError) { value = cycle() }
298
311
  end
299
-
312
+
300
313
  def test_cycle_resets_with_new_values
301
314
  assert_equal("even", cycle("even", "odd"))
302
315
  assert_equal("odd", cycle("even", "odd"))
@@ -306,7 +319,7 @@ class TextHelperTest < Test::Unit::TestCase
306
319
  assert_equal("3", cycle(1, 2, 3))
307
320
  assert_equal("1", cycle(1, 2, 3))
308
321
  end
309
-
322
+
310
323
  def test_named_cycles
311
324
  assert_equal("1", cycle(1, 2, 3, :name => "numbers"))
312
325
  assert_equal("red", cycle("red", "blue", :name => "colors"))
@@ -315,24 +328,24 @@ class TextHelperTest < Test::Unit::TestCase
315
328
  assert_equal("3", cycle(1, 2, 3, :name => "numbers"))
316
329
  assert_equal("red", cycle("red", "blue", :name => "colors"))
317
330
  end
318
-
331
+
319
332
  def test_default_named_cycle
320
333
  assert_equal("1", cycle(1, 2, 3))
321
334
  assert_equal("2", cycle(1, 2, 3, :name => "default"))
322
335
  assert_equal("3", cycle(1, 2, 3))
323
336
  end
324
-
337
+
325
338
  def test_reset_cycle
326
339
  assert_equal("1", cycle(1, 2, 3))
327
340
  assert_equal("2", cycle(1, 2, 3))
328
341
  reset_cycle
329
342
  assert_equal("1", cycle(1, 2, 3))
330
343
  end
331
-
344
+
332
345
  def test_reset_unknown_cycle
333
346
  reset_cycle("colors")
334
347
  end
335
-
348
+
336
349
  def test_recet_named_cycle
337
350
  assert_equal("1", cycle(1, 2, 3, :name => "numbers"))
338
351
  assert_equal("red", cycle("red", "blue", :name => "colors"))
@@ -342,7 +355,7 @@ class TextHelperTest < Test::Unit::TestCase
342
355
  assert_equal("2", cycle(1, 2, 3, :name => "numbers"))
343
356
  assert_equal("red", cycle("red", "blue", :name => "colors"))
344
357
  end
345
-
358
+
346
359
  def test_cycle_no_instance_variable_clashes
347
360
  @cycles = %w{Specialized Fuji Giant}
348
361
  assert_equal("red", cycle("red", "blue"))
@@ -2,10 +2,8 @@ require 'abstract_unit'
2
2
 
3
3
  RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env)
4
4
 
5
- class UrlHelperTest < Test::Unit::TestCase
6
- include ActionView::Helpers::AssetTagHelper
7
- include ActionView::Helpers::UrlHelper
8
- include ActionView::Helpers::TagHelper
5
+ class UrlHelperTest < ActionView::TestCase
6
+ tests ActionView::Helpers::UrlHelper
9
7
 
10
8
  def setup
11
9
  @controller = Class.new do
@@ -293,7 +291,7 @@ class UrlHelperTest < Test::Unit::TestCase
293
291
  end
294
292
  end
295
293
 
296
- class UrlHelperWithControllerTest < Test::Unit::TestCase
294
+ class UrlHelperWithControllerTest < ActionView::TestCase
297
295
  class UrlHelperController < ActionController::Base
298
296
  self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
299
297
 
@@ -310,7 +308,7 @@ class UrlHelperWithControllerTest < Test::Unit::TestCase
310
308
  def rescue_action(e) raise e end
311
309
  end
312
310
 
313
- include ActionView::Helpers::UrlHelper
311
+ tests ActionView::Helpers::UrlHelper
314
312
 
315
313
  def setup
316
314
  @request = ActionController::TestRequest.new
@@ -348,7 +346,7 @@ class UrlHelperWithControllerTest < Test::Unit::TestCase
348
346
  end
349
347
  end
350
348
 
351
- class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
349
+ class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
352
350
  class TasksController < ActionController::Base
353
351
  self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
354
352
 
@@ -372,7 +370,7 @@ class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
372
370
  end
373
371
  end
374
372
 
375
- include ActionView::Helpers::UrlHelper
373
+ tests ActionView::Helpers::UrlHelper
376
374
 
377
375
  def setup
378
376
  @request = ActionController::TestRequest.new
@@ -440,7 +438,7 @@ class Session
440
438
  end
441
439
  end
442
440
 
443
- class PolymorphicControllerTest < Test::Unit::TestCase
441
+ class PolymorphicControllerTest < ActionView::TestCase
444
442
  class WorkshopsController < ActionController::Base
445
443
  self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
446
444
 
@@ -479,7 +477,7 @@ class PolymorphicControllerTest < Test::Unit::TestCase
479
477
  def rescue_action(e) raise e end
480
478
  end
481
479
 
482
- include ActionView::Helpers::UrlHelper
480
+ tests ActionView::Helpers::UrlHelper
483
481
 
484
482
  def setup
485
483
  @request = ActionController::TestRequest.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,18 +9,17 @@ autorequire: action_controller
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-19 00:00:00 +02:00
12
+ date: 2008-05-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- type: :runtime
18
17
  version_requirement:
19
18
  version_requirements: !ruby/object:Gem::Requirement
20
19
  requirements:
21
20
  - - "="
22
21
  - !ruby/object:Gem::Version
23
- version: 2.0.5
22
+ version: 2.1.0
24
23
  version:
25
24
  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.
26
25
  email: david@loudthinking.com
@@ -48,6 +47,12 @@ files:
48
47
  - lib/action_controller/assertions.rb
49
48
  - lib/action_controller/base.rb
50
49
  - lib/action_controller/benchmarking.rb
50
+ - lib/action_controller/caching
51
+ - lib/action_controller/caching/actions.rb
52
+ - lib/action_controller/caching/fragments.rb
53
+ - lib/action_controller/caching/pages.rb
54
+ - lib/action_controller/caching/sql_cache.rb
55
+ - lib/action_controller/caching/sweeping.rb
51
56
  - lib/action_controller/caching.rb
52
57
  - lib/action_controller/cgi_ext
53
58
  - lib/action_controller/cgi_ext/cookie.rb
@@ -61,6 +66,7 @@ files:
61
66
  - lib/action_controller/dispatcher.rb
62
67
  - lib/action_controller/filters.rb
63
68
  - lib/action_controller/flash.rb
69
+ - lib/action_controller/headers.rb
64
70
  - lib/action_controller/helpers.rb
65
71
  - lib/action_controller/http_authentication.rb
66
72
  - lib/action_controller/integration.rb
@@ -76,8 +82,15 @@ files:
76
82
  - lib/action_controller/rescue.rb
77
83
  - lib/action_controller/resources.rb
78
84
  - lib/action_controller/response.rb
85
+ - lib/action_controller/routing
86
+ - lib/action_controller/routing/builder.rb
87
+ - lib/action_controller/routing/optimisations.rb
88
+ - lib/action_controller/routing/recognition_optimisation.rb
89
+ - lib/action_controller/routing/route.rb
90
+ - lib/action_controller/routing/route_set.rb
91
+ - lib/action_controller/routing/routing_ext.rb
92
+ - lib/action_controller/routing/segments.rb
79
93
  - lib/action_controller/routing.rb
80
- - lib/action_controller/routing_optimisation.rb
81
94
  - lib/action_controller/session
82
95
  - lib/action_controller/session/active_record_store.rb
83
96
  - lib/action_controller/session/cookie_store.rb
@@ -116,7 +129,6 @@ files:
116
129
  - lib/action_pack.rb
117
130
  - lib/action_view
118
131
  - lib/action_view/base.rb
119
- - lib/action_view/compiled_templates.rb
120
132
  - lib/action_view/helpers
121
133
  - lib/action_view/helpers/active_record_helper.rb
122
134
  - lib/action_view/helpers/asset_tag_helper.rb
@@ -144,22 +156,27 @@ files:
144
156
  - lib/action_view/helpers/tag_helper.rb
145
157
  - lib/action_view/helpers/text_helper.rb
146
158
  - lib/action_view/helpers/url_helper.rb
159
+ - lib/action_view/inline_template.rb
160
+ - lib/action_view/partial_template.rb
147
161
  - lib/action_view/partials.rb
162
+ - lib/action_view/template.rb
148
163
  - lib/action_view/template_error.rb
164
+ - lib/action_view/template_finder.rb
149
165
  - lib/action_view/template_handler.rb
150
166
  - lib/action_view/template_handlers
151
167
  - lib/action_view/template_handlers/builder.rb
168
+ - lib/action_view/template_handlers/compilable.rb
152
169
  - lib/action_view/template_handlers/erb.rb
153
170
  - lib/action_view/template_handlers/rjs.rb
171
+ - lib/action_view/test_case.rb
154
172
  - lib/action_view.rb
155
173
  - lib/actionpack.rb
156
174
  - test/abstract_unit.rb
157
- - test/action_view_test.rb
158
175
  - test/active_record_unit.rb
159
176
  - test/activerecord
160
177
  - test/activerecord/active_record_store_test.rb
161
- - test/activerecord/fixtures_test.rb
162
178
  - test/activerecord/render_partial_with_record_identification_test.rb
179
+ - test/adv_attr_test.rb
163
180
  - test/controller
164
181
  - test/controller/action_pack_assertions_test.rb
165
182
  - test/controller/addresses_render_test.rb
@@ -192,7 +209,7 @@ files:
192
209
  - test/controller/filter_params_test.rb
193
210
  - test/controller/filters_test.rb
194
211
  - test/controller/flash_test.rb
195
- - test/controller/fragment_store_setting_test.rb
212
+ - test/controller/header_test.rb
196
213
  - test/controller/helper_test.rb
197
214
  - test/controller/html-scanner
198
215
  - test/controller/html-scanner/document_test.rb
@@ -203,6 +220,7 @@ files:
203
220
  - test/controller/html-scanner/tokenizer_test.rb
204
221
  - test/controller/http_authentication_test.rb
205
222
  - test/controller/integration_test.rb
223
+ - test/controller/integration_upload_test.rb
206
224
  - test/controller/layout_test.rb
207
225
  - test/controller/mime_responds_test.rb
208
226
  - test/controller/mime_type_test.rb
@@ -231,6 +249,8 @@ files:
231
249
  - test/fixtures
232
250
  - test/fixtures/addresses
233
251
  - test/fixtures/addresses/list.erb
252
+ - test/fixtures/bad_customers
253
+ - test/fixtures/bad_customers/_bad_customer.html.erb
234
254
  - test/fixtures/companies.yml
235
255
  - test/fixtures/company.rb
236
256
  - test/fixtures/content_type
@@ -238,6 +258,8 @@ files:
238
258
  - test/fixtures/content_type/render_default_for_rhtml.rhtml
239
259
  - test/fixtures/content_type/render_default_for_rjs.rjs
240
260
  - test/fixtures/content_type/render_default_for_rxml.rxml
261
+ - test/fixtures/customers
262
+ - test/fixtures/customers/_customer.html.erb
241
263
  - test/fixtures/db_definitions
242
264
  - test/fixtures/db_definitions/sqlite.sql
243
265
  - test/fixtures/developer.rb
@@ -246,6 +268,13 @@ files:
246
268
  - test/fixtures/fun
247
269
  - test/fixtures/fun/games
248
270
  - test/fixtures/fun/games/hello_world.erb
271
+ - test/fixtures/functional_caching
272
+ - test/fixtures/functional_caching/_partial.erb
273
+ - test/fixtures/functional_caching/fragment_cached.html.erb
274
+ - test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb
275
+ - test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
276
+ - test/fixtures/good_customers
277
+ - test/fixtures/good_customers/_good_customer.html.erb
249
278
  - test/fixtures/helpers
250
279
  - test/fixtures/helpers/abc_helper.rb
251
280
  - test/fixtures/helpers/fun
@@ -260,6 +289,7 @@ files:
260
289
  - test/fixtures/layout_tests/layouts/item.rhtml
261
290
  - test/fixtures/layout_tests/layouts/layout_test.rhtml
262
291
  - test/fixtures/layout_tests/layouts/multiple_extensions.html.erb
292
+ - test/fixtures/layout_tests/layouts/symlinked
263
293
  - test/fixtures/layout_tests/layouts/third_party_template_library.mab
264
294
  - test/fixtures/layout_tests/views
265
295
  - test/fixtures/layout_tests/views/hello.rhtml
@@ -270,8 +300,13 @@ files:
270
300
  - test/fixtures/layouts/standard.erb
271
301
  - test/fixtures/layouts/talk_from_action.erb
272
302
  - test/fixtures/layouts/yield.erb
303
+ - test/fixtures/mascot.rb
304
+ - test/fixtures/mascots
305
+ - test/fixtures/mascots/_mascot.html.erb
306
+ - test/fixtures/mascots.yml
273
307
  - test/fixtures/multipart
274
308
  - test/fixtures/multipart/binary_file
309
+ - test/fixtures/multipart/boundary_problem_file
275
310
  - test/fixtures/multipart/bracketed_param
276
311
  - test/fixtures/multipart/large_text_file
277
312
  - test/fixtures/multipart/mixed_files
@@ -305,10 +340,16 @@ files:
305
340
  - test/fixtures/public/javascripts
306
341
  - test/fixtures/public/javascripts/application.js
307
342
  - test/fixtures/public/javascripts/bank.js
343
+ - test/fixtures/public/javascripts/controls.js
344
+ - test/fixtures/public/javascripts/dragdrop.js
345
+ - test/fixtures/public/javascripts/effects.js
346
+ - test/fixtures/public/javascripts/prototype.js
308
347
  - test/fixtures/public/javascripts/robber.js
348
+ - test/fixtures/public/javascripts/version.1.0.js
309
349
  - test/fixtures/public/stylesheets
310
350
  - test/fixtures/public/stylesheets/bank.css
311
351
  - test/fixtures/public/stylesheets/robber.css
352
+ - test/fixtures/public/stylesheets/version.1.0.css
312
353
  - test/fixtures/replies.yml
313
354
  - test/fixtures/reply.rb
314
355
  - test/fixtures/respond_to
@@ -330,12 +371,18 @@ files:
330
371
  - test/fixtures/scope
331
372
  - test/fixtures/scope/test
332
373
  - test/fixtures/scope/test/modgreet.erb
374
+ - test/fixtures/shared.html.erb
375
+ - test/fixtures/symlink_parent
376
+ - test/fixtures/symlink_parent/symlinked_layout.erb
333
377
  - test/fixtures/test
334
378
  - test/fixtures/test/_customer.erb
379
+ - test/fixtures/test/_customer_counter.erb
335
380
  - test/fixtures/test/_customer_greeting.erb
381
+ - test/fixtures/test/_form.erb
336
382
  - test/fixtures/test/_hash_greeting.erb
337
383
  - test/fixtures/test/_hash_object.erb
338
384
  - test/fixtures/test/_hello.builder
385
+ - test/fixtures/test/_labelling_form.erb
339
386
  - test/fixtures/test/_layout_for_partial.html.erb
340
387
  - test/fixtures/test/_partial.erb
341
388
  - test/fixtures/test/_partial.html.erb
@@ -343,6 +390,7 @@ files:
343
390
  - test/fixtures/test/_partial_for_use_in_layout.html.erb
344
391
  - test/fixtures/test/_partial_only.erb
345
392
  - test/fixtures/test/_person.erb
393
+ - test/fixtures/test/_raise.html.erb
346
394
  - test/fixtures/test/action_talk_to_layout.erb
347
395
  - test/fixtures/test/block_content_for.erb
348
396
  - test/fixtures/test/calling_partial_with_layout.html.erb
@@ -360,6 +408,7 @@ files:
360
408
  - test/fixtures/test/formatted_xml_erb.html.erb
361
409
  - test/fixtures/test/formatted_xml_erb.xml.erb
362
410
  - test/fixtures/test/greeting.erb
411
+ - test/fixtures/test/greeting.js.rjs
363
412
  - test/fixtures/test/hello.builder
364
413
  - test/fixtures/test/hello_world.erb
365
414
  - test/fixtures/test/hello_world_container.builder
@@ -375,15 +424,15 @@ files:
375
424
  - test/fixtures/test/update_element_with_capture.erb
376
425
  - test/fixtures/test/using_layout_around_block.html.erb
377
426
  - test/fixtures/topic.rb
427
+ - test/fixtures/topics
428
+ - test/fixtures/topics/_topic.html.erb
378
429
  - test/fixtures/topics.yml
379
430
  - test/template
380
431
  - test/template/active_record_helper_test.rb
381
432
  - test/template/asset_tag_helper_test.rb
382
433
  - test/template/atom_feed_helper_test.rb
383
434
  - test/template/benchmark_helper_test.rb
384
- - test/template/compiled_templates_test.rb
385
435
  - test/template/date_helper_test.rb
386
- - test/template/deprecate_ivars_test.rb
387
436
  - test/template/erb_util_test.rb
388
437
  - test/template/form_helper_test.rb
389
438
  - test/template/form_options_helper_test.rb
@@ -391,9 +440,13 @@ files:
391
440
  - test/template/javascript_helper_test.rb
392
441
  - test/template/number_helper_test.rb
393
442
  - test/template/prototype_helper_test.rb
443
+ - test/template/record_tag_helper_test.rb
394
444
  - test/template/sanitize_helper_test.rb
395
445
  - test/template/scriptaculous_helper_test.rb
396
446
  - test/template/tag_helper_test.rb
447
+ - test/template/template_finder_test.rb
448
+ - test/template/template_object_test.rb
449
+ - test/template/test_test.rb
397
450
  - test/template/text_helper_test.rb
398
451
  - test/template/url_helper_test.rb
399
452
  - test/testing_sandbox.rb
@@ -419,7 +472,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
419
472
  requirements:
420
473
  - none
421
474
  rubyforge_project: actionpack
422
- rubygems_version: 1.2.0
475
+ rubygems_version: 1.0.1
423
476
  signing_key:
424
477
  specification_version: 2
425
478
  summary: Web-flow and rendering framework putting the VC in MVC.