Permalink
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
2 parents a7f09bc + bb1e177 commit 2e50110eac439f3d5d292f1519ae7c79991eb91a @lifo lifo committed Aug 9, 2009
Showing with 3,933 additions and 2,176 deletions.
  1. +1 −0 .gitignore
  2. +26 −5 actionmailer/lib/action_mailer/base.rb
  3. +22 −0 actionmailer/test/delivery_method_test.rb
  4. +21 −6 actionmailer/test/mail_service_test.rb
  5. +4 −0 actionpack/CHANGELOG
  6. +74 −14 actionpack/examples/minimal.rb
  7. +5 −5 actionpack/examples/very_simple.rb
  8. +1 −0 actionpack/examples/views/_collection.erb
  9. +1 −0 actionpack/examples/views/_hello.erb
  10. +10 −0 actionpack/examples/views/_many_partials.erb
  11. +10 −0 actionpack/examples/views/_partial.erb
  12. +1 −1 actionpack/examples/views/template.html.erb
  13. +16 −0 actionpack/lib/abstract_controller.rb
  14. +1 −1 actionpack/lib/{action_controller/abstract → abstract_controller}/base.rb
  15. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/benchmarker.rb
  16. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/callbacks.rb
  17. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/exceptions.rb
  18. +11 −1 actionpack/lib/{action_controller/abstract → abstract_controller}/helpers.rb
  19. +21 −3 actionpack/lib/{action_controller/abstract → abstract_controller}/layouts.rb
  20. 0 actionpack/lib/{action_controller/abstract → abstract_controller}/logger.rb
  21. +11 −11 ...onpack/lib/{action_controller/abstract/renderer.rb → abstract_controller/rendering_controller.rb}
  22. +38 −38 actionpack/lib/action_controller.rb
  23. +0 −16 actionpack/lib/action_controller/abstract.rb
  24. +5 −5 actionpack/lib/action_controller/{base → }/base.rb
  25. +1 −2 actionpack/lib/action_controller/caching/actions.rb
  26. +2 −2 actionpack/lib/action_controller/caching/fragments.rb
  27. +1 −1 actionpack/lib/action_controller/legacy/layout.rb
  28. +5 −7 actionpack/lib/action_controller/{base/http.rb → metal.rb}
  29. +4 −2 actionpack/lib/action_controller/{base → metal}/compatibility.rb
  30. +8 −22 actionpack/lib/action_controller/{base → metal}/conditional_get.rb
  31. 0 actionpack/lib/action_controller/{base → metal}/cookies.rb
  32. 0 actionpack/lib/action_controller/{base → metal}/exceptions.rb
  33. 0 actionpack/lib/action_controller/{base → metal}/filter_parameter_logging.rb
  34. 0 actionpack/lib/action_controller/{base → metal}/flash.rb
  35. 0 actionpack/lib/action_controller/{base → metal}/helpers.rb
  36. 0 actionpack/lib/action_controller/{base → metal}/hide_actions.rb
  37. +3 −2 actionpack/lib/action_controller/{base → metal}/http_authentication.rb
  38. +1 −1 actionpack/lib/action_controller/{base → metal}/layouts.rb
  39. +38 −77 actionpack/lib/action_controller/{base → metal}/mime_responds.rb
  40. +1 −1 actionpack/lib/action_controller/{base → metal}/rack_convenience.rb
  41. 0 actionpack/lib/action_controller/{base → metal}/redirector.rb
  42. +12 −12 actionpack/lib/action_controller/{base → metal}/render_options.rb
  43. +4 −18 actionpack/lib/action_controller/{base/renderer.rb → metal/rendering_controller.rb}
  44. 0 actionpack/lib/action_controller/{base → metal}/request_forgery_protection.rb
  45. 0 actionpack/lib/action_controller/{base → metal}/rescuable.rb
  46. +181 −0 actionpack/lib/action_controller/metal/responder.rb
  47. 0 actionpack/lib/action_controller/{base → metal}/session.rb
  48. 0 actionpack/lib/action_controller/{base → metal}/session_management.rb
  49. +5 −3 actionpack/lib/action_controller/{base → metal}/streaming.rb
  50. 0 actionpack/lib/action_controller/{base → metal}/testing.rb
  51. 0 actionpack/lib/action_controller/{base → metal}/url_for.rb
  52. +2 −2 actionpack/lib/action_controller/{base → metal}/verification.rb
  53. +0 −84 actionpack/lib/action_controller/old_base.rb
  54. +0 −15 actionpack/lib/action_controller/record_identifier.rb
  55. +17 −11 actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb
  56. +0 −7 actionpack/lib/action_controller/routing/route_set.rb
  57. +1 −1 actionpack/lib/action_controller/testing/process.rb
  58. +2 −2 actionpack/lib/action_dispatch/http/request.rb
  59. +26 −42 actionpack/lib/action_dispatch/http/response.rb
  60. +10 −3 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  61. +26 −16 actionpack/lib/action_view/base.rb
  62. +2 −2 actionpack/lib/action_view/context.rb
  63. +1 −3 actionpack/lib/action_view/helpers/active_model_helper.rb
  64. +15 −11 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  65. +1 −1 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  66. +10 −2 actionpack/lib/action_view/helpers/form_helper.rb
  67. +8 −1 actionpack/lib/action_view/helpers/form_tag_helper.rb
  68. +1 −1 actionpack/lib/action_view/helpers/number_helper.rb
  69. +11 −10 actionpack/lib/action_view/helpers/tag_helper.rb
  70. +21 −11 actionpack/lib/action_view/helpers/text_helper.rb
  71. +5 −5 actionpack/lib/action_view/paths.rb
  72. +87 −103 actionpack/lib/action_view/render/partials.rb
  73. +64 −43 actionpack/lib/action_view/render/rendering.rb
  74. +1 −1 actionpack/lib/action_view/template/resolver.rb
  75. +8 −4 actionpack/lib/action_view/template/template.rb
  76. +3 −1 actionpack/lib/action_view/template/text.rb
  77. +3 −3 actionpack/lib/action_view/test_case.rb
  78. +5 −5 actionpack/test/abstract_controller/abstract_controller_test.rb
  79. +2 −2 actionpack/test/abstract_controller/helper_test.rb
  80. +1 −1 actionpack/test/abstract_controller/layouts_test.rb
  81. +1 −1 actionpack/test/abstract_controller/test_helper.rb
  82. +1 −2 actionpack/test/abstract_unit.rb
  83. +54 −1 actionpack/test/activerecord/polymorphic_routes_test.rb
  84. +7 −0 actionpack/test/controller/assert_select_test.rb
  85. +15 −0 actionpack/test/controller/caching_test.rb
  86. +25 −0 actionpack/test/controller/http_basic_authentication_test.rb
  87. +29 −6 actionpack/test/controller/http_digest_authentication_test.rb
  88. +2 −1 actionpack/test/controller/logging_test.rb
  89. +158 −40 actionpack/test/controller/mime_responds_test.rb
  90. +0 −57 actionpack/test/controller/record_identifier_test.rb
  91. +10 −0 actionpack/test/controller/redirect_test.rb
  92. +20 −3 actionpack/test/controller/render_test.rb
  93. +2 −2 actionpack/test/controller/render_xml_test.rb
  94. +1 −1 actionpack/test/controller/routing_test.rb
  95. +15 −2 actionpack/test/controller/send_file_test.rb
  96. +0 −2 actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  97. +28 −0 actionpack/test/dispatch/request_test.rb
  98. +4 −6 actionpack/test/dispatch/response_test.rb
  99. +1 −0 actionpack/test/fixtures/respond_with/edit.html.erb
  100. +1 −0 actionpack/test/fixtures/respond_with/new.html.erb
  101. +0 −1 actionpack/test/fixtures/respond_with/using_resource.html.erb
  102. +1 −0 actionpack/test/fixtures/respond_with/using_resource.js.rjs
  103. +1 −0 actionpack/test/fixtures/test/greeting.xml.erb
  104. +22 −0 actionpack/test/lib/controller/fake_models.rb
  105. +0 −3 actionpack/test/new_base/base_test.rb
  106. +10 −6 actionpack/test/template/asset_tag_helper_test.rb
  107. +29 −0 actionpack/test/template/atom_feed_helper_test.rb
  108. +1 −1 actionpack/test/template/body_parts_test.rb
  109. +10 −0 actionpack/test/template/form_helper_test.rb
  110. +12 −0 actionpack/test/template/form_tag_helper_test.rb
  111. +1 −0 actionpack/test/template/number_helper_test.rb
  112. +13 −0 actionpack/test/template/tag_helper_test.rb
  113. +17 −0 actionpack/test/template/text_helper_test.rb
  114. +1 −0 activemodel/lib/active_model.rb
  115. +267 −0 activemodel/lib/active_model/attribute_methods.rb
  116. +3 −3 activemodel/lib/active_model/errors.rb
  117. +2 −5 activemodel/lib/active_model/state_machine.rb
  118. +5 −7 activemodel/lib/active_model/state_machine/event.rb
  119. +13 −16 activemodel/lib/active_model/state_machine/machine.rb
  120. +1 −1 activemodel/lib/active_model/state_machine/state_transition.rb
  121. +23 −1 activemodel/lib/active_model/validations.rb
  122. +15 −6 activemodel/lib/active_model/validations/length.rb
  123. +20 −3 activemodel/test/cases/validations/length_validation_test.rb
  124. +14 −0 activemodel/test/cases/validations/presence_validation_test.rb
  125. +14 −0 activemodel/test/cases/validations_test.rb
  126. +17 −0 activemodel/test/models/custom_reader.rb
  127. +4 −0 activerecord/CHANGELOG
  128. +2 −2 activerecord/Rakefile
  129. +11 −1 activerecord/lib/active_record.rb
  130. +2 −2 activerecord/lib/active_record/associations.rb
  131. +5 −1 activerecord/lib/active_record/associations/has_many_through_association.rb
  132. +12 −360 activerecord/lib/active_record/attribute_methods.rb
  133. +33 −0 activerecord/lib/active_record/attribute_methods/before_type_cast.rb
  134. +204 −0 activerecord/lib/active_record/attribute_methods/dirty.rb
  135. +44 −0 activerecord/lib/active_record/attribute_methods/primary_key.rb
  136. +37 −0 activerecord/lib/active_record/attribute_methods/query.rb
  137. +116 −0 activerecord/lib/active_record/attribute_methods/read.rb
  138. +60 −0 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  139. +37 −0 activerecord/lib/active_record/attribute_methods/write.rb
  140. +13 −102 activerecord/lib/active_record/base.rb
  141. +2 −0 activerecord/lib/active_record/calculations.rb
  142. +6 −1 activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
  143. +1 −2 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  144. +4 −0 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  145. +0 −1 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  146. +0 −186 activerecord/lib/active_record/dirty.rb
  147. +18 −7 activerecord/lib/active_record/migration.rb
  148. +0 −1 activerecord/lib/active_record/schema_dumper.rb
  149. +24 −0 activerecord/lib/active_record/state_machine.rb
  150. +11 −14 activerecord/test/cases/adapter_test.rb
  151. +4 −2 activerecord/test/cases/associations/belongs_to_associations_test.rb
  152. +6 −1 activerecord/test/cases/associations/eager_test.rb
  153. +4 −2 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  154. +42 −38 activerecord/test/cases/associations/has_many_associations_test.rb
  155. +12 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  156. +7 −3 activerecord/test/cases/associations/join_model_test.rb
  157. +49 −26 activerecord/test/cases/attribute_methods_test.rb
  158. +36 −10 activerecord/test/cases/autosave_association_test.rb
  159. +86 −5 activerecord/test/cases/base_test.rb
  160. +12 −1 activerecord/test/cases/calculations_test.rb
  161. +8 −1 activerecord/test/cases/database_statements_test.rb
  162. +20 −0 activerecord/test/cases/dirty_test.rb
  163. +63 −48 activerecord/test/cases/finder_test.rb
  164. +1 −1 activerecord/test/cases/fixtures_test.rb
  165. +2 −1 activerecord/test/cases/inheritance_test.rb
  166. +12 −2 activerecord/test/cases/invalid_date_test.rb
  167. +2 −1 activerecord/test/cases/method_scoping_test.rb
  168. +62 −21 activerecord/test/cases/migration_test.rb
  169. +42 −0 activerecord/test/cases/modules_test.rb
  170. +2 −1 activerecord/test/cases/named_scope_test.rb
  171. +37 −0 activerecord/test/cases/nested_attributes_test.rb
  172. +6 −1 activerecord/test/cases/query_cache_test.rb
  173. +19 −1 activerecord/test/cases/schema_dumper_test.rb
  174. +42 −0 activerecord/test/cases/state_machine_test.rb
  175. +23 −0 activerecord/test/cases/validations/association_validation_test.rb
  176. +48 −7 activerecord/test/connections/native_oracle/connection.rb
  177. +6 −2 activerecord/test/models/company.rb
  178. +1 −1 activerecord/test/models/company_in_module.rb
  179. +2 −0 activerecord/test/models/organization.rb
  180. +9 −1 activerecord/test/models/subject.rb
  181. +27 −0 activerecord/test/models/traffic_light.rb
  182. +27 −0 activerecord/test/schema/oracle_specific_schema.rb
  183. +34 −4 activerecord/test/schema/schema.rb
  184. +5 −0 activeresource/CHANGELOG
  185. +22 −0 activeresource/lib/active_resource/base.rb
  186. +27 −5 activeresource/lib/active_resource/connection.rb
  187. +64 −0 activeresource/test/base_test.rb
  188. +21 −0 activeresource/test/connection_test.rb
  189. +4 −0 activeresource/test/fixtures/proxy.rb
  190. +12 −4 activesupport/lib/active_support/core_ext/enumerable.rb
  191. +2 −1 activesupport/lib/active_support/core_ext/load_error.rb
  192. +5 −0 activesupport/lib/active_support/core_ext/string/bytesize.rb
  193. +2 −3 activesupport/lib/active_support/core_ext/string/interpolation.rb
  194. +8 −8 activesupport/lib/active_support/core_ext/time/calculations.rb
  195. +9 −9 activesupport/lib/active_support/deprecation/method_wrappers.rb
  196. +10 −7 activesupport/lib/active_support/json/backends/yaml.rb
  197. +1 −1 activesupport/test/core_ext/date_ext_test.rb
  198. +9 −0 activesupport/test/core_ext/enumerable_test.rb
  199. +7 −0 activesupport/test/core_ext/string_ext_test.rb
  200. +23 −23 activesupport/test/core_ext/time_ext_test.rb
  201. +4 −0 activesupport/test/deprecation_test.rb
  202. +7 −1 activesupport/test/json/decoding_test.rb
  203. +0 −7 railties/lib/commands/server.rb
  204. +44 −22 railties/lib/generators.rb
  205. +10 −1 railties/lib/generators/actions.rb
  206. +7 −7 railties/lib/generators/{action_orm.rb → active_model.rb}
  207. +2 −2 railties/lib/generators/active_record.rb
  208. +2 −4 railties/lib/generators/active_record/model/model_generator.rb
  209. +5 −1 railties/lib/generators/active_record/session_migration/session_migration_generator.rb
  210. +7 −6 railties/lib/generators/named_base.rb
  211. +18 −3 railties/lib/generators/rails/app/app_generator.rb
  212. +1 −1 railties/lib/generators/rails/app/templates/config/boot.rb
  213. +5 −5 railties/lib/generators/rails/app/templates/config/environment.rb
  214. +1 −2 railties/lib/generators/rails/mailer/templates/mailer.rb
  215. +3 −1 railties/lib/generators/test_unit/plugin/templates/test_helper.rb
  216. +0 −1 railties/lib/initializer.rb
  217. +2 −1 railties/lib/rails/configuration.rb
  218. +19 −4 railties/lib/tasks/databases.rake
  219. +4 −3 railties/lib/tasks/routes.rake
  220. +0 −27 railties/lib/vendor/thor-0.11.3/lib/thor/error.rb
  221. +0 −4 railties/lib/vendor/thor-0.11.3/lib/thor/tasks.rb
  222. +0 −35 railties/lib/vendor/thor-0.11.3/lib/thor/tasks/install.rb
  223. +0 −31 railties/lib/vendor/thor-0.11.3/lib/thor/tasks/package.rb
  224. +0 −70 railties/lib/vendor/thor-0.11.3/lib/thor/tasks/spec.rb
  225. +4 −2 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/CHANGELOG.rdoc
  226. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/LICENSE
  227. +31 −44 railties/lib/vendor/{thor-0.11.3/README.markdown → thor-0.11.5/README.rdoc}
  228. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/bin/rake2thor
  229. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/bin/thor
  230. +21 −18 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor.rb
  231. +16 −14 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions.rb
  232. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions/create_file.rb
  233. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions/directory.rb
  234. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions/empty_directory.rb
  235. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions/file_manipulation.rb
  236. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/actions/inject_into_file.rb
  237. +18 −24 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/base.rb
  238. +2 −2 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/core_ext/hash_with_indifferent_access.rb
  239. +1 −3 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/core_ext/ordered_hash.rb
  240. +27 −0 railties/lib/vendor/thor-0.11.5/lib/thor/error.rb
  241. +3 −3 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/group.rb
  242. +24 −18 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/invocation.rb
  243. 0 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/parser.rb
  244. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/parser/argument.rb
  245. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/parser/arguments.rb
  246. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/parser/option.rb
  247. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/parser/options.rb
  248. +67 −0 railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb
  249. +13 −9 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/runner.rb
  250. +1 −1 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/shell.rb
  251. +21 −17 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/shell/basic.rb
  252. +9 −7 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/shell/color.rb
  253. +16 −8 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/task.rb
  254. +31 −10 railties/lib/vendor/{thor-0.11.3 → thor-0.11.5}/lib/thor/util.rb
  255. +1 −0 railties/test/fixtures/lib/template.rb
  256. 0 railties/test/fixtures/vendor/gems/{ → gems}/mspec/lib/generators/mspec_generator.rb
  257. 0 railties/test/fixtures/vendor/gems/{ → gems}/wrong/lib/generators/wrong_generator.rb
  258. +15 −0 railties/test/generators/actions_test.rb
  259. +5 −0 railties/test/generators/app_generator_test.rb
  260. +1 −1 railties/test/generators/generators_test_helper.rb
  261. +44 −0 railties/test/generators/model_generator_test.rb
  262. +1 −1 railties/test/generators/scaffold_controller_generator_test.rb
  263. +18 −0 railties/test/generators/session_migration_generator_test.rb
  264. +2 −1 railties/test/initializer/path_test.rb
