actionpack 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (65) hide show
  1. data/CHANGELOG +109 -0
  2. data/README +2 -2
  3. data/RUNNING_UNIT_TESTS +1 -1
  4. data/install.rb +8 -77
  5. data/lib/action_controller/assertions.rb +203 -0
  6. data/lib/action_controller/base.rb +15 -7
  7. data/lib/action_controller/benchmarking.rb +10 -4
  8. data/lib/action_controller/caching.rb +28 -17
  9. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +5 -9
  10. data/lib/action_controller/cgi_process.rb +5 -1
  11. data/lib/action_controller/cookies.rb +3 -2
  12. data/lib/action_controller/deprecated_assertions.rb +204 -0
  13. data/lib/action_controller/flash.rb +30 -36
  14. data/lib/action_controller/pagination.rb +4 -4
  15. data/lib/action_controller/request.rb +18 -2
  16. data/lib/action_controller/routing.rb +6 -2
  17. data/lib/action_controller/scaffolding.rb +1 -1
  18. data/lib/action_controller/templates/rescues/diagnostics.rhtml +1 -1
  19. data/lib/action_controller/templates/rescues/routing_error.rhtml +4 -2
  20. data/lib/action_controller/templates/rescues/template_error.rhtml +5 -4
  21. data/lib/action_controller/templates/scaffolds/list.rhtml +3 -0
  22. data/lib/action_controller/test_process.rb +60 -17
  23. data/lib/action_controller/url_rewriter.rb +3 -3
  24. data/lib/action_controller/vendor/html-scanner/html/document.rb +63 -0
  25. data/lib/action_controller/vendor/html-scanner/html/node.rb +431 -0
  26. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +95 -0
  27. data/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
  28. data/lib/action_controller/verification.rb +13 -4
  29. data/lib/action_view/base.rb +3 -2
  30. data/lib/action_view/helpers/active_record_helper.rb +1 -1
  31. data/lib/action_view/helpers/asset_tag_helper.rb +31 -9
  32. data/lib/action_view/helpers/date_helper.rb +25 -22
  33. data/lib/action_view/helpers/form_helper.rb +6 -5
  34. data/lib/action_view/helpers/form_options_helper.rb +4 -4
  35. data/lib/action_view/helpers/javascript_helper.rb +28 -6
  36. data/lib/action_view/helpers/javascripts/prototype.js +340 -30
  37. data/lib/action_view/helpers/number_helper.rb +110 -0
  38. data/lib/action_view/helpers/pagination_helper.rb +1 -1
  39. data/lib/action_view/helpers/text_helper.rb +8 -21
  40. data/lib/action_view/helpers/url_helper.rb +21 -4
  41. data/lib/action_view/partials.rb +39 -9
  42. data/rakefile +29 -5
  43. data/test/abstract_unit.rb +1 -0
  44. data/test/controller/action_pack_assertions_test.rb +1 -2
  45. data/test/controller/active_record_assertions_test.rb +1 -1
  46. data/test/controller/cgi_test.rb +0 -1
  47. data/test/controller/cookie_test.rb +11 -1
  48. data/test/controller/helper_test.rb +0 -12
  49. data/test/controller/render_test.rb +9 -0
  50. data/test/controller/request_test.rb +44 -1
  51. data/test/controller/routing_tests.rb +4 -1
  52. data/test/controller/test_test.rb +62 -0
  53. data/test/controller/verification_test.rb +21 -0
  54. data/test/fixtures/test/_partial_only.rhtml +1 -0
  55. data/test/template/active_record_helper_test.rb +2 -2
  56. data/test/template/asset_tag_helper_test.rb +52 -4
  57. data/test/template/date_helper_test.rb +163 -32
  58. data/test/template/form_helper_test.rb +9 -6
  59. data/test/template/form_options_helper_test.rb +18 -15
  60. data/test/template/number_helper_test.rb +51 -0
  61. data/test/template/text_helper_test.rb +17 -20
  62. data/test/template/url_helper_test.rb +7 -1
  63. metadata +15 -6
  64. data/lib/action_controller/assertions/action_pack_assertions.rb +0 -260
  65. data/lib/action_controller/assertions/active_record_assertions.rb +0 -65
