actionpack 2.0.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,13 +1,26 @@
1
1
  module ActionView
2
2
  module TemplateHandlers
3
3
  class RJS < TemplateHandler
4
+ include Compilable
5
+
4
6
  def self.line_offset
5
7
  2
6
8
  end
7
9
 
8
10
  def compile(template)
9
11
  "controller.response.content_type ||= Mime::JS\n" +
10
- "update_page do |page|\n#{template}\nend"
12
+ "update_page do |page|\n#{template.source}\nend"
13
+ end
14
+
15
+ def cache_fragment(block, name = {}, options = nil) #:nodoc:
16
+ @view.fragment_for(block, name, options) do
17
+ begin
18
+ debug_mode, ActionView::Base.debug_rjs = ActionView::Base.debug_rjs, false
19
+ eval('page.to_s', block.binding)
20
+ ensure
21
+ ActionView::Base.debug_rjs = debug_mode
22
+ end
23
+ end
11
24
  end
12
25
  end
13
26
  end
@@ -0,0 +1,58 @@
1
+ require 'active_support/test_case'
2
+
3
+ module ActionView
4
+ class TestCase < ActiveSupport::TestCase
5
+ class_inheritable_accessor :helper_class
6
+ @@helper_class = nil
7
+
8
+ class << self
9
+ def tests(helper_class)
10
+ self.helper_class = helper_class
11
+ end
12
+
13
+ def helper_class
14
+ if current_helper_class = read_inheritable_attribute(:helper_class)
15
+ current_helper_class
16
+ else
17
+ self.helper_class = determine_default_helper_class(name)
18
+ end
19
+ end
20
+
21
+ def determine_default_helper_class(name)
22
+ name.sub(/Test$/, '').constantize
23
+ rescue NameError
24
+ nil
25
+ end
26
+ end
27
+
28
+ ActionView::Base.helper_modules.each do |helper_module|
29
+ include helper_module
30
+ end
31
+ include ActionController::PolymorphicRoutes
32
+ include ActionController::RecordIdentifier
33
+
34
+ setup :setup_with_helper_class
35
+
36
+ def setup_with_helper_class
37
+ if helper_class && !self.class.ancestors.include?(helper_class)
38
+ self.class.send(:include, helper_class)
39
+ end
40
+ end
41
+
42
+ class TestController < ActionController::Base
43
+ attr_accessor :request, :response
44
+
45
+ def initialize
46
+ @request = ActionController::TestRequest.new
47
+ @response = ActionController::TestResponse.new
48
+ end
49
+ end
50
+
51
+ private
52
+ def method_missing(selector, *args)
53
+ controller = TestController.new
54
+ return controller.send!(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
55
+ super
56
+ end
57
+ end
58
+ end
@@ -8,6 +8,7 @@ require 'test/unit'
8
8
  require 'action_controller'
9
9
  require 'action_controller/cgi_ext'
10
10
  require 'action_controller/test_process'
11
+ require 'action_view/test_case'
11
12
 
12
13
  begin
13
14
  require 'ruby-debug'
@@ -19,7 +20,6 @@ end
19
20
  ActiveSupport::Deprecation.debug = true
20
21
 
21
22
  ActionController::Base.logger = nil
22
- ActionController::Base.ignore_missing_templates = false
23
23
  ActionController::Routing::Routes.reload rescue nil
24
24
 
25
25
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/abstract_unit'
1
+ require 'abstract_unit'
2
2
 
3
3
  # Define the essentials
4
4
  class ActiveRecordTestConnector
@@ -84,8 +84,7 @@ class ActiveRecordTestConnector
84
84
  end
85
85
  end
86
86
 
87
- # Test case for inheritance
88
- class ActiveRecordTestCase < Test::Unit::TestCase
87
+ class ActiveRecordTestCase < ActiveSupport::TestCase
89
88
  # Set our fixture path
90
89
  if ActiveRecordTestConnector.able_to_connect
91
90
  self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
@@ -100,9 +99,7 @@ class ActiveRecordTestCase < Test::Unit::TestCase
100
99
  super if ActiveRecordTestConnector.connected
101
100
  end
102
101
 
103
- # Default so Test::Unit::TestCase doesn't complain
104
- def test_truth
105
- end
102
+ def default_test; end
106
103
  end
107
104
 
108
105
  ActiveRecordTestConnector.setup
@@ -1,9 +1,8 @@
1
1
  # These tests exercise CGI::Session::ActiveRecordStore, so you're going to
2
2
  # need AR in a sibling directory to AP and have SQLite installed.
3
- require File.dirname(__FILE__) + '/../active_record_unit'
3
+ require 'active_record_unit'
4
4
  require 'action_controller/session/active_record_store'
5
5
 
6
-
7
6
  module CommonActiveRecordStoreTests
8
7
  def test_basics
9
8
  s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
@@ -1,39 +1,49 @@
1
- require File.dirname(__FILE__) + '/../active_record_unit'
1
+ require 'active_record_unit'
2
2
 
3
- class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
4
- fixtures :developers, :projects, :developers_projects, :topics, :replies
3
+ class RenderPartialWithRecordIdentificationController < ActionController::Base
4
+ def render_with_has_many_and_belongs_to_association
5
+ @developer = Developer.find(1)
6
+ render :partial => @developer.projects
7
+ end
5
8
 
6
- class RenderPartialWithRecordIdentificationController < ActionController::Base
7
- def render_with_has_many_and_belongs_to_association
8
- @developer = Developer.find(1)
9
- render :partial => @developer.projects
10
- end
11
-
12
- def render_with_has_many_association
13
- @topic = Topic.find(1)
14
- render :partial => @topic.replies
15
- end
16
-
17
- def render_with_has_many_through_association
18
- @developer = Developer.find(:first)
19
- render :partial => @developer.topics
20
- end
21
-
22
- def render_with_belongs_to_association
23
- @reply = Reply.find(1)
24
- render :partial => @reply.topic
25
- end
26
-
27
- def render_with_record
28
- @developer = Developer.find(:first)
29
- render :partial => @developer
30
- end
31
-
32
- def render_with_record_collection
33
- @developers = Developer.find(:all)
34
- render :partial => @developers
35
- end
9
+ def render_with_has_many_association
10
+ @topic = Topic.find(1)
11
+ render :partial => @topic.replies
12
+ end
13
+
14
+ def render_with_named_scope
15
+ render :partial => Reply.base
16
+ end
17
+
18
+ def render_with_has_many_through_association
19
+ @developer = Developer.find(:first)
20
+ render :partial => @developer.topics
21
+ end
22
+
23
+ def render_with_has_one_association
24
+ @company = Company.find(1)
25
+ render :partial => @company.mascot
26
+ end
27
+
28
+ def render_with_belongs_to_association
29
+ @reply = Reply.find(1)
30
+ render :partial => @reply.topic
31
+ end
32
+
33
+ def render_with_record
34
+ @developer = Developer.find(:first)
35
+ render :partial => @developer
36
+ end
37
+
38
+ def render_with_record_collection
39
+ @developers = Developer.find(:all)
40
+ render :partial => @developers
36
41
  end
42
+ end
43
+ RenderPartialWithRecordIdentificationController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
44
+
45
+ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
46
+ fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots
37
47
 
38
48
  def setup
39
49
  @controller = RenderPartialWithRecordIdentificationController.new
@@ -52,14 +62,9 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
52
62
  assert_template 'replies/_reply'
53
63
  end
54
64
 
55
- def test_rendering_partial_with_has_many_association
56
- get :render_with_has_many_through_association
57
- assert_template 'topics/_topic'
58
- end
59
-
60
- def test_rendering_partial_with_belongs_to_association
61
- get :render_with_belongs_to_association
62
- assert_template 'topics/_topic'
65
+ def test_rendering_partial_with_named_scope
66
+ get :render_with_named_scope
67
+ assert_template 'replies/_reply'
63
68
  end
64
69
 
65
70
  def test_render_with_record
@@ -71,4 +76,116 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
71
76
  get :render_with_record_collection
72
77
  assert_template 'developers/_developer'
73
78
  end
79
+
80
+ def test_rendering_partial_with_has_one_association
81
+ mascot = Company.find(1).mascot
82
+ get :render_with_has_one_association
83
+ assert_template 'mascots/_mascot'
84
+ assert_equal mascot.name, @response.body
85
+ end
86
+ end
87
+
88
+ class RenderPartialWithRecordIdentificationController < ActionController::Base
89
+ def render_with_has_many_and_belongs_to_association
90
+ @developer = Developer.find(1)
91
+ render :partial => @developer.projects
92
+ end
93
+
94
+ def render_with_has_many_association
95
+ @topic = Topic.find(1)
96
+ render :partial => @topic.replies
97
+ end
98
+
99
+ def render_with_has_many_through_association
100
+ @developer = Developer.find(:first)
101
+ render :partial => @developer.topics
102
+ end
103
+
104
+ def render_with_belongs_to_association
105
+ @reply = Reply.find(1)
106
+ render :partial => @reply.topic
107
+ end
108
+
109
+ def render_with_record
110
+ @developer = Developer.find(:first)
111
+ render :partial => @developer
112
+ end
113
+
114
+ def render_with_record_collection
115
+ @developers = Developer.find(:all)
116
+ render :partial => @developers
117
+ end
118
+ end
119
+ RenderPartialWithRecordIdentificationController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
120
+
121
+ class Game < Struct.new(:name, :id)
122
+ def to_param
123
+ id.to_s
124
+ end
125
+ end
126
+
127
+ module Fun
128
+ class NestedController < ActionController::Base
129
+ def render_with_record_in_nested_controller
130
+ render :partial => Game.new("Pong")
131
+ end
132
+
133
+ def render_with_record_collection_in_nested_controller
134
+ render :partial => [ Game.new("Pong"), Game.new("Tank") ]
135
+ end
136
+ end
137
+ NestedController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
138
+
139
+ module Serious
140
+ class NestedDeeperController < ActionController::Base
141
+ def render_with_record_in_deeper_nested_controller
142
+ render :partial => Game.new("Chess")
143
+ end
144
+
145
+ def render_with_record_collection_in_deeper_nested_controller
146
+ render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ]
147
+ end
148
+ end
149
+ NestedDeeperController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
150
+ end
74
151
  end