View
@@ -11,6 +11,7 @@ actionpack/pkg
activemodel/test/fixtures/fixture_database.sqlite3
actionmailer/pkg
activesupport/pkg
+activesupport/test/fixtures/isolation_test
railties/pkg
railties/test/500.html
railties/test/fixtures/tmp
@@ -1,3 +1,5 @@
+require 'tmpdir'
+
require "active_support/core_ext/class"
# Use the old layouts until actionmailer gets refactored
require "action_controller/legacy/layout"
@@ -224,9 +226,13 @@ module ActionMailer #:nodoc:
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
# * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt>.
#
+ # * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method.
+ # * <tt>:location</tt> - The directory into which emails will be written. Defaults to the application <tt>tmp/mails</tt>.
+ #
# * <tt>raise_delivery_errors</tt> - Whether or not errors should be raised if the email fails to be delivered.
#
- # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, and <tt>:test</tt>.
+ # * <tt>delivery_method</tt> - Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, <tt>:test</tt>,
+ # and <tt>:file</tt>.
#
# * <tt>perform_deliveries</tt> - Determines whether <tt>deliver_*</tt> methods are actually carried out. By default they are,
# but this can be turned off to help functional testing.
@@ -279,6 +285,12 @@ class Base
}
cattr_accessor :sendmail_settings
+ @@file_settings = {
+ :location => defined?(Rails) ? "#{Rails.root}/tmp/mails" : "#{Dir.tmpdir}/mails"
+ }
+
+ cattr_accessor :file_settings
+
@@raise_delivery_errors = true
cattr_accessor :raise_delivery_errors
@@ -499,7 +511,7 @@ def create!(method_name, *parameters) #:nodoc:
# ====
# TODO: Revisit this
# template_exists = @parts.empty?
- # template_exists ||= template_root.find_by_parts("#{mailer_name}/#{@template}")
+ # template_exists ||= template_root.find("#{mailer_name}/#{@template}")
# @body = render_message(@template, @body) if template_exists
# Finally, if there are other message parts and a textual body exists,
@@ -556,6 +568,7 @@ def initialize_defaults(method_name)
@headers ||= {}
@body ||= {}
@mime_version = @@default_mime_version.dup if @@default_mime_version
+ @sent_on ||= Time.now
end
def render_template(template, body)
@@ -566,7 +579,7 @@ def render_template(template, body)
@template = initialize_template_class(body)
layout = _pick_layout(layout, true) unless
ActionController::Base.exempt_from_layout.include?(template.handler)
- @template._render_template_with_layout(template, layout, {})
+ @template._render_template(template, layout, {})
ensure
@current_template_content_type = nil
end
@@ -585,14 +598,14 @@ def render(opts)
if file
prefix = mailer_name unless file =~ /\//
- template = view_paths.find_by_parts(file, {:formats => formats}, prefix)
+ template = view_paths.find(file, {:formats => formats}, prefix)
end
layout = _pick_layout(layout,
!template || ActionController::Base.exempt_from_layout.include?(template.handler))
if template
- @template._render_template_with_layout(template, layout, opts)
+ @template._render_template(template, layout, opts)
elsif inline = opts[:inline]
@template._render_inline(inline, layout, opts)
end
@@ -723,6 +736,14 @@ def perform_delivery_sendmail(mail)
def perform_delivery_test(mail)
deliveries << mail
end
+
+ def perform_delivery_file(mail)
+ FileUtils.mkdir_p file_settings[:location]
+
+ (mail.to + mail.cc + mail.bcc).uniq.each do |to|
+ File.open(File.join(file_settings[:location], to), 'a') { |f| f.write(mail) }
+ end
+ end
end
Base.class_eval do
@@ -7,6 +7,10 @@ class NonDefaultDeliveryMethodMailer < ActionMailer::Base
self.delivery_method = :sendmail
end
+class FileDeliveryMethodMailer < ActionMailer::Base
+ self.delivery_method = :file
+end
+
class ActionMailerBase_delivery_method_Test < Test::Unit::TestCase
def setup
set_delivery_method :smtp
@@ -49,3 +53,21 @@ def test_should_be_the_set_delivery_method
end
end
+class FileDeliveryMethodMailer_delivery_method_Test < Test::Unit::TestCase
+ def setup
+ set_delivery_method :smtp
+ end
+
+ def teardown
+ restore_delivery_method
+ end
+
+ def test_should_be_the_set_delivery_method
+ assert_equal :file, FileDeliveryMethodMailer.delivery_method
+ end
+
+ def test_should_default_location_to_the_tmpdir
+ assert_equal "#{Dir.tmpdir}/mails", ActionMailer::Base.file_settings[:location]
+ end
+end
+
@@ -18,7 +18,6 @@ def signed_up(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
@from = "system@loudthinking.com"
- @sent_on = Time.local(2004, 12, 12)
@body["recipient"] = recipient
end
@@ -357,12 +356,14 @@ def test_attachment_with_custom_header
end
def test_signed_up
+ Time.stubs(:now => Time.now)
+
expected = new_mail
expected.to = @recipient
expected.subject = "[Signed up] Welcome #{@recipient}"
expected.body = "Hello there, \n\nMr. #{@recipient}"
expected.from = "system@loudthinking.com"
- expected.date = Time.local(2004, 12, 12)
+ expected.date = Time.now
created = nil
assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) }
@@ -573,12 +574,14 @@ def initialize
@info_contents, @debug_contents = "", ""
end
- def info(str)
- @info_contents << str
+ def info(str = nil, &blk)
+ @info_contents << str if str
+ @info_contents << blk.call if block_given?
end
- def debug(str)
- @debug_contents << str
+ def debug(str = nil, &blk)
+ @debug_contents << str if str
+ @debug_contents << blk.call if block_given?
end
end
@@ -886,6 +889,18 @@ def test_headers_removed_on_smtp_delivery
assert_no_match %r{^Bcc: root@loudthinking.com}, MockSMTP.deliveries[0][0]
end
+ def test_file_delivery_should_create_a_file
+ ActionMailer::Base.delivery_method = :file
+ tmp_location = ActionMailer::Base.file_settings[:location]
+
+ TestMailer.deliver_cc_bcc(@recipient)
+ assert File.exists?(tmp_location)
+ assert File.directory?(tmp_location)
+ assert File.exists?(File.join(tmp_location, @recipient))
+ assert File.exists?(File.join(tmp_location, 'nobody@loudthinking.com'))
+ assert File.exists?(File.join(tmp_location, 'root@loudthinking.com'))
+ end
+
def test_recursive_multipart_processing
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email7")
mail = TMail::Mail.parse(fixture)
@@ -1,5 +1,9 @@
*Edge*
+* Make sure javascript_include_tag/stylesheet_link_tag does not append ".js" or ".css" onto external urls. #1664 [Matthew Rudy Jacobs]
+
+* Ruby 1.9: fix Content-Length for multibyte send_data streaming. #2661 [Sava Chankov]
+
* Ruby 1.9: ERB template encoding using a magic comment at the top of the file. [Jeremy Kemper]
<%# encoding: utf-8 %>
@@ -3,13 +3,19 @@
ENV['NO_RELOAD'] ||= '1'
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
require 'action_controller'
require 'action_controller/new_base' if ENV['NEW']
+require 'action_view'
require 'benchmark'
class Runner
- def initialize(app)
- @app = app
+ def initialize(app, output)
+ @app, @output = app, output
+ end
+
+ def puts(*)
+ super if @output
end
def call(env)
@@ -18,16 +24,22 @@ def call(env)
end
def report(env, response)
+ return unless ENV["DEBUG"]
out = env['rack.errors']
out.puts response[0], response[1].to_yaml, '---'
response[2].each { |part| out.puts part }
out.puts '---'
end
- def self.run(app, n, label = nil)
- puts '=' * label.size, label, '=' * label.size if label
- env = { 'n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout }
- t = Benchmark.realtime { new(app).call(env) }
+ def self.puts(*)
+ super if @output
+ end
+
+ def self.run(app, n, label, output = true)
+ @output = output
+ puts label, '=' * label.size if label
+ env = Rack::MockRequest.env_for("/").merge('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
+ t = Benchmark.realtime { new(app, output).call(env) }
puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
puts
end
@@ -36,23 +48,71 @@ def self.run(app, n, label = nil)
N = (ENV['N'] || 1000).to_i
+module ActionController::Rails2Compatibility
+ instance_methods.each do |name|
+ remove_method name
+ end
+end
+
class BasePostController < ActionController::Base
+ append_view_path "#{File.dirname(__FILE__)}/views"
+
+ def overhead
+ self.response_body = ''
+ end
+
def index
render :text => ''
end
+
+ def partial
+ render :partial => "/partial"
+ end
+
+ def many_partials
+ render :partial => "/many_partials"
+ end
+
+ def partial_collection
+ render :partial => "/collection", :collection => [1,2,3,4,5,6,7,8,9,10]
+ end
+
+ def show_template
+ render :template => "template"
+ end
end
OK = [200, {}, []]
MetalPostController = lambda { OK }
-if ActionController.const_defined?(:Http)
- class HttpPostController < ActionController::Http
- def index
- self.response_body = ''
- end
+class HttpPostController < ActionController::Metal
+ def index
+ self.response_body = ''
end
end
-Runner.run(MetalPostController, N, 'metal')
-Runner.run(HttpPostController.action(:index), N, 'http') if defined? HttpPostController
-Runner.run(BasePostController.action(:index), N, 'base')
+unless ENV["PROFILE"]
+ Runner.run(BasePostController.action(:overhead), N, 'overhead', false)
+ Runner.run(BasePostController.action(:index), N, 'index', false)
+ Runner.run(BasePostController.action(:partial), N, 'partial', false)
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials', false)
+ Runner.run(BasePostController.action(:partial_collection), N, 'collection', false)
+ Runner.run(BasePostController.action(:show_template), N, 'template', false)
+
+ (ENV["M"] || 1).to_i.times do
+ Runner.run(BasePostController.action(:overhead), N, 'overhead')
+ Runner.run(BasePostController.action(:index), N, 'index')
+ Runner.run(BasePostController.action(:partial), N, 'partial')
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
+ Runner.run(BasePostController.action(:partial_collection), N, 'collection')
+ Runner.run(BasePostController.action(:show_template), N, 'template')
+ end
+else
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
+ require "ruby-prof"
+ RubyProf.start
+ Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
+ result = RubyProf.stop
+ printer = RubyProf::CallStackPrinter.new(result)
+ printer.print(File.open("output.html", "w"))
+end
@@ -3,17 +3,17 @@
require "action_controller"
-class Kaigi < ActionController::Http
+class Kaigi < ActionController::Metal
include AbstractController::Callbacks
include ActionController::RackConvenience
- include ActionController::Renderer
+ include ActionController::RenderingController
include ActionController::Layouts
include ActionView::Context
before_filter :set_name
append_view_path "views"
- def _action_view
+ def view_context
self
end
@@ -23,7 +23,7 @@ def controller
DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
- def _render_template_from_controller(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
+ def render_template(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
ret = template.render(self, {})
layout.render(self, {}) { ret }
end
@@ -47,4 +47,4 @@ def set_name
map("/kaigi/alt") { run Kaigi.action(:alt) }
end.to_app
-Rack::Handler::Mongrel.run app, :Port => 3000
+Rack::Handler::Mongrel.run app, :Port => 3000
@@ -0,0 +1 @@
+<%= collection %>
@@ -0,0 +1 @@
+Hello
@@ -0,0 +1,10 @@
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
+<%= render :partial => '/hello' %>
Oops, something went wrong. Retry.

0 comments on commit 2e50110

Please sign in to comment.