data/CHANGELOG CHANGED
@@ -1,3 +1,112 @@
1
+ *1.8.0* (19th April, 2005)
2
+
3
+ * Added assert_tag and assert_no_tag as a much improved alternative to the deprecated assert_template_xpath_match #1126 [Jamis Buck]
4
+
5
+ * Deprecated the majority of all the testing assertions and replaced them with a much smaller core and access to all the collections the old assertions relied on. That way the regular test/unit assertions can be used against these. Added documentation about how to use it all.
6
+
7
+ * Added a wide range of new Javascript effects:
8
+ * Effect.Puff zooms the element out and makes it smoothly transparent at the same time, giving a "puff" illusion #996 [thomas@fesch.at]
9
+ After the animation is completed, the display property will be set to none.
10
+ This effect will work on relative and absolute positioned elements.
11
+
12
+ * Effect.Appear as the opposite of Effect.Fade #990 [thomas@fesch.at]
13
+ You should return elements with style="display:none;" or a like class for this to work best and have no chance of flicker.
14
+
15
+ * Effect.Squish for scaling down an element and making it disappear at the end #972 [thomas@fesch.at]
16
+
17
+ * Effect.Scale for smoothly scaling images or text up and down #972 [thomas@fesch.at]
18
+
19
+ * Effect.Fade which smoothly turns opacity from 100 to 0 and then hides the element #960 [thomas@fesch.at]
20
+
21
+ * Added Request#xml_http_request? (and an alias xhr?) to that'll return true when the request came from one of the Javascript helper methods (Ajax). This can be used to give one behavior for modern browsers supporting Ajax, another to old browsers #1127 [Sam Stephenson]
22
+
23
+ * Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns. So the API changes from:
24
+
25
+ <%= render_partial "account", person, "rules" => regulations.rules %>
26
+
27
+ ...to:
28
+
29
+ <%= render_partial "account", :account => person, :rules => regulations.rules %>
30
+
31
+ The old API will still work, though, and render_partial "account" will still assume :account => @account.
32
+
33
+ * Added support for web servers that use PATH_INFO instead of REQUEST_URI like IIS #1014 [BradG/Nicholas Seckar]
34
+
35
+ * Added graceful handling of PUT, DELETE, and OPTIONS requests for a complete coverage of REST functionality #1136 [joshknowles@gmail.com]
36
+
37
+ * Fixed that you can now pass an alternative :href option to link_to_function/remote in order to point to somewhere other than # if the javascript fails or is turned off. You can do the same with form_remote_tag by passing in :action. #1113 [Sam Stephenson]
38
+
39
+ * Fixed DateHelper to return values on the option tags such that they'll work properly in IE with form_remote_tag #1024 [rscottmace@gmail.com]
40
+
41
+ * Fixed FormTagHelper#check_box to respect checked #1049 [DelynnB]
42
+
43
+ * Added that render_partial called from a controller will use the action name as default #828 [Dan Peterson]
44
+
45
+ * Added Element.toggle, Element.show, and Element.hide to the prototype javascript library. Toggle.display has been deprecated, but will still work #992 [Lucas Carlson]
46
+
47
+ * Added that deleting a cookie should not just set it to an empty string but also instantly expire it #1118 [todd@robotcoop.com]
48
+
49
+ * Added AssetTagHelper#image_path, AssetTagHelper#javascript_path, and AssetTagHelper#stylesheet_path #1110 [Larry Halff]
50
+
51
+ * Fixed url_for(nil) in functional tests #1116 [Alisdair McDiarmid]
52
+
53
+ * Fixed error handling of broken layouts #1115 [Michael Schubert]
54
+
55
+ * Added submit_to_remote that allows you to trigger an Ajax form submition at the click of the submission button, which allows for multiple targets in a single form through the use of multiple submit buttons #930 [yrashk@gmail.com]
56
+
57
+ * Fixed pagination to work with joins #1034 [scott@sigkill.org]
58
+
59
+ * Fixed that *rest parameter in map.connect couldn't accept an empty list #1037 [Dee.Zsombor@gmail.com]
60
+
61
+ * Added :confirm option to link_to_remote just like link_to has #1082 [yrashk@fp.org.ua]
62
+
63
+ * Added minute_step as an option to select_minute (and the helpers that use it) to jump in larger increments than just 1 minute. At 15, it would return 0, 15, 30, 45 options #1085 [ordwaye@evergreen.edu]
64
+
65
+ * Fixed that an exception would be thrown when an empty form was submitted #1090 [jan@ulbrich-boerwang.de]
66
+
67
+ * Moved TextHelper#human_size to NumberHelper#number_to_human_size, but kept an deprecated alias to the old method name
68
+
69
+ * Fixed that the content-type for some browsers could include an additional \r which made wonky things happen #1067 [Thomas Fuchs]
70
+
71
+ * Fixed that radio buttons shouldn't have a default size attribute #1074 [hendrik@mans.de]
72
+
73
+ * Added ActionView::Helpers::InstanceTag::DEFAULT_RADIO_OPTIONS that contains a hash of default options for radio buttons #1074 [hendrik@mans.de]
74
+
75
+ * Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar]
76
+
77
+ * Added JavascriptHelper#periodically_call_remote in order to create areas of a page that update automatically at a set interval #945 [Jon Tirsen]
78
+
79
+ * Fixed Cache#expire_matched_fragments that couldn't recognize the difference between string and url_for options #1030 [skaes@web.de]
80
+
81
+ * Added simulation of @request.request_uri in functional tests #1038 [Jamis Buck]
82
+
83
+ * Fixed autolinking to work better in more cases #1013 [Jamis Buck]
84
+
85
+ * Added the possible of using symbols in form helpers that relate to instance variables like text_field :account, :name in addition to text_field "account", "name"'
86
+
87
+ * Fixed javascript_include_tag to output type instead of language and conform to XHTML #1018 [Rick Olson]
88
+
89
+ * Added NumberHelper for common string representations like phone number, currency, and percentage #1015 [DeLynn]
90
+
91
+ * Added pagination for scaffolding (10 items per page) #964 [mortonda@dgrmm.net]
92
+
93
+ * Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat]
94
+
95
+ * Fixed :overwrite_param so it doesn't delete but reject elements from @request.parameters #982 [raphinou@yahoo.com]
96
+
97
+ * Added :method option to verify for ensuring that either GET, POST, etc is allowed #984 [Jamis Buck]
98
+
99
+ * Added options to set cc, bcc, subject, and body for UrlHelper#mail_to #966 [DeLynn]
100
+
101
+ * Fixed include_blank for select_hour/minute/second #527 [edward@debian.org]
102
+
103
+ * Improved the message display on the exception handler pages #963 [Johan Sorensen]
104
+
105
+ * Fixed that on very rare occasions, webrick would raise a NoMethodError: private method 'split' called for nil #1001 [Flurin Egger]
106
+
107
+ * Fixed problem with page caching #958 [Rick Olson]
108
+
109
+
1
110
  *1.7.0* (27th March, 2005)