152
+
153
+ class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveRecordTestCase
154
+ def setup
155
+ @controller = Fun::NestedController.new
156
+ @request = ActionController::TestRequest.new
157
+ @response = ActionController::TestResponse.new
158
+ super
159
+ end
160
+
161
+ def test_render_with_record_in_nested_controller
162
+ get :render_with_record_in_nested_controller
163
+ assert_template 'fun/games/_game'
164
+ end
165
+
166
+ def test_render_with_record_collection_in_nested_controller
167
+ get :render_with_record_collection_in_nested_controller
168
+ assert_template 'fun/games/_game'
169
+ end
170
+
171
+ end
172
+
173
+ class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < ActiveRecordTestCase
174
+ def setup
175
+ @controller = Fun::Serious::NestedDeeperController.new
176
+ @request = ActionController::TestRequest.new
177
+ @response = ActionController::TestResponse.new
178
+ super
179
+ end
180
+
181
+ def test_render_with_record_in_deeper_nested_controller
182
+ get :render_with_record_in_deeper_nested_controller
183
+ assert_template 'fun/serious/games/_game'
184
+ end
185
+
186
+ def test_render_with_record_collection_in_deeper_nested_controller
187
+ get :render_with_record_collection_in_deeper_nested_controller
188
+ assert_template 'fun/serious/games/_game'
189
+ end
190
+
191
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/abstract_unit'
2
+ require 'action_mailer/adv_attr_accessor'
3
+
4
+ class AdvAttrTest < Test::Unit::TestCase
5
+ class Person
6
+ include ActionMailer::AdvAttrAccessor
7
+ adv_attr_accessor :name
8
+ end
9
+
10
+ def test_adv_attr
11
+ bob = Person.new
12
+ assert_nil bob.name
13
+ bob.name 'Bob'
14
+ assert_equal 'Bob', bob.name
15
+
16
+ assert_raise(ArgumentError) {bob.name 'x', 'y'}
17
+ end
18
+
19
+
20
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../abstract_unit'
1
+ require 'abstract_unit'
2
2
 
