Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'mainstream/master'

Conflicts:

	actionmailer/lib/action_mailer/base.rb
	actionpack/lib/action_controller/base.rb
	actionpack/lib/action_controller/mime_type.rb
	railties/doc/guides/html/activerecord_validations_callbacks.html
	railties/doc/guides/html/caching_with_rails.html
	railties/doc/guides/html/command_line.html
	railties/doc/guides/html/configuring.html
	railties/doc/guides/html/creating_plugins.html
	railties/doc/guides/html/finders.html
	railties/doc/guides/html/routing_outside_in.html
	railties/doc/guides/source/activerecord_validations_callbacks.txt
	railties/doc/guides/source/caching_with_rails.txt
	railties/doc/guides/source/command_line.txt
	railties/doc/guides/source/creating_plugins/acts_as_yaffle.txt
	railties/doc/guides/source/creating_plugins/controllers.txt
	railties/doc/guides/source/creating_plugins/core_ext.txt
	railties/doc/guides/source/creating_plugins/helpers.txt
	railties/doc/guides/source/creating_plugins/index.txt
	railties/doc/guides/source/creating_plugins/migration_generator.txt
	railties/doc/guides/source/creating_plugins/models.txt
	railties/doc/guides/source/creating_plugins/odds_and_ends.txt
	railties/doc/guides/source/creating_plugins/routes.txt
	railties/doc/guides/source/finders.txt
	railties/doc/guides/source/routing_outside_in.txt
	railties/doc/guides/source/testing_rails_applications.txt
  • Loading branch information...