2
111
 
3
112
  * Added ActionController::Base.page_cache_extension for setting the page cache file extension (the default is .html) #903 [Andreas]
data/README CHANGED
@@ -187,7 +187,7 @@ A short rundown of the major features:
187
187
 
188
188
  # view
189
189
  <%= link_to "Previous page", { :page => @pages.current.previous } if @pages.current.previous %>
190
- <%= link_to "Next page", { :page => @pages.current.next } of @pages.current.next =%>
190
+ <%= link_to "Next page", { :page => @pages.current.next } if @pages.current.next %>
191
191
 
192
192
  {Learn more}[link:classes/ActionController/Pagination.html]
193
193
 
@@ -468,4 +468,4 @@ And as Jim from Rake says:
468
468
  new feature to be submitted in the form of new unit tests.
469
469
 
470
470
  For other information, feel free to ask on the ruby-talk mailing list (which
471
- is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com.
471
+ is mirrored to comp.lang.ruby) or contact mailto:david@loudthinking.com.
@@ -11,7 +11,7 @@ Rake can be found at http://rake.rubyforge.org
11
11
  If you only want to run a single test suite, or don't want to bother with Rake,
12
12
  you can do so with something like:
13
13
 
14
- ruby controller/base_test.rb
14
+ ruby controller/base_tests.rb
15
15
 