3
3
  # a controller class to facilitate the tests
4
4
  class ActionPackAssertionsController < ActionController::Base
@@ -131,9 +131,10 @@ class AssertResponseWithUnexpectedErrorController < ActionController::Base
131
131
  def index
132
132
  raise 'FAIL'
133
133
  end
134
- end
135
134
 
136
- class UserController < ActionController::Base
135
+ def show
136
+ render :text => "Boom", :status => 500
137
+ end
137
138
  end
138
139
 
139
140
  module Admin
@@ -173,7 +174,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
173
174
  # let's get this party started
174
175
  def setup
175
176
  ActionController::Routing::Routes.reload
176
- ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user))
177
+ ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module content admin/user))
177
178
  @controller = ActionPackAssertionsController.new
178
179
  @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new
179
180
  end
@@ -267,7 +268,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
267
268
  assert_redirected_to admin_inner_module_path
268
269
  end
269
270
  end
270
-
271
+
271
272
  def test_assert_redirected_to_top_level_named_route_from_nested_controller
272
273
  with_routing do |set|
273
274
  set.draw do |map|
@@ -281,20 +282,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
281
282
  end
282
283
  end
283
284
 
284
-
285
- def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in_both_namespaces
286
- with_routing do |set|
287
- set.draw do |map|
288
- # this controller exists in the admin namespace as well which is the only difference from previous test
289
- map.top_level '/user/:id', :controller => 'user', :action => 'index'
290
- map.connect ':controller/:action/:id'
291
- end
292
- @controller = Admin::InnerModuleController.new
293
- process :redirect_to_top_level_named_route
294
- assert_redirected_to "/user/foo"
295
- end
296
- end
297
-
298
285
  # -- standard request/response object testing --------------------------------
299
286
 
300
287
  # make sure that the template objects exist
@@ -500,6 +487,16 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
500
487
  rescue Test::Unit::AssertionFailedError => e
501
488
  assert e.message.include?('FAIL')
502
489
  end
490
+
491
+ def test_assert_response_failure_response_with_no_exception
492
+ @controller = AssertResponseWithUnexpectedErrorController.new
493
+ get :show
494
+ assert_response :success
495
+ flunk 'Expected non-success response'
496
+ rescue Test::Unit::AssertionFailedError
497
+ rescue
498
+ flunk "assert_response failed to handle failure response with missing, but optional, exception."
499
+ end
503
500
  end
504
501
 
505
502
  class ActionPackHeaderTest < Test::Unit::TestCase