commit 8f1c229571b4db8dda144bf6eaa193799309e817 2 parents 601e40e + 9eca588
@lifo lifo authored
Showing with 3,886 additions and 11,118 deletions.
  1. +7 −0 actionmailer/CHANGELOG
  2. +1 −1  actionmailer/Rakefile
  3. +22 −13 actionmailer/lib/action_mailer.rb
  4. +64 −85 actionmailer/lib/action_mailer/base.rb
  5. +2 −0  actionmailer/lib/action_mailer/helpers.rb
  6. +0 −2  actionmailer/lib/action_mailer/mail_helper.rb
  7. +2 −8 actionmailer/lib/action_mailer/part.rb
  8. +5 −1 actionmailer/lib/action_mailer/part_container.rb
  9. +1 −1  actionmailer/lib/action_mailer/quoting.rb
  10. +1 −1  actionmailer/lib/action_mailer/test_case.rb
  11. +1 −0  actionmailer/lib/action_mailer/test_helper.rb
  12. +0 −1  actionmailer/lib/action_mailer/utils.rb
  13. +0 −14 actionmailer/lib/action_mailer/vendor.rb
  14. +10 −0 actionmailer/lib/action_mailer/vendor/text_format.rb
  15. +17 −0 actionmailer/lib/action_mailer/vendor/tmail.rb
  16. +2 −2 actionmailer/lib/action_mailer/version.rb
  17. +4 −0 actionmailer/test/abstract_unit.rb
  18. +54 −0 actionmailer/test/asset_host_test.rb
  19. +1 −0  actionmailer/test/fixtures/asset_host_mailer/email_with_asset.html.erb
  20. +1 −0  actionmailer/test/fixtures/auto_layout_mailer/multipart.text.html.erb
  21. +1 −0  actionmailer/test/fixtures/auto_layout_mailer/multipart.text.plain.erb
  22. +1 −0  actionmailer/test/fixtures/layouts/auto_layout_mailer.text.erb
  23. +17 −0 actionmailer/test/mail_layout_test.rb
  24. +8 −0 actionmailer/test/mail_service_test.rb
  25. +0 −1  actionmailer/test/quoting_test.rb
  26. +4 −4 actionmailer/test/test_helper_test.rb
  27. +52 −1 actionpack/CHANGELOG
  28. +2 −1  actionpack/Rakefile
  29. +74 −42 actionpack/lib/action_controller.rb
  30. +0 −69 actionpack/lib/action_controller/assertions.rb
  31. +1 −0  actionpack/lib/action_controller/assertions/model_assertions.rb
  32. +0 −3  actionpack/lib/action_controller/assertions/response_assertions.rb
  33. +0 −3  actionpack/lib/action_controller/assertions/selector_assertions.rb
  34. +1 −4 actionpack/lib/action_controller/assertions/tag_assertions.rb
  35. +26 −68 actionpack/lib/action_controller/base.rb
  36. +8 −10 actionpack/lib/action_controller/caching.rb
  37. +11 −11 actionpack/lib/action_controller/caching/fragments.rb
  38. +2 −0  actionpack/lib/action_controller/cgi_ext/cookie.rb
  39. +52 −165 actionpack/lib/action_controller/cgi_process.rb
  40. +0 −169 actionpack/lib/action_controller/components.rb
  41. +19 −78 actionpack/lib/action_controller/dispatcher.rb
  42. +52 −0 actionpack/lib/action_controller/failsafe.rb
  43. +1 −1  actionpack/lib/action_controller/flash.rb
  44. +10 −6 actionpack/lib/action_controller/helpers.rb
  45. +5 −7 actionpack/lib/action_controller/integration.rb
  46. +10 −28 actionpack/lib/action_controller/layout.rb
  47. +42 −0 actionpack/lib/action_controller/middleware_stack.rb
  48. +2 −4 actionpack/lib/action_controller/mime_type.rb
  49. +0 −1  actionpack/lib/action_controller/performance_test.rb
  50. +21 −21 actionpack/lib/action_controller/polymorphic_routes.rb
  51. +1 −2  actionpack/lib/action_controller/rack_process.rb
  52. +5 −7 actionpack/lib/action_controller/request.rb
  53. +7 −39 actionpack/lib/action_controller/request_forgery_protection.rb
  54. +0 −1  actionpack/lib/action_controller/request_profiler.rb
  55. +44 −32 actionpack/lib/action_controller/rescue.rb
  56. +2 −8 actionpack/lib/action_controller/resources.rb
  57. +0 −1  actionpack/lib/action_controller/routing.rb
  58. +2 −0  actionpack/lib/action_controller/routing/builder.rb
  59. +3 −7 actionpack/lib/action_controller/routing/optimisations.rb
  60. +15 −5 actionpack/lib/action_controller/routing/route.rb
  61. +60 −15 actionpack/lib/action_controller/routing/route_set.rb
  62. +31 −0 actionpack/lib/action_controller/routing/segments.rb
  63. +14 −18 actionpack/lib/action_controller/session/cookie_store.rb
  64. +0 −7 actionpack/lib/action_controller/session_management.rb
  65. +2 −2 actionpack/lib/action_controller/templates/rescues/diagnostics.erb
  66. +2 −2 actionpack/lib/action_controller/templates/rescues/template_error.erb
  67. +72 −21 actionpack/lib/action_controller/test_case.rb
  68. +13 −13 actionpack/lib/action_controller/test_process.rb
  69. +16 −0 actionpack/lib/action_controller/vendor/html-scanner.rb
  70. +2 −2 actionpack/lib/action_pack/version.rb
  71. +21 −17 actionpack/lib/action_view.rb
  72. +22 −17 actionpack/lib/action_view/base.rb
  73. +38 −0 actionpack/lib/action_view/erb/util.rb
  74. +24 −5 actionpack/lib/action_view/helpers.rb
  75. +47 −33 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  76. +1 −1  actionpack/lib/action_view/helpers/date_helper.rb
  77. +0 −3  actionpack/lib/action_view/helpers/javascript_helper.rb
  78. +0 −963 actionpack/lib/action_view/helpers/javascripts/controls.js
  79. +0 −972 actionpack/lib/action_view/helpers/javascripts/dragdrop.js
  80. +0 −1,120 actionpack/lib/action_view/helpers/javascripts/effects.js
  81. +0 −4,221 actionpack/lib/action_view/helpers/javascripts/prototype.js
  82. +3 −4 actionpack/lib/action_view/helpers/number_helper.rb
  83. +1 −0  actionpack/lib/action_view/helpers/prototype_helper.rb
  84. +0 −10 actionpack/lib/action_view/helpers/sanitize_helper.rb
  85. +1 −0  actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  86. +1 −2  actionpack/lib/action_view/helpers/tag_helper.rb
  87. +97 −121 actionpack/lib/action_view/helpers/text_helper.rb
  88. +2 −1  actionpack/lib/action_view/locale/{en-US.yml → en.yml}
  89. +32 −0 actionpack/lib/action_view/partials.rb
  90. +59 −18 actionpack/lib/action_view/paths.rb
  91. +4 −2 actionpack/lib/action_view/renderable.rb
  92. +25 −11 actionpack/lib/action_view/template.rb
  93. +8 −9 actionpack/lib/action_view/template_error.rb
  94. +23 −3 actionpack/lib/action_view/template_handler.rb
  95. +4 −5 actionpack/lib/action_view/template_handlers.rb
  96. +0 −39 actionpack/lib/action_view/template_handlers/erb.rb
  97. +1 −0  actionpack/lib/action_view/template_handlers/rjs.rb
  98. +2 −2 actionpack/lib/action_view/test_case.rb
  99. +13 −13 actionpack/test/abstract_unit.rb
  100. +3 −3 actionpack/test/active_record_unit.rb
  101. +0 −1  actionpack/test/activerecord/active_record_store_test.rb
  102. +3 −19 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  103. +19 −17 actionpack/test/controller/action_pack_assertions_test.rb
  104. +68 −68 actionpack/test/controller/assert_select_test.rb
  105. +1 −1  actionpack/test/controller/base_test.rb
  106. +14 −12 actionpack/test/controller/caching_test.rb
  107. +0 −262 actionpack/test/controller/cgi_test.rb
  108. +0 −156 actionpack/test/controller/components_test.rb
  109. +9 −11 actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
  110. +18 −22 actionpack/test/controller/dispatcher_test.rb
  111. +15 −1 actionpack/test/controller/helper_test.rb
  112. +1 −1  actionpack/test/controller/html-scanner/sanitizer_test.rb
  113. +0 −2  actionpack/test/controller/integration_test.rb
  114. +0 −2  actionpack/test/controller/integration_upload_test.rb
  115. +12 −35 actionpack/test/controller/layout_test.rb
  116. +6 −10 actionpack/test/controller/mime_responds_test.rb
  117. +17 −10 actionpack/test/controller/polymorphic_routes_test.rb
  118. +4 −7 actionpack/test/controller/rack_test.rb
  119. +4 −12 actionpack/test/controller/redirect_test.rb
  120. +57 −30 actionpack/test/controller/render_test.rb
  121. +8 −89 actionpack/test/controller/request_forgery_protection_test.rb
  122. +28 −26 actionpack/test/controller/request_test.rb
  123. +0 −18 actionpack/test/controller/rescue_test.rb
  124. +21 −11 actionpack/test/controller/resources_test.rb
  125. +34 −8 actionpack/test/controller/routing_test.rb
  126. +2 −14 actionpack/test/controller/session/cookie_store_test.rb
  127. +0 −3  actionpack/test/controller/session/mem_cache_store_test.rb
  128. +44 −49 actionpack/test/controller/session_fixation_test.rb
  129. +11 −15 actionpack/test/controller/test_test.rb
  130. +38 −3 actionpack/test/controller/url_rewriter_test.rb
  131. +1 −1  actionpack/test/controller/verification_test.rb
  132. +14 −14 actionpack/test/controller/view_paths_test.rb
  133. +178 −145 actionpack/test/controller/webservice_test.rb
  134. +3 −0  actionpack/test/fixtures/alternate_helpers/foo_helper.rb
  135. +1 −0  actionpack/test/fixtures/test/_one.html.erb
  136. +1 −0  actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb
  137. +1 −0  actionpack/test/fixtures/test/_two.html.erb
  138. +1 −0  actionpack/test/fixtures/test/dont_pick_me
  139. +1 −1  actionpack/test/fixtures/test/hello.builder
  140. +1 −0  actionpack/test/fixtures/test/render_explicit_html_template.js.rjs
  141. +1 −0  actionpack/test/fixtures/test/render_implicit_html_template.js.rjs
  142. +12 −12 actionpack/test/template/active_record_helper_i18n_test.rb
  143. +46 −0 actionpack/test/template/asset_tag_helper_test.rb
  144. +3 −5 actionpack/test/template/atom_feed_helper_test.rb
  145. +49 −10 actionpack/test/template/compiled_templates_test.rb
  146. +11 −11 actionpack/test/template/date_helper_i18n_test.rb
  147. +2 −1  actionpack/test/template/form_options_helper_test.rb
  148. +1 −0  actionpack/test/template/form_tag_helper_test.rb
  149. +18 −15 actionpack/test/template/number_helper_i18n_test.rb
  150. +53 −17 actionpack/test/template/render_test.rb
  151. +100 −50 actionpack/test/template/text_helper_test.rb
  152. +3 −3 actionpack/test/template/translation_helper_test.rb
  153. +8 −6 activemodel/lib/active_model/state_machine.rb
  154. +2 −0  activemodel/lib/active_model/state_machine/event.rb
  155. +6 −2 activemodel/lib/active_model/state_machine/machine.rb
  156. +2 −5 activemodel/lib/active_model/state_machine/state.rb
  157. +18 −20 activemodel/test/observing_test.rb
  158. +8 −10 activemodel/test/state_machine/event_test.rb
  159. +2 −2 activemodel/test/state_machine/machine_test.rb
  160. +22 −24 activemodel/test/state_machine/state_test.rb
  161. +51 −55 activemodel/test/state_machine/state_transition_test.rb
  162. +81 −93 activemodel/test/state_machine_test.rb
  163. +9 −27 activemodel/test/test_helper.rb
  164. +18 −0 activerecord/CHANGELOG
  165. +1 −1  activerecord/Rakefile
  166. +39 −43 activerecord/lib/active_record.rb
  167. +1 −1  activerecord/lib/active_record/association_preload.rb
  168. +21 −14 activerecord/lib/active_record/associations.rb
  169. +5 −1 activerecord/lib/active_record/associations/association_proxy.rb
  170. +3 −4 activerecord/lib/active_record/associations/has_one_through_association.rb
  171. +46 −7 activerecord/lib/active_record/base.rb
  172. +4 −4 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  173. +2 −1  activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  174. +145 −140 activerecord/lib/active_record/fixtures.rb
  175. +1 −1  activerecord/lib/active_record/locale/{en-US.yml → en.yml}
  176. +3 −1 activerecord/lib/active_record/serialization.rb
  177. +3 −13 activerecord/lib/active_record/test_case.rb
  178. +2 −2 activerecord/lib/active_record/version.rb
  179. +0 −95 activerecord/test/cases/adapter_test_sqlserver.rb
  180. +0 −1  activerecord/test/cases/ar_schema_test.rb
  181. +19 −3 activerecord/test/cases/associations/eager_test.rb
  182. +5 −0 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  183. +5 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  184. +39 −1 activerecord/test/cases/associations/has_one_through_associations_test.rb
  185. +5 −8 activerecord/test/cases/base_test.rb
  186. +1 −5 activerecord/test/cases/binary_test.rb
  187. +1 −1  activerecord/test/cases/defaults_test.rb
  188. +7 −0 activerecord/test/cases/finder_test.rb
  189. +4 −4 activerecord/test/cases/fixtures_test.rb
  190. +18 −11 activerecord/test/cases/helper.rb
  191. +6 −6 activerecord/test/cases/i18n_test.rb
  192. +2 −2 activerecord/test/cases/inheritance_test.rb
  193. +2 −2 activerecord/test/cases/locking_test.rb
  194. +67 −0 activerecord/test/cases/method_scoping_test.rb
  195. +3 −7 activerecord/test/cases/migration_test.rb
  196. +0 −1  activerecord/test/cases/schema_dumper_test.rb
  197. +0 −23 activerecord/test/cases/table_name_test_sqlserver.rb
  198. +49 −49 activerecord/test/cases/validations_i18n_test.rb
  199. +5 −0 activerecord/test/fixtures/organizations.yml
  200. +1 −0  activerecord/test/models/author.rb
  201. +1 −0  activerecord/test/models/category.rb
  202. +12 −0 activerecord/test/models/developer.rb
  203. +2 −0  activerecord/test/models/member.rb
  204. +4 −0 activerecord/test/models/member_detail.rb
  205. +4 −0 activerecord/test/models/organization.rb
  206. +1 −0  activerecord/test/models/project.rb
  207. +10 −0 activerecord/test/schema/schema.rb
  208. +0 −5 activerecord/test/schema/sqlserver_specific_schema.rb
  209. +1 −1  activeresource/Rakefile
  210. +1 −0  activeresource/lib/active_resource/base.rb
  211. +2 −2 activeresource/lib/active_resource/version.rb
  212. +43 −43 activeresource/test/base_test.rb
  213. +14 −14 activeresource/test/format_test.rb
  214. +22 −1 activesupport/CHANGELOG
  215. +31 −33 activesupport/lib/active_support.rb
  216. +72 −0 activesupport/lib/active_support/backtrace_cleaner.rb
  217. +7 −6 activesupport/lib/active_support/cache.rb
  218. +2 −3 activesupport/lib/active_support/cache/drb_store.rb
  219. +1 −1  activesupport/lib/active_support/core_ext.rb
  220. +3 −23 activesupport/lib/active_support/core_ext/array/access.rb
  221. +1 −2  activesupport/lib/active_support/core_ext/array/conversions.rb
  222. +14 −5 activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb
  223. +9 −0 activesupport/lib/active_support/core_ext/enumerable.rb
  224. +12 −8 activesupport/lib/active_support/core_ext/exception.rb
  225. +2 −2 activesupport/lib/active_support/core_ext/file/atomic.rb
  226. +16 −45 activesupport/lib/active_support/core_ext/hash/conversions.rb
  227. +4 −0 activesupport/lib/active_support/core_ext/module/delegation.rb
  228. +2 −1  activesupport/lib/active_support/core_ext/object/conversions.rb
  229. +18 −0 activesupport/lib/active_support/core_ext/object/misc.rb
  230. +28 −23 activesupport/lib/active_support/core_ext/rexml.rb
  231. +3 −1 activesupport/lib/active_support/core_ext/string/iterators.rb
  232. +2 −0  activesupport/lib/active_support/core_ext/time/calculations.rb
  233. +8 −7 activesupport/lib/active_support/dependencies.rb
  234. +0 −52 activesupport/lib/active_support/deprecation.rb
  235. +2 −0  activesupport/lib/active_support/duration.rb
  236. +8 −3 activesupport/lib/active_support/inflector.rb
  237. +23 −29 activesupport/lib/active_support/json/encoding.rb
  238. +1 −1  activesupport/lib/active_support/locale/{en-US.yml → en.yml}
  239. +28 −16 activesupport/lib/active_support/memoizable.rb
  240. +70 −0 activesupport/lib/active_support/message_encryptor.rb
  241. +46 −0 activesupport/lib/active_support/message_verifier.rb
  242. +7 −1 activesupport/lib/active_support/option_merger.rb
  243. +8 −0 activesupport/lib/active_support/ordered_hash.rb
  244. +8 −6 activesupport/lib/active_support/secure_random.rb
  245. +32 −17 activesupport/lib/active_support/test_case.rb
  246. +61 −0 activesupport/lib/active_support/testing/assertions.rb
  247. +21 −0 activesupport/lib/active_support/testing/declarative.rb
  248. +55 −0 activesupport/lib/active_support/testing/deprecation.rb
  249. +52 −86 activesupport/lib/active_support/testing/setup_and_teardown.rb
  250. +1 −0  activesupport/lib/active_support/time_with_zone.rb
  251. +1 −0  activesupport/lib/active_support/values/time_zone.rb
  252. +4 −9 activesupport/lib/active_support/vendor.rb
  253. +3 −3 activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
  254. +0 −170 activesupport/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb
  255. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb
  256. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb
  257. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb
  258. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb
  259. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb
  260. 0  ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb
  261. 0  ...esupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb
  262. 0  ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb
  263. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb
  264. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb
  265. 0  ...ve_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb
  266. +86 −0 activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb
  267. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb
  268. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb
  269. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb
  270. 0  ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb
  271. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb
  272. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb
  273. 0  ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb
  274. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb
  275. 0  ...tive_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb
  276. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb
  277. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb
  278. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb
  279. 0  ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb
  280. 0  ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb
  281. 0  ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb
  282. 0  ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb
  283. 0  ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb
  284. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb
  285. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb
  286. 0  ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb
  287. 0  ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb
  288. 0  ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb
  289. 0  ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb
  290. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb
  291. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb
  292. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb
  293. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb
  294. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb
  295. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Colombo.rb
  296. 0  activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb
  297. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb
  298. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb
  299. 0  ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb
  300. 0  ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb
Sorry, we could not display the entire diff because too many files (623) changed.
View
7 actionmailer/CHANGELOG
@@ -1,3 +1,10 @@
+*2.3.0 [Edge]*
+
+* Fixed RFC-2045 quoted-printable bug #1421 [squadette]
+
+* Fixed that no body charset would be set when there are attachments present #740 [Paweł Kondzior]
+
+
*2.2.1 [RC2] (November 14th, 2008)*
* Turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it (This is required for Gmail's SMTP server) #1336 [Grant Hollingworth]
View
2  actionmailer/Rakefile
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
s.rubyforge_project = "actionmailer"
s.homepage = "http://www.rubyonrails.org"
- s.add_dependency('actionpack', '= 2.2.0' + PKG_BUILD)
+ s.add_dependency('actionpack', '= 2.3.0' + PKG_BUILD)
s.has_rdoc = true
s.requirements << 'none'
View
35 actionmailer/lib/action_mailer.rb
@@ -31,22 +31,31 @@
end
end
-require 'action_mailer/vendor'
-require 'tmail'
+require 'action_view'
-require 'action_mailer/base'
-require 'action_mailer/helpers'
-require 'action_mailer/mail_helper'
-require 'action_mailer/quoting'
-require 'action_mailer/test_helper'
+module ActionMailer
+ def self.load_all!
+ [Base, Part, ::Text::Format, ::Net::SMTP]
+ end
-require 'net/smtp'
+ autoload :AdvAttrAccessor, 'action_mailer/adv_attr_accessor'
+ autoload :Base, 'action_mailer/base'
+ autoload :Helpers, 'action_mailer/helpers'
+ autoload :Part, 'action_mailer/part'
+ autoload :PartContainer, 'action_mailer/part_container'
+ autoload :Quoting, 'action_mailer/quoting'
+ autoload :TestCase, 'action_mailer/test_case'
+ autoload :TestHelper, 'action_mailer/test_helper'
+ autoload :Utils, 'action_mailer/utils'
+end
-ActionMailer::Base.class_eval do
- include ActionMailer::Quoting
- include ActionMailer::Helpers
+module Text
+ autoload :Format, 'action_mailer/vendor/text_format'
+end
- helper MailHelper
+module Net
+ autoload :SMTP, 'net/smtp'
end
-silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
+autoload :MailHelper, 'action_mailer/mail_helper'
+autoload :TMail, 'action_mailer/vendor/tmail'
View
149 actionmailer/lib/action_mailer/base.rb
@@ -1,9 +1,3 @@
-require 'action_mailer/adv_attr_accessor'
-require 'action_mailer/part'
-require 'action_mailer/part_container'
-require 'action_mailer/utils'
-require 'tmail/net'
-
module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
#
@@ -201,9 +195,51 @@ module ActionMailer #:nodoc:
# end
#
#
- # Configuration options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
+ # = Configuration options
+ #
+ # These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
+ #
+ # * <tt>template_root</tt> - Determines the base from which template references will be made.
+ #
+ # * <tt>logger</tt> - the logger is used for generating information on the mailing run if available.
+ # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
+ #
+ # * <tt>smtp_settings</tt> - Allows detailed configuration for <tt>:smtp</tt> delivery method:
+ # * <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
+ # * <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
+ # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
+ # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
+ # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
+ # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here.
+ # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
+ #
+ # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
+ # * <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>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>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.
+ #
+ # * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with <tt>delivery_method :test</tt>. Most useful
+ # for unit and functional testing.
+ #
+ # * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
+ # pick a different charset from inside a method with +charset+.
+ # * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
+ # can also pick a different content type from inside a method with +content_type+.
+ # * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
+ # can also pick a different value from inside a method with +mime_version+.
+ # * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
+ # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
+ # <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
+ # and appear last in the mime encoded message. You can also pick a different order from inside a method with
+ # +implicit_parts_order+.
class Base
- include AdvAttrAccessor, PartContainer
+ include AdvAttrAccessor, PartContainer, Quoting, Utils
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
include ActionController::Layout
@@ -212,10 +248,6 @@ class Base
private_class_method :new #:nodoc:
class_inheritable_accessor :view_paths
- ##
- # :singleton-method:
- # The logger is used for generating information on the mailing run if available.
- # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
cattr_accessor :logger
@@smtp_settings = {
@@ -226,150 +258,88 @@ class Base
:password => nil,
:authentication => nil
}
- ##
- # :singleton-method:
- # Allows detailed configuration for <tt>:smtp</tt> delivery method:
- # * <tt>:address</tt> - Allows you to use a remote mail server. Just change it from its default "localhost" setting.
- # * <tt>:port</tt> - On the off chance that your mail server doesn't run on port 25, you can change it.
- # * <tt>:domain</tt> - If you need to specify a HELO domain, you can do it here.
- # * <tt>:user_name</tt> - If your mail server requires authentication, set the username in this setting.
- # * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
- # * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here.
- # This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
cattr_accessor :smtp_settings
@@sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t'
}
- ##
- # :singleton-method:
- # Allows you to override options for the <tt>:sendmail</tt> delivery method.
- # * <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>.
cattr_accessor :sendmail_settings
@@raise_delivery_errors = true
- ##
- # :singleton-method:
- # Whether or not errors should be raised if the email fails to be delivered.
cattr_accessor :raise_delivery_errors
- ##
- # :singleton-method:
- # Defines a delivery method. Possible values are <tt>:smtp</tt> (default), <tt>:sendmail</tt>, and <tt>:test</tt>.
superclass_delegating_accessor :delivery_method
self.delivery_method = :smtp
@@perform_deliveries = true
- ##
- # :singleton-method:
- # Determines whether <tt>deliver_*</tt> methods are actually carried out. By default they are,
- # but this can be turned off to help functional testing.
cattr_accessor :perform_deliveries
@@deliveries = []
- ##
- # :singleton-method:
- # Keeps an array of all the emails sent out through the Action Mailer with <tt>delivery_method :test</tt>. Most useful
- # for unit and functional testing.
cattr_accessor :deliveries
@@default_charset = "utf-8"
- ##
- # :singleton-method:
- # The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
- # pick a different charset from inside a method with +charset+.
cattr_accessor :default_charset
@@default_content_type = "text/plain"
- ##
- # :singleton-method:
- # The default content type used for the main part of the message. Defaults to "text/plain". You
- # can also pick a different content type from inside a method with +content_type+.
cattr_accessor :default_content_type
@@default_mime_version = "1.0"
- ##
- # :singleton-method:
- # The default mime version used for the message. Defaults to <tt>1.0</tt>. You
- # can also pick a different value from inside a method with +mime_version+.
cattr_accessor :default_mime_version
@@default_implicit_parts_order = [ "text/html", "text/enriched", "text/plain" ]
- ##
- # :singleton-method:
- # When a message is built implicitly (i.e. multiple parts are assembled from templates
- # which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
- # <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
- # and appear last in the mime encoded message. You can also pick a different order from inside a method with
- # +implicit_parts_order+.
cattr_accessor :default_implicit_parts_order
cattr_reader :protected_instance_variables
@@protected_instance_variables = %w(@body)
- ##
# Specify the BCC addresses for the message
adv_attr_accessor :bcc
- ##
# Define the body of the message. This is either a Hash (in which case it
# specifies the variables to pass to the template when it is rendered),
# or a string, in which case it specifies the actual text of the message.
adv_attr_accessor :body
- ##
# Specify the CC addresses for the message.
adv_attr_accessor :cc
- ##
# Specify the charset to use for the message. This defaults to the
# +default_charset+ specified for ActionMailer::Base.
adv_attr_accessor :charset
- ##
# Specify the content type for the message. This defaults to <tt>text/plain</tt>
# in most cases, but can be automatically set in some situations.
adv_attr_accessor :content_type
- ##
# Specify the from address for the message.
adv_attr_accessor :from
- ##
# Specify the address (if different than the "from" address) to direct
# replies to this message.
adv_attr_accessor :reply_to
- ##
# Specify additional headers to be added to the message.
adv_attr_accessor :headers
- ##
# Specify the order in which parts should be sorted, based on content-type.
# This defaults to the value for the +default_implicit_parts_order+.
adv_attr_accessor :implicit_parts_order
- ##
# Defaults to "1.0", but may be explicitly given if needed.
adv_attr_accessor :mime_version
- ##
# The recipient addresses for the message, either as a string (for a single
# address) or an array (for multiple addresses).
adv_attr_accessor :recipients
- ##
# The date on which the message was sent. If not set (the default), the
# header will be set by the delivery agent.
adv_attr_accessor :sent_on
- ##
# Specify the subject of the message.
adv_attr_accessor :subject
- ##
# Specify the template name to use for current message. This is the "base"
# template name, without the extension or directory, and may be used to
# have multiple mailer methods share the same template.
@@ -450,13 +420,6 @@ def deliver(mail)
new.deliver!(mail)
end
- def register_template_extension(extension)
- ActiveSupport::Deprecation.warn(
- "ActionMailer::Base.register_template_extension has been deprecated." +
- "Use ActionView::Base.register_template_extension instead", caller)
- end
-
- # Determines the base from which template references will be made.
def template_root
self.view_paths && self.view_paths.first
end
@@ -574,7 +537,12 @@ def initialize_defaults(method_name)
end
def render_message(method_name, body)
+ if method_name.respond_to?(:content_type)
+ @current_template_content_type = method_name.content_type
+ end
render :file => method_name, :body => body
+ ensure
+ @current_template_content_type = nil
end
def render(opts)
@@ -593,7 +561,11 @@ def render(opts)
end
def default_template_format
- :html
+ if @current_template_content_type
+ Mime::Type.lookup(@current_template_content_type).to_sym
+ else
+ :html
+ end
end
def candidate_for_layout?(options)
@@ -613,7 +585,9 @@ def template_path
end
def initialize_template_class(assigns)
- ActionView::Base.new(view_paths, assigns, self)
+ template = ActionView::Base.new(view_paths, assigns, self)
+ template.template_format = default_template_format
+ template
end
def sort_parts(parts, order = [])
@@ -662,11 +636,11 @@ def create_mail
if @parts.empty?
m.set_content_type(real_content_type, nil, ctype_attrs)
- m.body = Utils.normalize_new_lines(body)
+ m.body = normalize_new_lines(body)
else
if String === body
part = TMail::Mail.new
- part.body = Utils.normalize_new_lines(body)
+ part.body = normalize_new_lines(body)
part.set_content_type(real_content_type, nil, ctype_attrs)
part.set_content_disposition "inline"
m.parts << part
@@ -712,4 +686,9 @@ def perform_delivery_test(mail)
deliveries << mail
end
end
+
+ Base.class_eval do
+ include Helpers
+ helper MailHelper
+ end
end
View
2  actionmailer/lib/action_mailer/helpers.rb
@@ -1,3 +1,5 @@
+require 'active_support/dependencies'
+
module ActionMailer
module Helpers #:nodoc:
def self.included(base) #:nodoc:
View
2  actionmailer/lib/action_mailer/mail_helper.rb
@@ -1,5 +1,3 @@
-require 'text/format'
-
module MailHelper
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
View
10 actionmailer/lib/action_mailer/part.rb
@@ -1,15 +1,10 @@
-require 'action_mailer/adv_attr_accessor'
-require 'action_mailer/part_container'
-require 'action_mailer/utils'
-
module ActionMailer
# Represents a subpart of an email message. It shares many similar
# attributes of ActionMailer::Base. Although you can create parts manually
# and add them to the +parts+ list of the mailer, it is easier
# to use the helper methods in ActionMailer::PartContainer.
class Part
- include ActionMailer::AdvAttrAccessor
- include ActionMailer::PartContainer
+ include AdvAttrAccessor, PartContainer, Utils
# Represents the body of the part, as a string. This should not be a
# Hash (like ActionMailer::Base), but if you want a template to be rendered
@@ -64,7 +59,7 @@ def to_mail(defaults)
when "base64" then
part.body = TMail::Base64.folding_encode(body)
when "quoted-printable"
- part.body = [Utils.normalize_new_lines(body)].pack("M*")
+ part.body = [normalize_new_lines(body)].pack("M*")
else
part.body = body
end
@@ -102,7 +97,6 @@ def to_mail(defaults)
end
private
-
def squish(values={})
values.delete_if { |k,v| v.nil? }
end
View
6 actionmailer/lib/action_mailer/part_container.rb
@@ -41,7 +41,11 @@ def attachment(params, &block)
private
def parse_content_type(defaults=nil)
- return [defaults && defaults.content_type, {}] if content_type.blank?
+ if content_type.blank?
+ return defaults ?
+ [ defaults.content_type, { 'charset' => defaults.charset } ] :
+ [ nil, {} ]
+ end
ctype, *attrs = content_type.split(/;\s*/)
attrs = attrs.inject({}) { |h,s| k,v = s.split(/=/, 2); h[k] = v; h }
[ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
View
2  actionmailer/lib/action_mailer/quoting.rb
@@ -12,7 +12,7 @@ def quoted_printable(text, charset)
# account multi-byte characters (if executing with $KCODE="u", for instance)
def quoted_printable_encode(character)
result = ""
- character.each_byte { |b| result << "=%02x" % b }
+ character.each_byte { |b| result << "=%02X" % b }
result
end
View
2  actionmailer/lib/action_mailer/test_case.rb
@@ -10,7 +10,7 @@ def initialize(name)
end
class TestCase < ActiveSupport::TestCase
- include ActionMailer::Quoting
+ include Quoting, TestHelper
setup :initialize_test_deliveries
setup :set_expected_mail
View
1  actionmailer/lib/action_mailer/test_helper.rb
@@ -58,6 +58,7 @@ def assert_no_emails(&block)
end
end
+# TODO: Deprecate this
module Test
module Unit
class TestCase
View
1  actionmailer/lib/action_mailer/utils.rb
@@ -3,6 +3,5 @@ module Utils #:nodoc:
def normalize_new_lines(text)
text.to_s.gsub(/\r\n?/, "\n")
end
- module_function :normalize_new_lines
end
end
View
14 actionmailer/lib/action_mailer/vendor.rb
@@ -1,14 +0,0 @@
-# Prefer gems to the bundled libs.
-require 'rubygems'
-
-begin
- gem 'tmail', '~> 1.2.3'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.3"
-end
-
-begin
- gem 'text-format', '>= 0.6.3'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/text-format-0.6.3"
-end
View
10 actionmailer/lib/action_mailer/vendor/text_format.rb
@@ -0,0 +1,10 @@
+# Prefer gems to the bundled libs.
+require 'rubygems'
+
+begin
+ gem 'text-format', '>= 0.6.3'
+rescue Gem::LoadError
+ $:.unshift "#{File.dirname(__FILE__)}/text-format-0.6.3"
+end
+
+require 'text/format'
View
17 actionmailer/lib/action_mailer/vendor/tmail.rb
@@ -0,0 +1,17 @@
+# Prefer gems to the bundled libs.
+require 'rubygems'
+
+begin
+ gem 'tmail', '~> 1.2.3'
+rescue Gem::LoadError
+ $:.unshift "#{File.dirname(__FILE__)}/tmail-1.2.3"
+end
+
+module TMail
+end
+
+require 'tmail'
+
+silence_warnings do
+ TMail::Encoder.const_set("MAX_LINE_LEN", 200)
+end
View
4 actionmailer/lib/action_mailer/version.rb
@@ -1,8 +1,8 @@
module ActionMailer
module VERSION #:nodoc:
MAJOR = 2
- MINOR = 2
- TINY = 1
+ MINOR = 3
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
4 actionmailer/test/abstract_unit.rb
@@ -9,6 +9,10 @@
# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
+# Bogus template processors
+ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!" }
+ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup" }
+
$:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"
ActionMailer::Base.template_root = "#{File.dirname(__FILE__)}/fixtures"
View
54 actionmailer/test/asset_host_test.rb
@@ -0,0 +1,54 @@
+require 'abstract_unit'
+
+class AssetHostMailer < ActionMailer::Base
+ def email_with_asset(recipient)
+ recipients recipient
+ subject "testing email containing asset path while asset_host is set"
+ from "tester@example.com"
+ end
+end
+
+class AssetHostTest < Test::Unit::TestCase
+ def setup
+ set_delivery_method :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @recipient = 'test@localhost'
+ end
+
+ def teardown
+ restore_delivery_method
+ end
+
+ def test_asset_host_as_string
+ ActionController::Base.asset_host = "http://www.example.com"
+ mail = AssetHostMailer.deliver_email_with_asset(@recipient)
+ assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip
+ end
+
+ def test_asset_host_as_one_arguement_proc
+ ActionController::Base.asset_host = Proc.new { |source|
+ if source.starts_with?('/images')
+ "http://images.example.com"
+ else
+ "http://assets.example.com"
+ end
+ }
+ mail = AssetHostMailer.deliver_email_with_asset(@recipient)
+ assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.strip
+ end
+
+ def test_asset_host_as_two_arguement_proc
+ ActionController::Base.asset_host = Proc.new {|source,request|
+ if request && request.ssl?
+ "https://www.example.com"
+ else
+ "http://www.example.com"
+ end
+ }
+ mail = nil
+ assert_nothing_raised { mail = AssetHostMailer.deliver_email_with_asset(@recipient) }
+ assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip
+ end
+end
View
1  actionmailer/test/fixtures/asset_host_mailer/email_with_asset.html.erb
@@ -0,0 +1 @@
+<%= image_tag "somelogo.png" %>
View
1  actionmailer/test/fixtures/auto_layout_mailer/multipart.text.html.erb
@@ -0,0 +1 @@
+text/html multipart
View
1  actionmailer/test/fixtures/auto_layout_mailer/multipart.text.plain.erb
@@ -0,0 +1 @@
+text/plain multipart
View
1  actionmailer/test/fixtures/layouts/auto_layout_mailer.text.erb
@@ -0,0 +1 @@
+text/plain layout - <%= yield %>
View
17 actionmailer/test/mail_layout_test.rb
@@ -20,6 +20,12 @@ def nolayout(recipient)
from "tester@example.com"
body render(:inline => "Hello, <%= @world %>", :layout => false, :body => { :world => "Earth" })
end
+
+ def multipart(recipient)
+ recipients recipient
+ subject "You have a mail"
+ from "tester@example.com"
+ end
end
class ExplicitLayoutMailer < ActionMailer::Base
@@ -56,6 +62,17 @@ def test_should_pickup_default_layout
assert_equal "Hello from layout Inside", mail.body.strip
end
+ def test_should_pickup_multipart_layout
+ mail = AutoLayoutMailer.create_multipart(@recipient)
+ assert_equal 2, mail.parts.size
+
+ assert_equal 'text/plain', mail.parts.first.content_type
+ assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
+
+ assert_equal 'text/html', mail.parts.last.content_type
+ assert_equal "Hello from layout text/html multipart", mail.parts.last.body
+ end
+
def test_should_pickup_layout_given_to_render
mail = AutoLayoutMailer.create_spam(@recipient)
assert_equal "Spammer layout Hello, Earth", mail.body.strip
View
8 actionmailer/test/mail_service_test.rb
@@ -389,6 +389,8 @@ def test_custom_template
end
def test_custom_templating_extension
+ assert ActionView::Template.template_handler_extensions.include?("haml"), "haml extension was not registered"
+
# N.b., custom_templating_extension.text.plain.haml is expected to be in fixtures/test_mailer directory
expected = new_mail
expected.to = @recipient
@@ -799,6 +801,8 @@ def test_explicitly_multipart_with_invalid_content_type
end
def test_implicitly_multipart_messages
+ assert ActionView::Template.template_handler_extensions.include?("bak"), "bak extension was not registered"
+
mail = TestMailer.create_implicitly_multipart_example(@recipient)
assert_equal 3, mail.parts.length
assert_equal "1.0", mail.mime_version
@@ -812,6 +816,8 @@ def test_implicitly_multipart_messages
end
def test_implicitly_multipart_messages_with_custom_order
+ assert ActionView::Template.template_handler_extensions.include?("bak"), "bak extension was not registered"
+
mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
assert_equal 3, mail.parts.length
assert_equal "text/html", mail.parts[0].content_type
@@ -915,6 +921,8 @@ def test_deliver_with_mail_object
def test_multipart_with_template_path_with_dots
mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient)
assert_equal 2, mail.parts.length
+ assert_equal 'text/plain', mail.parts[0].content_type
+ assert_equal 'utf-8', mail.parts[0].charset
end
def test_custom_content_type_attributes
View
1  actionmailer/test/quoting_test.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
require 'abstract_unit'
-require 'tmail'
require 'tempfile'
class QuotingTest < Test::Unit::TestCase
View
8 actionmailer/test/test_helper_test.rb
@@ -36,7 +36,7 @@ def test_charset_is_utf_8
end
def test_encode
- assert_equal "=?utf-8?Q?=0aasdf=0a?=", encode("\nasdf\n")
+ assert_equal "=?utf-8?Q?=0Aasdf=0A?=", encode("\nasdf\n")
end
def test_assert_emails
@@ -84,7 +84,7 @@ def test_assert_no_emails
end
def test_assert_emails_too_few_sent
- error = assert_raises Test::Unit::AssertionFailedError do
+ error = assert_raises ActiveSupport::TestCase::Assertion do
assert_emails 2 do
TestHelperMailer.deliver_test
end
@@ -94,7 +94,7 @@ def test_assert_emails_too_few_sent
end
def test_assert_emails_too_many_sent
- error = assert_raises Test::Unit::AssertionFailedError do
+ error = assert_raises ActiveSupport::TestCase::Assertion do
assert_emails 1 do
TestHelperMailer.deliver_test
TestHelperMailer.deliver_test
@@ -105,7 +105,7 @@ def test_assert_emails_too_many_sent
end
def test_assert_no_emails_failure
- error = assert_raises Test::Unit::AssertionFailedError do
+ error = assert_raises ActiveSupport::TestCase::Assertion do
assert_no_emails do
TestHelperMailer.deliver_test
end
View
53 actionpack/CHANGELOG
@@ -1,4 +1,55 @@
-*2.2.1 [RC2] (November 14th, 2008)*
+*2.3.0 [Edge]*
+
+* Allow users to opt out of the spoofing checks in Request#remote_ip. Useful for sites whose traffic regularly triggers false positives. [Darren Boyd]
+
+* Deprecated formatted_polymorphic_url. [Jeremy Kemper]
+
+* Added the option to declare an asset_host as an object that responds to call (see http://github.com/dhh/asset-hosting-with-minimum-ssl for an example) [DHH]
+
+* Added support for multiple routes.rb files (useful for plugin engines). This also means that draw will no longer clear the route set, you have to do that by hand (shouldn't make a difference to you unless you're doing some funky stuff) [DHH]
+
+* Dropped formatted_* routes in favor of just passing in :format as an option. This cuts resource routes generation in half #1359 [aaronbatalion]
+
+* Remove support for old double-encoded cookies from the cookie store. These values haven't been generated since before 2.1.0, and any users who have visited the app in the intervening 6 months will have had their cookie upgraded. [Koz]
+
+* Allow helpers directory to be overridden via ActionController::Base.helpers_dir #1424 [Sam Pohlenz]
+
+* Remove deprecated ActionController::Base#assign_default_content_type_and_charset
+
+* Changed the default of ActionView#render to assume partials instead of files when not given an options hash [DHH]. Examples:
+
+ # Instead of <%= render :partial => "account" %>
+ <%= render "account" %>
+
+ # Instead of <%= render :partial => "account", :locals => { :account => @buyer } %>
+ <%= render "account", :account => @buyer %>
+
+ # @account is an Account instance, so it uses the RecordIdentifier to replace
+ # <%= render :partial => "accounts/account", :locals => { :account => @account } %>
+ <%= render(@account) %>
+
+ # @posts is an array of Post instances, so it uses the RecordIdentifier to replace
+ # <%= render :partial => "posts/post", :collection => @posts %>
+ <%= render(@posts) %>
+
+* Remove deprecated render_component. Please use the plugin from http://github.com/rails/render_component/tree/master [Pratik]
+
+* Fixed RedCloth and BlueCloth shouldn't preload. Instead just assume that they're available if you want to use textilize and markdown and let autoload require them [DHH]
+
+
+*2.2.2 (November 21st, 2008)*
+
+* I18n: translate number_to_human_size. Add storage_units: [Bytes, KB, MB, GB, TB] to your translations. #1448 [Yaroslav Markin]
+
+* Restore backwards compatible functionality for setting relative_url_root. Include deprecation
+
+* Switched the CSRF module to use the request content type to decide if the request is forgeable. #1145 [Jeff Cohen]
+
+* Added :only and :except to map.resources to let people cut down on the number of redundant routes in an application. Typically only useful for huge routesets. #1215 [Tom Stuart]
+
+ map.resources :products, :only => :show do |product|
+ product.resources :images, :except => :destroy
+ end
* Added render :js for people who want to render inline JavaScript replies without using RJS [DHH]
View
3  actionpack/Rakefile
@@ -80,7 +80,8 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.requirements << 'none'
- s.add_dependency('activesupport', '= 2.2.0' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.3.0' + PKG_BUILD)
+ s.add_dependency('rack', '= 0.4.0')
s.require_path = 'lib'
s.autorequire = 'action_controller'
View
116 actionpack/lib/action_controller.rb
@@ -31,49 +31,81 @@
end
end
-$:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner"
+gem 'rack', '~> 0.4.0'
+require 'rack'
-require 'action_controller/base'
-require 'action_controller/request'
-require 'action_controller/rescue'
-require 'action_controller/benchmarking'
-require 'action_controller/flash'
-require 'action_controller/filters'
-require 'action_controller/layout'
-require 'action_controller/mime_responds'
-require 'action_controller/helpers'
-require 'action_controller/cookies'
-require 'action_controller/cgi_process'
-require 'action_controller/caching'
-require 'action_controller/verification'
-require 'action_controller/streaming'
-require 'action_controller/session_management'
-require 'action_controller/http_authentication'
-require 'action_controller/components'
-require 'action_controller/rack_process'
-require 'action_controller/record_identifier'
-require 'action_controller/request_forgery_protection'
-require 'action_controller/headers'
-require 'action_controller/translation'
+module ActionController
+ # TODO: Review explicit to see if they will automatically be handled by
+ # the initilizer if they are really needed.
+ def self.load_all!
+ [Base, CgiRequest, CgiResponse, RackRequest, RackRequest, Http::Headers, UrlRewriter, UrlWriter]
+ end
-require 'action_view'
+ autoload :AbstractRequest, 'action_controller/request'
+ autoload :AbstractResponse, 'action_controller/response'
+ autoload :Base, 'action_controller/base'
+ autoload :Benchmarking, 'action_controller/benchmarking'
+ autoload :Caching, 'action_controller/caching'
+ autoload :Cookies, 'action_controller/cookies'
+ autoload :Dispatcher, 'action_controller/dispatcher'
+ autoload :Failsafe, 'action_controller/failsafe'
+ autoload :Filters, 'action_controller/filters'
+ autoload :Flash, 'action_controller/flash'
+ autoload :Helpers, 'action_controller/helpers'
+ autoload :HttpAuthentication, 'action_controller/http_authentication'
+ autoload :Integration, 'action_controller/integration'
+ autoload :IntegrationTest, 'action_controller/integration'
+ autoload :Layout, 'action_controller/layout'
+ autoload :MiddlewareStack, 'action_controller/middleware_stack'
+ autoload :MimeResponds, 'action_controller/mime_responds'
+ autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'
+ autoload :RackRequest, 'action_controller/rack_process'
+ autoload :RackResponse, 'action_controller/rack_process'
+ autoload :RecordIdentifier, 'action_controller/record_identifier'
+ autoload :RequestForgeryProtection, 'action_controller/request_forgery_protection'
+ autoload :Rescue, 'action_controller/rescue'
+ autoload :Resources, 'action_controller/resources'
+ autoload :Routing, 'action_controller/routing'
+ autoload :SessionManagement, 'action_controller/session_management'
+ autoload :StatusCodes, 'action_controller/status_codes'
+ autoload :Streaming, 'action_controller/streaming'
+ autoload :TestCase, 'action_controller/test_case'
+ autoload :TestProcess, 'action_controller/test_process'
+ autoload :Translation, 'action_controller/translation'
+ autoload :UrlRewriter, 'action_controller/url_rewriter'
+ autoload :UrlWriter, 'action_controller/url_rewriter'
+ autoload :Verification, 'action_controller/verification'
+
+ module Assertions
+ autoload :DomAssertions, 'action_controller/assertions/dom_assertions'
+ autoload :ModelAssertions, 'action_controller/assertions/model_assertions'
+ autoload :ResponseAssertions, 'action_controller/assertions/response_assertions'
+ autoload :RoutingAssertions, 'action_controller/assertions/routing_assertions'
+ autoload :SelectorAssertions, 'action_controller/assertions/selector_assertions'
+ autoload :TagAssertions, 'action_controller/assertions/tag_assertions'
+ end
-ActionController::Base.class_eval do
- include ActionController::Flash
- include ActionController::Filters
- include ActionController::Layout
- include ActionController::Benchmarking
- include ActionController::Rescue
- include ActionController::MimeResponds
- include ActionController::Helpers
- include ActionController::Cookies
- include ActionController::Caching
- include ActionController::Verification
- include ActionController::Streaming
- include ActionController::SessionManagement
- include ActionController::HttpAuthentication::Basic::ControllerMethods
- include ActionController::Components
- include ActionController::RecordIdentifier
- include ActionController::RequestForgeryProtection
- include ActionController::Translation
+ module Http
+ autoload :Headers, 'action_controller/headers'
+ end
+
+ # DEPRECATE: Remove CGI support
+ autoload :CgiRequest, 'action_controller/cgi_process'
+ autoload :CgiResponse, 'action_controller/cgi_process'
+ autoload :CGIHandler, 'action_controller/cgi_process'
end
+
+class CGI
+ class Session
+ autoload :ActiveRecordStore, 'action_controller/session/active_record_store'
+ autoload :CookieStore, 'action_controller/session/cookie_store'
+ autoload :DRbStore, 'action_controller/session/drb_store'
+ autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
+ end
+end
+
+autoload :Mime, 'action_controller/mime_type'
+
+autoload :HTML, 'action_controller/vendor/html-scanner'
+
+require 'action_view'
View
69 actionpack/lib/action_controller/assertions.rb
@@ -1,69 +0,0 @@
-require 'test/unit/assertions'
-
-module ActionController #:nodoc:
- # In addition to these specific assertions, you also have easy access to various collections that the regular test/unit assertions
- # can be used against. These collections are:
- #
- # * assigns: Instance variables assigned in the action that are available for the view.
- # * session: Objects being saved in the session.
- # * flash: The flash objects currently in the session.
- # * cookies: Cookies being sent to the user on this request.
- #
- # These collections can be used just like any other hash:
- #
- # assert_not_nil assigns(:person) # makes sure that a @person instance variable was set
- # assert_equal "Dave", cookies[:name] # makes sure that a cookie called :name was set as "Dave"
- # assert flash.empty? # makes sure that there's nothing in the flash
- #
- # For historic reasons, the assigns hash uses string-based keys. So assigns[:person] won't work, but assigns["person"] will. To
- # appease our yearning for symbols, though, an alternative accessor has been devised using a method call instead of index referencing.
- # So assigns(:person) will work just like assigns["person"], but again, assigns[:person] will not work.
- #
- # On top of the collections, you have the complete url that a given action redirected to available in redirect_to_url.
- #
- # For redirects within the same controller, you can even call follow_redirect and the redirect will be followed, triggering another
- # action call which can then be asserted against.
- #
- # == Manipulating the request collections
- #
- # The collections described above link to the response, so you can test if what the actions were expected to do happened. But
- # sometimes you also want to manipulate these collections in the incoming request. This is really only relevant for sessions
- # and cookies, though. For sessions, you just do:
- #
- # @request.session[:key] = "value"
- #
- # For cookies, you need to manually create the cookie, like this:
- #
- # @request.cookies["key"] = CGI::Cookie.new("key", "value")
- #
- # == Testing named routes
- #
- # If you're using named routes, they can be easily tested using the original named routes' methods straight in the test case.
- # Example:
- #
- # assert_redirected_to page_url(:title => 'foo')
- module Assertions
- def self.included(klass)
- %w(response selector tag dom routing model).each do |kind|
- require "action_controller/assertions/#{kind}_assertions"
- klass.module_eval { include const_get("#{kind.camelize}Assertions") }
- end
- end
-
- def clean_backtrace(&block)
- yield
- rescue Test::Unit::AssertionFailedError => error
- framework_path = Regexp.new(File.expand_path("#{File.dirname(__FILE__)}/assertions"))
- error.backtrace.reject! { |line| File.expand_path(line) =~ framework_path }
- raise
- end
- end
-end
-
-module Test #:nodoc:
- module Unit #:nodoc:
- class TestCase #:nodoc:
- include ActionController::Assertions
- end
- end
-end
View
1  actionpack/lib/action_controller/assertions/model_assertions.rb
@@ -11,6 +11,7 @@ module ModelAssertions
# assert_valid(model)
#
def assert_valid(record)
+ ::ActiveSupport::Deprecation.warn("assert_valid is deprecated. Use assert record.valid? instead", caller)
clean_backtrace do
assert record.valid?, record.errors.full_messages.join("\n")
end
View
3  actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -1,6 +1,3 @@
-require 'rexml/document'
-require 'html/document'
-
module ActionController
module Assertions
# A small suite of assertions that test responses from Rails applications.
View
3  actionpack/lib/action_controller/assertions/selector_assertions.rb
@@ -3,9 +3,6 @@
# Under MIT and/or CC By license.
#++
-require 'rexml/document'
-require 'html/document'
-
module ActionController
module Assertions
unless const_defined?(:NO_STRIP)
View
5 actionpack/lib/action_controller/assertions/tag_assertions.rb
@@ -1,6 +1,3 @@
-require 'rexml/document'
-require 'html/document'
-
module ActionController
module Assertions
# Pair of assertions to testing elements in the HTML output of the response.
@@ -127,4 +124,4 @@ def assert_no_tag(*opts)
end
end
end
-end
+end
View
94 actionpack/lib/action_controller/base.rb
@@ -1,12 +1,3 @@
-require 'action_controller/mime_type'
-require 'action_controller/request'
-require 'action_controller/response'
-require 'action_controller/routing'
-require 'action_controller/resources'
-require 'action_controller/url_rewriter'
-require 'action_controller/status_codes'
-require 'action_view'
-require 'drb'
require 'set'
module ActionController #:nodoc:
@@ -260,44 +251,30 @@ class Base
include StatusCodes
- ##
- # :singleton-method:
- # Controller specific instance variables which will not be accessible inside views.
cattr_reader :protected_instance_variables
+ # Controller specific instance variables which will not be accessible inside views.
@@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
@action_name @before_filter_chain_aborted @action_cache_path @_session @_cookies @_headers @_params
@_flash @_response)
- @@asset_host = ""
- ##
- # :singleton-method:
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
# and images to a dedicated asset server away from the main web server. Example:
# ActionController::Base.asset_host = "http://assets.example.com"
+ @@asset_host = ""
cattr_accessor :asset_host
- @@consider_all_requests_local = true
- ##
- # :singleton-method:
# All requests are considered local by default, so everyone will be exposed to detailed debugging screens on errors.
# When the application is ready to go public, this should be set to false, and the protected method <tt>local_request?</tt>
# should instead be implemented in the controller to determine when debugging screens should be shown.
+ @@consider_all_requests_local = true
cattr_accessor :consider_all_requests_local
- @@allow_concurrency = false
- ##
- # :singleton-method:
# Indicates whether to allow concurrent action processing. Your
# controller actions and any other code they call must also behave well
# when called from concurrent threads. Turned off by default.
+ @@allow_concurrency = false
cattr_accessor :allow_concurrency
- @@param_parsers = { Mime::MULTIPART_FORM => :multipart_form,
- Mime::URL_ENCODED_FORM => :url_encoded_form,
- Mime::XML => :xml_simple,
- Mime::JSON => :json }
- ##
- # :singleton-method:
# Modern REST web services often need to submit complex data to the web application.
# The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the
# <tt>params</tt> hash. These handlers are invoked for POST and PUT requests.
@@ -324,47 +301,41 @@ class Base
# A YAML parser is also available and can be turned on with:
#
# ActionController::Base.param_parsers[Mime::YAML] = :yaml
+ @@param_parsers = { Mime::MULTIPART_FORM => :multipart_form,
+ Mime::URL_ENCODED_FORM => :url_encoded_form,
+ Mime::XML => :xml_simple,
+ Mime::JSON => :json }
cattr_accessor :param_parsers
- @@default_charset = "utf-8"
- ##
- # :singleton-method:
# Controls the default charset for all renders.
+ @@default_charset = "utf-8"
cattr_accessor :default_charset
- ##
- # :singleton-method:
# The logger is used for generating information on the action run-time (including benchmarking) if available.
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
cattr_accessor :logger
- @@resource_action_separator = "/"
- ##
- # :singleton-method:
# Controls the resource action separator
+ @@resource_action_separator = "/"
cattr_accessor :resource_action_separator
- @@resources_path_names = { :new => 'new', :edit => 'edit' }
- ##
- # :singleton-method:
# Allow to override path names for default resources' actions
+ @@resources_path_names = { :new => 'new', :edit => 'edit' }
cattr_accessor :resources_path_names
- ##
- # :singleton-method:
# Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+
# sets it to <tt>:authenticity_token</tt> by default.
cattr_accessor :request_forgery_protection_token
- ##
- # :singleton-method:
+ # Controls the IP Spoofing check when determining the remote IP.
+ @@ip_spoofing_check = true
+ cattr_accessor :ip_spoofing_check
+
# Indicates whether or not optimise the generated named
# route helper methods
cattr_accessor :optimise_named_routes
self.optimise_named_routes = true
- ##
- # :singleton-method:
# Indicates whether the response format should be determined by examining the Accept HTTP header,
# or by using the simpler params + ajax rules.
#
@@ -375,54 +346,38 @@ class Base
cattr_accessor :use_accept_header
self.use_accept_header = true
- ##
- # :singleton-method:
# Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
class_inheritable_accessor :allow_forgery_protection
self.allow_forgery_protection = true
- ##
- # :singleton-method:
# If you are deploying to a subdirectory, you will need to set
# <tt>config.action_controller.relative_url_root</tt>
# This defaults to ENV['RAILS_RELATIVE_URL_ROOT']
cattr_accessor :relative_url_root
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
- ##
- # :singleton-method:
# Holds the request object that's primarily used to get environment variables through access like
# <tt>request.env["REQUEST_URI"]</tt>.
attr_internal :request
- ##
- # :singleton-method:
# Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>params["post_id"]</tt>
# to get the post_id. No type casts are made, so all values are returned as strings.
attr_internal :params
- ##
- # :singleton-method:
# Holds the response object that's primarily used to set additional HTTP headers through access like
# <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
# has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
# such as a OutputCompressionFilter.
attr_internal :response
- ##
- # :singleton-method:
# Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person"
# key. The session will hold any type of object as values, but the key should be a string or symbol.
attr_internal :session
- ##
- # :singleton-method:
# Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control
# directive. Values should always be specified as strings.
attr_internal :headers
- ##
- # :singleton-method:
# Returns the name of the action this controller is processing.
attr_accessor :action_name
@@ -569,7 +524,7 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc:
end
def send_response
- response.prepare! unless component_request?
+ response.prepare!
response
end
@@ -916,8 +871,9 @@ def render(options = nil, extra_options = {}, &block) #:doc:
end
end
- response.layout = layout = pick_layout(options)
- logger.info("Rendering template within #{layout}") if logger && layout
+ layout = pick_layout(options)
+ response.layout = layout.path_without_format_and_extension if layout
+ logger.info("Rendering template within #{layout.path_without_format_and_extension}") if logger && layout
if content_type = options[:content_type]
response.content_type = content_type.to_s
@@ -1310,11 +1266,6 @@ def assign_names
@action_name = (params['action'] || 'index')
end
- def assign_default_content_type_and_charset
- response.assign_default_content_type_and_charset!
- end
- deprecate :assign_default_content_type_and_charset => :'response.assign_default_content_type_and_charset!'
-
def action_methods
self.class.action_methods
end
@@ -1377,4 +1328,11 @@ def process_cleanup
close_session
end
end
+
+ Base.class_eval do
+ include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers
+ include Cookies, Caching, Verification, Streaming
+ include SessionManagement, HttpAuthentication::Basic::ControllerMethods
+ include RecordIdentifier, RequestForgeryProtection, Translation
+ end
end
View
18 actionpack/lib/action_controller/caching.rb
@@ -2,13 +2,6 @@
require 'uri'
require 'set'
-require 'action_controller/caching/pages'
-require 'action_controller/caching/actions'
-require 'action_controller/caching/sql_cache'
-require 'action_controller/caching/sweeping'
-require 'action_controller/caching/fragments'
-
-
module ActionController #:nodoc:
# Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls
# around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment.
@@ -31,6 +24,12 @@ module ActionController #:nodoc:
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
module Caching
+ autoload :Actions, 'action_controller/caching/actions'
+ autoload :Fragments, 'action_controller/caching/fragments'
+ autoload :Pages, 'action_controller/caching/pages'
+ autoload :SqlCache, 'action_controller/caching/sql_cache'
+ autoload :Sweeping, 'action_controller/caching/sweeping'
+
def self.included(base) #:nodoc:
base.class_eval do
@@cache_store = nil
@@ -63,10 +62,9 @@ def cache(key, options = {}, &block)
end
end
-
- private
+ private
def cache_configured?
self.class.cache_configured?
end
end
-end
+end
View
22 actionpack/lib/action_controller/caching/fragments.rb
@@ -10,23 +10,23 @@ module Caching
# <%= render :partial => "topic", :collection => Topic.find(:all) %>
# <% end %>
#
- # This cache will bind to the name of the action that called it, so if this code was part of the view for the topics/list action, you would
- # be able to invalidate it using <tt>expire_fragment(:controller => "topics", :action => "list")</tt>.
- #
- # This default behavior is of limited use if you need to cache multiple fragments per action or if the action itself is cached using
+ # This cache will bind to the name of the action that called it, so if this code was part of the view for the topics/list action, you would
+ # be able to invalidate it using <tt>expire_fragment(:controller => "topics", :action => "list")</tt>.
+ #
+ # This default behavior is of limited use if you need to cache multiple fragments per action or if the action itself is cached using
# <tt>caches_action</tt>, so we also have the option to qualify the name of the cached fragment with something like:
#
# <% cache(:action => "list", :action_suffix => "all_topics") do %>
#
- # That would result in a name such as "/topics/list/all_topics", avoiding conflicts with the action cache and with any fragments that use a
- # different suffix. Note that the URL doesn't have to really exist or be callable - the url_for system is just used to generate unique
- # cache names that we can refer to when we need to expire the cache.
- #
+ # That would result in a name such as "/topics/list/all_topics", avoiding conflicts with the action cache and with any fragments that use a
+ # different suffix. Note that the URL doesn't have to really exist or be callable - the url_for system is just used to generate unique
+ # cache names that we can refer to when we need to expire the cache.
+ #
# The expiration call for this example is:
- #
+ #
# expire_fragment(:controller => "topics", :action => "list", :action_suffix => "all_topics")
module Fragments
- # Given a key (as described in <tt>expire_fragment</tt>), returns a key suitable for use in reading,
+ # Given a key (as described in <tt>expire_fragment</tt>), returns a key suitable for use in reading,
# writing, or expiring a cached fragment. If the key is a hash, the generated key is the return
# value of url_for on that hash (without the protocol). All keys are prefixed with "views/" and uses
# ActiveSupport::Cache.expand_cache_key for the expansion.
@@ -50,7 +50,7 @@ def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
# Writes <tt>content</tt> to the location signified by <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats)
def write_fragment(key, content, options = nil)
- return unless cache_configured?
+ return content unless cache_configured?
key = fragment_cache_key(key)
View
2  actionpack/lib/action_controller/cgi_ext/cookie.rb
@@ -1,3 +1,5 @@
+require 'delegate'
+
CGI.module_eval { remove_const "Cookie" }
# TODO: document how this differs from stdlib CGI::Cookie
View
217 actionpack/lib/action_controller/cgi_process.rb
@@ -1,185 +1,72 @@
require 'action_controller/cgi_ext'
-require 'action_controller/session/cookie_store'
module ActionController #:nodoc:
- class Base
- # Process a request extracted from a CGI object and return a response. Pass false as <tt>session_options</tt> to disable
- # sessions (large performance increase if sessions are not needed). The <tt>session_options</tt> are the same as for CGI::Session:
- #
- # * <tt>:database_manager</tt> - standard options are CGI::Session::FileStore, CGI::Session::MemoryStore, and CGI::Session::PStore
- # (default). Additionally, there is CGI::Session::DRbStore and CGI::Session::ActiveRecordStore. Read more about these in
- # lib/action_controller/session.
- # * <tt>:session_key</tt> - the parameter name used for the session id. Defaults to '_session_id'.
- # * <tt>:session_id</tt> - the session id to use. If not provided, then it is retrieved from the +session_key+ cookie, or
- # automatically generated for a new session.
- # * <tt>:new_session</tt> - if true, force creation of a new session. If not set, a new session is only created if none currently
- # exists. If false, a new session is never created, and if none currently exists and the +session_id+ option is not set,
- # an ArgumentError is raised.
- # * <tt>:session_expires</tt> - the time the current session expires, as a Time object. If not set, the session will continue
- # indefinitely.
- # * <tt>:session_domain</tt> - the hostname domain for which this session is valid. If not set, defaults to the hostname of the
- # server.
- # * <tt>:session_secure</tt> - if +true+, this session will only work over HTTPS.
- # * <tt>:session_path</tt> - the path for which this session applies. Defaults to the directory of the CGI script.
- # * <tt>:cookie_only</tt> - if +true+ (the default), session IDs will only be accepted from cookies and not from
- # the query string or POST parameters. This protects against session fixation attacks.
- def self.process_cgi(cgi = CGI.new, session_options = {})
- new.process_cgi(cgi, session_options)
- end
-
- def process_cgi(cgi, session_options = {}) #:nodoc:
- process(CgiRequest.new(cgi, session_options), CgiResponse.new(cgi)).out
- end
- end
-
- class CgiRequest < AbstractRequest #:nodoc:
- attr_accessor :cgi, :session_options
- class SessionFixationAttempt < StandardError #:nodoc:
- end
-
- DEFAULT_SESSION_OPTIONS = {
- :database_manager => CGI::Session::CookieStore, # store data in cookie
- :prefix => "ruby_sess.", # prefix session file names
- :session_path => "/", # available to all paths in app
- :session_key => "_session_id",
- :cookie_only => true,
- :session_http_only=> true
- }
-
- def initialize(cgi, session_options = {})
- @cgi = cgi
- @session_options = session_options
- @env = @cgi.__send__(:env_table)
- super()
- end
-
- def query_string
- qs = @cgi.query_string if @cgi.respond_to?(:query_string)
- if !qs.blank?
- qs
- else
- super
- end
- end
-
- def body_stream #:nodoc:
- @cgi.stdinput
- end
-
- def cookies
- @cgi.cookies.freeze
- end
-
- def session
- unless defined?(@session)
- if @session_options == false
- @session = Hash.new
- else
- stale_session_check! do
- if cookie_only? && query_parameters[session_options_with_string_keys['session_key']]
- raise SessionFixationAttempt
- end
- case value = session_options_with_string_keys['new_session']
- when true
- @session = new_session
- when false
- begin
- @session = CGI::Session.new(@cgi, session_options_with_string_keys)
- # CGI::Session raises ArgumentError if 'new_session' == false
- # and no session cookie or query param is present.
- rescue ArgumentError
- @session = Hash.new
- end
- when nil
- @session = CGI::Session.new(@cgi, session_options_with_string_keys)
- else
- raise ArgumentError, "Invalid new_session option: #{value}"
- end
- @session['__valid_session']
- end
+ class CGIHandler
+ module ProperStream
+ def each
+ while line = gets
+ yield line
end
end
- @session
- end
- def reset_session
- @session.delete if defined?(@session) && @session.is_a?(CGI::Session)
- @session = new_session
- end
-
- def method_missing(method_id, *arguments)
- @cgi.__send__(method_id, *arguments) rescue super
- end
-
- private
- # Delete an old session if it exists then create a new one.
- def new_session
- if @session_options == false
- Hash.new
+ def read(*args)
+ if args.empty?
+ super || ""
else
- CGI::Session.new(@cgi, session_options_with_string_keys.merge("new_session" => false)).delete rescue nil
- CGI::Session.new(@cgi, session_options_with_string_keys.merge("new_session" => true))
+ super
end
end
+ end
- def cookie_only?
- session_options_with_string_keys['cookie_only']
- end
+ def self.dispatch_cgi(app, cgi, out = $stdout)
+ env = cgi.__send__(:env_table)
+ env.delete "HTTP_CONTENT_LENGTH"
- def stale_session_check!
- yield
- rescue ArgumentError => argument_error
- if argument_error.message =~ %r{undefined class/module ([\w:]*\w)}
- begin
- # Note that the regexp does not allow $1 to end with a ':'
- $1.constantize
- rescue LoadError, NameError => const_error
- raise ActionController::SessionRestoreError, <<-end_msg
-Session contains objects whose class definition isn\'t available.
-Remember to require the classes for all objects kept in the session.
-(Original exception: #{const_error.message} [#{const_error.class}])
-end_msg
- end
+ cgi.stdinput.extend ProperStream
- retry
- else
- raise
- end
- end
+ env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
- def session_options_with_string_keys
- @session_options_with_string_keys ||= DEFAULT_SESSION_OPTIONS.merge(@session_options).stringify_keys
- end
- end
+ env.update({
+ "rack.version" => [0,1],
+ "rack.input" => cgi.stdinput,
+ "rack.errors" => $stderr,
+ "rack.multithread" => false,
+ "rack.multiprocess" => true,
+ "rack.run_once" => false,
+ "rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
+ })
- class CgiResponse < AbstractResponse #:nodoc:
- def initialize(cgi)
- @cgi = cgi
- super()
- end
-
- def out(output = $stdout)
- output.binmode if output.respond_to?(:binmode)
- output.sync = false if output.respond_to?(:sync=)
+ env["QUERY_STRING"] ||= ""
+ env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
+ env["REQUEST_PATH"] ||= "/"
+ env.delete "PATH_INFO" if env["PATH_INFO"] == ""
+ status, headers, body = app.call(env)
begin
- output.write(@cgi.header(@headers))
-
- if @cgi.__send__(:env_table)['REQUEST_METHOD'] == 'HEAD'
- return
- elsif @body.respond_to?(:call)
- # Flush the output now in case the @body Proc uses
- # #syswrite.
- output.flush if output.respond_to?(:flush)
- @body.call(self, output)
- else
- output.write(@body)
- end
-
- output.flush if output.respond_to?(:flush)
- rescue Errno::EPIPE, Errno::ECONNRESET
- # lost connection to parent process, ignore output
+ out.binmode if out.respond_to?(:binmode)
+ out.sync = false if out.respond_to?(:sync=)
+
+ headers['Status'] = status.to_s
+ out.write(cgi.header(headers))
+
+ body.each { |part|
+ out.write part
+ out.flush if out.respond_to?(:flush)
+ }
+ ensure
+ body.close if body.respond_to?(:close)
end
end
end
+
+ class CgiRequest #:nodoc:
+ DEFAULT_SESSION_OPTIONS = {
+ :database_manager => CGI::Session::CookieStore,
+ :prefix => "ruby_sess.",
+ :session_path => "/",
+ :session_key => "_session_id",
+ :cookie_only => true,
+ :session_http_only => true
+ }
+ end
end
View
169 actionpack/lib/action_controller/components.rb
@@ -1,169 +0,0 @@
-module ActionController #:nodoc:
- # Components allow you to call other actions for their rendered response while executing another action. You can either delegate
- # the entire response rendering or you can mix a partial response in with your other content.
- #
- # class WeblogController < ActionController::Base
- # # Performs a method and then lets hello_world output its render
- # def delegate_action
- # do_other_stuff_before_hello_world
- # render_component :controller => "greeter", :action => "hello_world", :params => { :person => "david" }
- # end
- # end
- #
- # class GreeterController < ActionController::Base
- # def hello_world
- # render :text => "#{params[:person]} says, Hello World!"
- # end
- # end
- #
- # The same can be done in a view to do a partial rendering:
- #
- # Let's see a greeting:
- # <%= render_component :controller => "greeter", :action => "hello_world" %>
- #
- # It is also possible to specify the controller as a class constant, bypassing the inflector
- # code to compute the controller class at runtime:
- #
- # <%= render_component :controller => GreeterController, :action => "hello_world" %>
- #
- # == When to use components
- #
- # Components should be used with care. They're significantly slower than simply splitting reusable parts into partials and
- # conceptually more complicated. Don't use components as a way of separating concerns inside a single application. Instead,
- # reserve components to those rare cases where you truly have reusable view and controller elements that can be employed
- # across many applications at once.
- #
- # So to repeat: Components are a special-purpose approach that can often be replaced with better use of partials and filters.
- module Components
- def self.included(base) #:nodoc:
- base.class_eval do
- include InstanceMethods
- include ActiveSupport::Deprecation
- extend ClassMethods
- helper HelperMethods
-
- # If this controller was instantiated to process a component request,
- # +parent_controller+ points to the instantiator of this controller.
- attr_accessor :parent_controller
-
- alias_method_chain :process_cleanup, :components
- alias_method_chain :set_session_options, :components
- alias_method_chain :flash, :components
-
- alias_method :component_request?, :parent_controller
- end
- end
-
- module ClassMethods
- # Track parent controller to identify component requests
- def process_with_components(request, response, parent_controller = nil) #:nodoc:
- controller = new
- controller.parent_controller = parent_controller
- controller.process(request, response)
- end
- end
-
- module HelperMethods
- def render_component(options)
- @controller.__send__(:render_component_as_string, options)
- end
- end
-
- module InstanceMethods
- # Extracts the action_name from the request parameters and performs that action.
- def process_with_components(request, response, method = :perform_action, *arguments) #:nodoc:
- flash.discard if component_request?
- process_without_components(request, response, method, *arguments)
- end
-
- protected
- # Renders the component specified as the response for the current method
- def render_component(options) #:doc:
- component_logging(options) do
- render_for_text(component_response(options, true).body, response.headers["Status"])
- end
- end
- deprecate :render_component => "Please install render_component plugin from http://github.com/rails/render_component/tree/master"
-
- # Returns the component response as a string
- def render_component_as_string(options) #:doc:
- component_logging(options) do
- response = component_response(options, false)
-
- if redirected = response.redirected_to
- render_component_as_string(redirected)
- else
- response.body
- end
- end
- end
- deprecate :render_component_as_string => "Please install render_component plugin from http://github.com/rails/render_component/tree/master"
-
- def flash_with_components(refresh = false) #:nodoc:
- if !defined?(@_flash) || refresh
- @_flash =
- if defined?(@parent_controller)
- @parent_controller.flash
- else
- flash_without_components
- end
- end
- @_flash
- end
-
- private
- def component_response(options, reuse_response)
- klass = component_class(options)
- request = request_for_component(klass.controller_name, options)
- new_response = reuse_response ? response : response.dup
-
- klass.process_with_components(request, new_response, self)
- end
-
- # determine the controller class for the component request
- def component_class(options)
- if controller =