16
16
  == Dependency on ActiveRecord and database setup
17
17
 
data/install.rb CHANGED
@@ -18,82 +18,13 @@ unless $sitedir
18
18
  end
19
19
  end
20
20
 
21
- makedirs = %w{ action_controller/assertions action_controller/cgi_ext
22
- action_controller/session action_controller/support
23
- action_controller/templates action_controller/templates/rescues
24
- action_controller/templates/scaffolds
25
- action_view/helpers action_view/vendor action_view/vendor/builder
26
- }
27
-
28
-
29
- makedirs.each {|f| File::makedirs(File.join($sitedir, *f.split(/\//)))}
30
-
31
- # deprecated files that should be removed
32
- # deprecated = %w{ }
33
-
34
- # files to install in library path
35
- files = %w-
36
- action_controller.rb
37
- action_controller/assertions/action_pack_assertions.rb
38
- action_controller/assertions/active_record_assertions.rb
39
- action_controller/base.rb
40
- action_controller/benchmarking.rb
41
- action_controller/cgi_ext/cgi_ext.rb
42
- action_controller/cgi_ext/cgi_methods.rb
43
- action_controller/cgi_ext/cookie_performance_fix.rb
44
- action_controller/cgi_ext/raw_post_data_fix.rb
45
- action_controller/caching.rb
46
- action_controller/cgi_process.rb
47
- action_controller/cookies.rb
48
- action_controller/dependencies.rb
49
- action_controller/filters.rb
50
- action_controller/flash.rb
51
- action_controller/helpers.rb
52
- action_controller/layout.rb
53
- action_controller/request.rb
54
- action_controller/rescue.rb
55
- action_controller/response.rb
56
- action_controller/scaffolding.rb
57
- action_controller/session/active_record_store.rb
58
- action_controller/session/drb_server.rb
59
- action_controller/session/drb_store.rb
60
- action_controller/session/mem_cache_store.rb
61
- action_controller/session.rb
62
- action_controller/templates/rescues/_request_and_response.rhtml
63
- action_controller/templates/rescues/diagnostics.rhtml
64
- action_controller/templates/rescues/layout.rhtml
65
- action_controller/templates/rescues/missing_template.rhtml
66
- action_controller/templates/rescues/template_error.rhtml
67
- action_controller/templates/rescues/unknown_action.rhtml
68
- action_controller/templates/scaffolds/edit.rhtml
69
- action_controller/templates/scaffolds/layout.rhtml
70
- action_controller/templates/scaffolds/list.rhtml
71
- action_controller/templates/scaffolds/new.rhtml
72
- action_controller/templates/scaffolds/show.rhtml
73
- action_controller/test_process.rb
74
- action_controller/url_rewriter.rb
75
- action_view.rb
76
- action_view/base.rb
77
- action_view/helpers/active_record_helper.rb
78
- action_view/helpers/date_helper.rb
79
- action_view/helpers/debug_helper.rb
80
- action_view/helpers/form_helper.rb
81
- action_view/helpers/form_options_helper.rb
82
- action_view/helpers/text_helper.rb
83
- action_view/helpers/tag_helper.rb
84
- action_view/helpers/url_helper.rb
85
- action_view/partials.rb
86
- action_view/template_error.rb
87
- action_view/vendor/builder.rb
88
- action_view/vendor/builder/blankslate.rb
89
- action_view/vendor/builder/xmlbase.rb
90
- action_view/vendor/builder/xmlevents.rb
91
- action_view/vendor/builder/xmlmarkup.rb
92
- -
93
-
94
21
  # the acual gruntwork
95
22
  Dir.chdir("lib")
96
- # File::safe_unlink *deprecated.collect{|f| File.join($sitedir, f.split(/\//))}
97
- files.each {|f|
98
- File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
99
- }
23
+
24
+ Find.find("action_controller", "action_controller.rb", "action_view", "action_view.rb") { |f|
25
+ if f[-3..-1] == ".rb"
26
+ File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
27
+ else
28
+ File::makedirs(File.join($sitedir, *f.split(/\//)))
29
+ end
30
+ }
@@ -0,0 +1,203 @@
1
+ require 'test/unit'
2
+ require 'test/unit/assertions'
3
+ require 'rexml/document'
4
+
5
+ module Test #:nodoc:
6
+ module Unit #:nodoc:
7
+ # In addition to these specific assertions, you also have easy access to various collections that the regular test/unit assertions
8
+ # can be used against. These collections are:
9
+ #
10
+ # * assigns: Instance variables assigned in the action that's available for the view.
11
+ # * session: Objects being saved in the session.
12
+ # * flash: The flash objects being currently in the session.
13
+ # * cookies: Cookies being sent to the user on this request.
14
+ #
15
+ # These collections can be used just like any other hash:
16
+ #
17
+ # assert_not_nil assigns[:person] # makes sure that a @person instance variable was set
18
+ # assert_equal "Dave", cookies[:name] # makes sure that a cookie called :name was set as "Dave"
19
+ # assert flash.empty? # makes sure that there's nothing in the flash
20
+ #
21
+ # On top of the collections, you have the complete url that a given action redirected to available in redirect_to_url.
22
+ #
23
+ # For redirects within the same controller, you can even call follow_redirect and the redirect will be follow triggering another
24
+ # action call which can then be asserted against.
25
+ module Assertions
26
+ # Asserts that the response is one of the following types:
27
+ #
28
+ # * <tt>:success</tt>: Status code was 200
29
+ # * <tt>:redirect</tt>: Status code was in the 300-399 range
30
+ # * <tt>:missing</tt>: Status code was 404
31
+ # * <tt>:error</tt>: Status code was in the 500-599 range
32
+ #
33
+ # You can also pass an explicit status code number as the type, like assert_response(501)
34
+ def assert_response(type, message = nil)
35
+ if [ :success, :missing, :redirect, :error ].include?(type) && @response.send("#{type}?")
36
+ assert_block("") { true } # to count the assertion
37
+ elsif type.is_a?(Fixnum) && @response.response_code == type
38
+ assert_block("") { true } # to count the assertion
39
+ else
40
+ assert_block(build_message(message, "Expected response to be a <?>, but was <?>", type, @response.response_code)) { false }
41
+ end
42
+ end
43
+
44
+ # Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial,
45
+ # such at assert_redirected_to(:controller => "weblog") will also match the redirection of
46
+ # redirect_to(:controller => "weblog", :action => "show") and so on.
47
+ def assert_redirected_to(options = {}, message=nil)
48
+ assert_redirect(message)
49
+
50
+ msg = build_message(message, "response is not a redirection to all of the options supplied (redirection is <?>)", @response.redirected_to)
51
+ assert_block(msg) do
52
+ if options.is_a?(Symbol)
53
+ @response.redirected_to == options
54
+ else
55
+ options.keys.all? do |k|
56
+ options[k] == (@response.redirected_to[k].respond_to?(:to_param) ? @response.redirected_to[k].to_param : @response.redirected_to[k] if @response.redirected_to[k])
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ # Asserts that the request was rendered with the appropriate template file.
63
+ def assert_template(expected = nil, message=nil)
64
+ rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file
65
+ msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
66
+ assert_block(msg) do
67
+ if expected.nil?
68
+ @response.rendered_with_file?
69
+ else
70
+ expected == rendered
71
+ end
72
+ end
73
+ end
74
+
75
+ # Asserts that the routing of the given path is handled correctly and that the parsed options match.
76
+ def assert_recognizes(expected_options, path, extras={}, message=nil)
77
+ # Load routes.rb if it hasn't been loaded.
78
+ ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
79
+
80
+ # Assume given controller
81
+ request = ActionController::TestRequest.new({}, {}, nil)
82
+ request.path = path
83
+ ActionController::Routing::Routes.recognize!(request)
84
+
85
+ expected_options = expected_options.clone
86
+ extras.each_key { |key| expected_options.delete key } unless extras.nil?
87
+
88
+ msg = build_message(message, "The recognized options <?> did not match <?>",
89
+ request.path_parameters, expected_options)
90
+ assert_block(msg) { request.path_parameters == expected_options }
91
+ end
92
+
93
+ # Asserts that the provided options can be used to generate the provided path.
94
+ def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
95
+ # Load routes.rb if it hasn't been loaded.
96
+ ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
97
+
98
+ # Assume given controller
99
+ request = ActionController::TestRequest.new({}, {}, nil)
100
+ request.path_parameters = (defaults or {}).clone
101
+ request.path_parameters[:controller] ||= options[:controller]
102
+
103
+ generated_path, found_extras = ActionController::Routing::Routes.generate(options, request)
104
+ generated_path = generated_path.join('/')
105
+ msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
106
+ assert_block(msg) { found_extras == extras }
107
+
108
+ msg = build_message(message, "The generated path <?> did not match <?>", generated_path,
109
+ expected_path)
110
+ assert_block(msg) { expected_path == generated_path }
111
+ end
112
+
113
+ # asserts that path and options match both ways, in other words, the URL generated from
114
+ # options is same as path, and also that the options recognized from path are same as options
115
+ def assert_routing(path, options, defaults={}, extras={}, message=nil)
116
+ assert_recognizes(options, path, extras, message)
117
+ assert_generates(path, options, defaults, extras, message)
118
+ end
119
+
120
+ # Asserts that there is a tag/node/element in the body of the response
121
+ # that meets all of the given conditions. The +conditions+ parameter must
122
+ # be a hash of any of the following keys (all are optional):
123
+ #
124
+ # * <tt>:tag</tt>: the node type must match the corresponding value
125
+ # * <tt>:attributes</tt>: a hash. The node's attributes must match the
126
+ # corresponding values in the hash.
127
+ # * <tt>:parent</tt>: a hash. The node's parent must match the
128
+ # corresponding hash.
129
+ # * <tt>:child</tt>: a hash. At least one of the node's immediate children
130
+ # must meet the criteria described by the hash.
131
+ # * <tt>:ancestor</tt>: a hash. At least one of the node's ancestors must
132
+ # meet the criteria described by the hash.
133
+ # * <tt>:descendant</tt>: a hash. At least one of the node's descendants
134
+ # must meet the criteria described by the hash.
135
+ # * <tt>:children</tt>: a hash, for counting children of a node. Accepts
136
+ # the keys:
137
+ # * <tt>:count</tt>: either a number or a range which must equal (or
138
+ # include) the number of children that match.
139
+ # * <tt>:less_than</tt>: the number of matching children must be less
140
+ # than this number.
141
+ # * <tt>:greater_than</tt>: the number of matching children must be
142
+ # greater than this number.
143
+ # * <tt>:only</tt>: another hash consisting of the keys to use
144
+ # to match on the children, and only matching children will be
145
+ # counted.
146
+ # * <tt>:content</tt>: (text nodes only). The content of the node must
147
+ # match the given value.
148
+ #
149
+ # Conditions are matched using the following algorithm:
150
+ #
151
+ # * if the condition is a string, it must be a substring of the value.
152
+ # * if the condition is a regexp, it must match the value.
153
+ # * if the condition is a number, the value must match number.to_s.
154
+ # * if the condition is +true+, the value must not be +nil+.
155
+ # * if the condition is +false+ or +nil+, the value must be +nil+.
156
+ #
157
+ # Usage:
158
+ #
159
+ # # assert that there is a "span" tag
160
+ # assert_tag :tag => "span"
161
+ #
162
+ # # assert that there is a "span" inside of a "div"
163
+ # assert_tag :tag => "span", :parent => { :tag => "div" }
164
+ #
165
+ # # assert that there is a "span" somewhere inside a table
166
+ # assert_tag :tag => "span", :ancestor => { :tag => "table" }
167
+ #
168
+ # # assert that there is a "span" with at least one "em" child
169
+ # assert_tag :tag => "span", :child => { :tag => "em" }
170
+ #
171
+ # # assert that there is a "span" containing a (possibly nested)
172
+ # # "strong" tag.
173
+ # assert_tag :tag => "span", :descendant => { :tag => "strong" }
174
+ #
175
+ # # assert that there is a "span" containing between 2 and 4 "em" tags
176
+ # # as immediate children
177
+ # assert_tag :tag => "span",
178
+ # :children => { :count => 2..4, :only => { :tag => "em" } }
179
+ #
180
+ # # get funky: assert that there is a "div", with an "ul" ancestor
181
+ # # and an "li" parent (with "class" = "enum"), and containing a
182
+ # # "span" descendant that contains text matching /hello world/
183
+ # assert_tag :tag => "div",
184
+ # :ancestor => { :tag => "ul" },
185
+ # :parent => { :tag => "li",
186
+ # :attributes => { :class => "enum" } },
187
+ # :descendant => { :tag => "span",
188
+ # :child => /hello world/ }
189
+ def assert_tag(opts)
190
+ tag = find_tag(opts)
191
+ assert tag, "expected tag, but no tag found matching #{opts.inspect} in:\n#{@response.body.inspect}"
192
+ end
193
+
194
+ # Identical to #assert_tag, but asserts that a matching tag does _not_
195
+ # exist. (See #assert_tag for a full discussion of the syntax.)
196
+ def assert_no_tag(opts)
197
+ tag = find_tag(opts)
198
+ assert !tag, "expected no tag, but found tag matching #{opts.inspect} in:\n#{@response.body.inspect}"
199
+ end
200
+
201
+ end
202
+ end
203
+ end
@@ -242,7 +242,7 @@ module ActionController #:nodoc:
242
242
  cattr_accessor :ignore_missing_templates
243
243
 
244
244
  # Holds the request object that's primarily used to get environment variables through access like
245
- # <tt>@request.env["REQUEST_URI"]</tt>.
245
+ # <tt>request.env["REQUEST_URI"]</tt>.
246
246
  attr_accessor :request
247
247
 
248
248
  # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>@params["post_id"]</tt>
@@ -250,16 +250,16 @@ module ActionController #:nodoc:
250
250
  attr_accessor :params
251
251
 
252
252
  # Holds the response object that's primarily used to set additional HTTP headers through access like
253
- # <tt>@response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
254
- # has been rendered through @response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
253
+ # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
254
+ # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
255
255
  # such as a OutputCompressionFilter.
256
256
  attr_accessor :response
257
257
 
258
- # Holds a hash of objects in the session. Accessed like <tt>@session["person"]</tt> to get the object tied to the "person"
258
+ # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person"
259
259
  # key. The session will hold any type of object as values, but the key should be a string.
260
260
  attr_accessor :session
261
261
 
262
- # Holds a hash of header names and values. Accessed like <tt>@headers["Cache-Control"]</tt> to get the value of the Cache-Control
262
+ # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control
263
263
  # directive. Values should always be specified as strings.
264
264
  attr_accessor :headers
265
265
 
@@ -489,11 +489,19 @@ module ActionController #:nodoc:
489
489
  @template.render_file(template_name)
490
490
  end
491
491
 
492
- def render_partial(partial_path, object = nil, local_assigns = {}) #:doc:
492
+ # Renders the partial specified by <tt>partial_path</tt>, which by default is the name of the action itself. Example:
493
+ #
494
+ # class WeblogController < ActionController::Base
495
+ # def show
496
+ # render_partial # renders "weblog/_show.r(xml|html)"
497
+ # end
498
+ # end
499
+ def render_partial(partial_path = default_template_name, object = nil, local_assigns = {}) #:doc:
493
500
  add_variables_to_assigns
494
501
  render_text(@template.render_partial(partial_path, object, local_assigns))
495
502
  end
496
503
 
504
+ # Renders a collection of partials using <tt>partial_name</tt> to iterate over the +collection+.
497
505
  def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = {})#:doc:
498
506
  add_variables_to_assigns
499
507
  render_text(@template.render_collection_of_partials(partial_name, collection, partial_spacer_template, local_assigns))
@@ -776,7 +784,7 @@ module ActionController #:nodoc:
776
784
 
777
785
  @headers.update(
778
786
  'Content-Length' => options[:length],
779
- 'Content-Type' => options[:type],
787
+ 'Content-Type' => options[:type].strip, # fixes a problem with extra '\r' with some browsers
780
788
  'Content-Disposition' => disposition,
781
789
  'Content-Transfer-Encoding' => 'binary'
782
790
  );