Permalink
Browse files

Merge branch 'master' into refactor_cache_store_updated

  • Loading branch information...
2 parents fcf0340 + ea53526 commit 695b0aea870969b28bc659048676a59dbcfbc557 Joey Butler committed Dec 3, 2012
Showing with 4,826 additions and 4,279 deletions.
  1. +4 −0 .travis.yml
  2. +3 −7 Gemfile
  3. +3 −0 actionmailer/CHANGELOG.md
  4. +10 −7 actionmailer/actionmailer.gemspec
  5. +1 −0 actionmailer/lib/action_mailer.rb
  6. +16 −21 actionmailer/lib/action_mailer/base.rb
  7. +21 −21 actionmailer/test/base_test.rb
  8. +106 −10 actionpack/CHANGELOG.md
  9. +15 −13 actionpack/actionpack.gemspec
  10. +8 −7 actionpack/lib/abstract_controller/callbacks.rb
  11. +3 −3 actionpack/lib/abstract_controller/layouts.rb
  12. +1 −0 actionpack/lib/action_controller/base.rb
  13. +2 −5 actionpack/lib/action_controller/caching.rb
  14. +0 −116 actionpack/lib/action_controller/caching/sweeping.rb
  15. +2 −2 actionpack/lib/action_controller/metal.rb
  16. +1 −1 actionpack/lib/action_controller/metal/conditional_get.rb
  17. +6 −5 actionpack/lib/action_controller/metal/data_streaming.rb
  18. +1 −1 actionpack/lib/action_controller/metal/force_ssl.rb
  19. +2 −2 actionpack/lib/action_controller/metal/head.rb
  20. +13 −13 actionpack/lib/action_controller/metal/http_authentication.rb
  21. +13 −13 actionpack/lib/action_controller/metal/mime_responds.rb
  22. +105 −61 actionpack/lib/action_controller/metal/params_wrapper.rb
  23. +11 −11 actionpack/lib/action_controller/metal/redirecting.rb
  24. +3 −3 actionpack/lib/action_controller/metal/renderers.rb
  25. +7 −7 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  26. +10 −10 actionpack/lib/action_controller/metal/responder.rb
  27. +3 −3 actionpack/lib/action_controller/metal/streaming.rb
  28. +11 −9 actionpack/lib/action_controller/metal/strong_parameters.rb
  29. +1 −1 actionpack/lib/action_controller/metal/url_for.rb
  30. +16 −13 actionpack/lib/action_controller/test_case.rb
  31. +6 −4 actionpack/lib/action_dispatch.rb
  32. +16 −11 actionpack/lib/action_dispatch/http/mime_type.rb
  33. +10 −10 actionpack/lib/action_dispatch/http/url.rb
  34. +7 −1 actionpack/lib/action_dispatch/middleware/best_standards_support.rb
  35. +87 −37 actionpack/lib/action_dispatch/middleware/cookies.rb
  36. +24 −10 actionpack/lib/action_dispatch/middleware/flash.rb
  37. +4 −6 actionpack/lib/action_dispatch/middleware/remote_ip.rb
  38. +47 −5 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  39. +1 −1 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  40. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
  41. +1 −1 actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
  42. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb
  43. +4 −0 actionpack/lib/action_dispatch/railtie.rb
  44. +24 −24 actionpack/lib/action_dispatch/routing.rb
  45. +83 −88 actionpack/lib/action_dispatch/routing/mapper.rb
  46. +3 −3 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  47. +8 −8 actionpack/lib/action_dispatch/routing/redirection.rb
  48. +7 −6 actionpack/lib/action_dispatch/routing/route_set.rb
  49. +15 −15 actionpack/lib/action_dispatch/routing/url_for.rb
  50. +3 −3 actionpack/lib/action_dispatch/testing/assertions/response.rb
  51. +22 −21 actionpack/lib/action_dispatch/testing/assertions/routing.rb
  52. +1 −1 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  53. +19 −19 actionpack/lib/action_dispatch/testing/assertions/tag.rb
  54. +6 −6 actionpack/lib/action_dispatch/testing/integration.rb
  55. +7 −5 actionpack/lib/action_dispatch/testing/test_process.rb
  56. +1 −1 actionpack/lib/action_view/base.rb
  57. +32 −32 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  58. +6 −6 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  59. +24 −2 actionpack/lib/action_view/helpers/cache_helper.rb
  60. +5 −5 actionpack/lib/action_view/helpers/capture_helper.rb
  61. +95 −95 actionpack/lib/action_view/helpers/date_helper.rb
  62. +1 −1 actionpack/lib/action_view/helpers/debug_helper.rb
  63. +5 −0 actionpack/lib/action_view/helpers/form_helper.rb
  64. +26 −28 actionpack/lib/action_view/helpers/form_options_helper.rb
  65. +55 −55 actionpack/lib/action_view/helpers/form_tag_helper.rb
  66. +4 −4 actionpack/lib/action_view/helpers/javascript_helper.rb
  67. +56 −56 actionpack/lib/action_view/helpers/number_helper.rb
  68. +3 −3 actionpack/lib/action_view/helpers/record_tag_helper.rb
  69. +2 −2 actionpack/lib/action_view/helpers/rendering_helper.rb
  70. +1 −1 actionpack/lib/action_view/helpers/sanitize_helper.rb
  71. +7 −7 actionpack/lib/action_view/helpers/tag_helper.rb
  72. +3 −5 actionpack/lib/action_view/helpers/tags/base.rb
  73. +1 −1 actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
  74. +22 −22 actionpack/lib/action_view/helpers/text_helper.rb
  75. +1 −1 actionpack/lib/action_view/helpers/translation_helper.rb
  76. +13 −7 actionpack/lib/action_view/helpers/url_helper.rb
  77. +2 −20 actionpack/lib/action_view/path_set.rb
  78. +28 −29 actionpack/lib/action_view/renderer/partial_renderer.rb
  79. +2 −12 actionpack/lib/action_view/renderer/renderer.rb
  80. +1 −1 actionpack/lib/action_view/renderer/template_renderer.rb
  81. +7 −7 actionpack/lib/action_view/routing_url_for.rb
  82. +5 −0 actionpack/lib/action_view/template/handlers/erb.rb
  83. +1 −1 actionpack/lib/action_view/vendor/html-scanner.rb
  84. +12 −12 actionpack/lib/action_view/vendor/html-scanner/html/node.rb
  85. +0 −1 actionpack/test/abstract_unit.rb
  86. +20 −0 actionpack/test/controller/action_pack_assertions_test.rb
  87. +12 −0 actionpack/test/controller/caching_test.rb
  88. +0 −41 actionpack/test/controller/filters_test.rb
  89. +21 −0 actionpack/test/controller/flash_hash_test.rb
  90. +4 −2 actionpack/test/controller/flash_test.rb
  91. +4 −2 actionpack/test/controller/http_digest_authentication_test.rb
  92. +25 −0 actionpack/test/controller/parameters/nested_parameters_test.rb
  93. +34 −5 actionpack/test/controller/parameters/parameters_permit_test.rb
  94. +1 −1 actionpack/test/controller/params_wrapper_test.rb
  95. +10 −0 actionpack/test/controller/render_test.rb
  96. +12 −0 actionpack/test/controller/send_file_test.rb
  97. +1 −1 actionpack/test/controller/show_exceptions_test.rb
  98. +0 −16 actionpack/test/controller/sweeper_test.rb
  99. +12 −0 actionpack/test/controller/test_case_test.rb
  100. +34 −0 actionpack/test/dispatch/best_standards_support_test.rb
  101. +26 −6 actionpack/test/dispatch/cookies_test.rb
  102. +5 −0 actionpack/test/dispatch/prefix_generation_test.rb
  103. +6 −9 actionpack/test/dispatch/request_test.rb
  104. +1,102 −634 actionpack/test/dispatch/routing_test.rb
  105. +4 −1 actionpack/test/dispatch/session/cookie_store_test.rb
  106. +3 −0 actionpack/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb
  107. +5 −0 actionpack/test/template/date_helper_test.rb
  108. +13 −0 actionpack/test/template/form_helper_test.rb
  109. +1 −1 actionpack/test/template/form_options_helper_test.rb
  110. +5 −0 actionpack/test/template/render_test.rb
  111. +7 −2 actionpack/test/template/tag_helper_test.rb
  112. +16 −1 actionpack/test/template/template_test.rb
  113. +23 −0 activemodel/CHANGELOG.md
  114. +8 −6 activemodel/activemodel.gemspec
  115. +3 −3 activemodel/examples/validations.rb
  116. +0 −2 activemodel/lib/active_model.rb
  117. +2 −2 activemodel/lib/active_model/attribute_methods.rb
  118. +0 −2 activemodel/lib/active_model/callbacks.rb
  119. +0 −2 activemodel/lib/active_model/conversion.rb
  120. +6 −4 activemodel/lib/active_model/deprecated_mass_assignment_security.rb
  121. +4 −2 activemodel/lib/active_model/dirty.rb
  122. +18 −18 activemodel/lib/active_model/errors.rb
  123. +1 −1 activemodel/lib/active_model/forbidden_attributes_protection.rb
  124. +4 −5 activemodel/lib/active_model/naming.rb
  125. +0 −152 activemodel/lib/active_model/observer_array.rb
  126. +0 −374 activemodel/lib/active_model/observing.rb
  127. +4 −0 activemodel/lib/active_model/railtie.rb
  128. +9 −1 activemodel/lib/active_model/secure_password.rb
  129. +6 −1 activemodel/lib/active_model/serializers/xml.rb
  130. +5 −8 activemodel/lib/active_model/validations.rb
  131. +2 −3 activemodel/lib/active_model/validations/acceptance.rb
  132. +2 −4 activemodel/lib/active_model/validations/callbacks.rb
  133. +1 −2 activemodel/lib/active_model/validations/confirmation.rb
  134. +1 −2 activemodel/lib/active_model/validations/exclusion.rb
  135. +1 −2 activemodel/lib/active_model/validations/format.rb
  136. +1 −2 activemodel/lib/active_model/validations/inclusion.rb
  137. +14 −2 activemodel/lib/active_model/validations/length.rb
  138. +1 −2 activemodel/lib/active_model/validations/numericality.rb
  139. +0 −1 activemodel/lib/active_model/validations/presence.rb
  140. +6 −7 activemodel/lib/active_model/validations/validates.rb
  141. +1 −1 activemodel/lib/active_model/validations/with.rb
  142. +2 −2 activemodel/lib/active_model/validator.rb
  143. +1 −2 activemodel/test/cases/dirty_test.rb
  144. +41 −4 activemodel/test/cases/errors_test.rb
  145. +0 −220 activemodel/test/cases/observer_array_test.rb
  146. +0 −181 activemodel/test/cases/observing_test.rb
  147. +29 −0 activemodel/test/cases/railtie_test.rb
  148. +21 −2 activemodel/test/cases/secure_password_test.rb
  149. +1 −4 activemodel/test/cases/serializers/json_serialization_test.rb
  150. +10 −2 activemodel/test/cases/serializers/xml_serialization_test.rb
  151. +12 −12 activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  152. +0 −20 activemodel/test/cases/validations/i18n_validation_test.rb
  153. +39 −0 activemodel/test/cases/validations/length_validation_test.rb
  154. +1 −1 activemodel/test/cases/validations/validates_test.rb
  155. +1 −1 activemodel/test/cases/validations/with_validation_test.rb
  156. +0 −27 activemodel/test/models/observers.rb
  157. +101 −10 activerecord/CHANGELOG.md
  158. +0 −11 activerecord/README.rdoc
  159. +11 −10 activerecord/activerecord.gemspec
  160. +0 −1 activerecord/lib/active_record.rb
  161. +18 −18 activerecord/lib/active_record/aggregations.rb
  162. +60 −54 activerecord/lib/active_record/associations.rb
  163. +3 −2 activerecord/lib/active_record/associations/association.rb
  164. +2 −0 activerecord/lib/active_record/associations/builder/association.rb
  165. +3 −0 activerecord/lib/active_record/associations/builder/collection_association.rb
  166. +1 −1 activerecord/lib/active_record/associations/builder/has_many.rb
  167. +14 −13 activerecord/lib/active_record/associations/collection_association.rb
  168. +18 −6 activerecord/lib/active_record/associations/collection_proxy.rb
  169. +1 −1 activerecord/lib/active_record/associations/has_many_association.rb
  170. +9 −1 activerecord/lib/active_record/associations/has_one_association.rb
  171. +3 −3 activerecord/lib/active_record/associations/preloader.rb
  172. +1 −1 activerecord/lib/active_record/associations/singular_association.rb
  173. +1 −1 activerecord/lib/active_record/associations/through_association.rb
  174. +19 −18 activerecord/lib/active_record/attribute_methods.rb
  175. +43 −0 activerecord/lib/active_record/attribute_methods/before_type_cast.rb
  176. +0 −7 activerecord/lib/active_record/attribute_methods/read.rb
  177. +19 −1 activerecord/lib/active_record/attribute_methods/serialization.rb
  178. +2 −2 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  179. +11 −11 activerecord/lib/active_record/autosave_association.rb
  180. +20 −23 activerecord/lib/active_record/base.rb
  181. +7 −9 activerecord/lib/active_record/callbacks.rb
  182. +25 −14 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  183. +2 −2 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  184. +29 −21 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  185. +38 −27 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  186. +2 −2 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
  187. +1 −1 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  188. +1 −1 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  189. +2 −0 activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
  190. +7 −3 activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
  191. +18 −14 activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
  192. +20 −1 activerecord/lib/active_record/connection_adapters/schema_cache.rb
  193. +8 −8 activerecord/lib/active_record/connection_handling.rb
  194. +7 −5 activerecord/lib/active_record/core.rb
  195. +2 −2 activerecord/lib/active_record/counter_cache.rb
  196. +12 −1 activerecord/lib/active_record/errors.rb
  197. +7 −6 activerecord/lib/active_record/explain.rb
  198. +14 −8 activerecord/lib/active_record/fixtures.rb
  199. +50 −24 activerecord/lib/active_record/inheritance.rb
  200. +3 −3 activerecord/lib/active_record/locking/pessimistic.rb
  201. +6 −2 activerecord/lib/active_record/migration.rb
  202. +1 −1 activerecord/lib/active_record/migration/join_table.rb
  203. +1 −1 activerecord/lib/active_record/model_schema.rb
  204. +38 −38 activerecord/lib/active_record/nested_attributes.rb
  205. +5 −1 activerecord/lib/active_record/null_relation.rb
  206. +0 −126 activerecord/lib/active_record/observer.rb
  207. +62 −23 activerecord/lib/active_record/persistence.rb
  208. +50 −12 activerecord/lib/active_record/railtie.rb
  209. +13 −13 activerecord/lib/active_record/reflection.rb
  210. +17 −20 activerecord/lib/active_record/relation.rb
  211. +2 −2 activerecord/lib/active_record/relation/batches.rb
  212. +28 −28 activerecord/lib/active_record/relation/calculations.rb
  213. +101 −15 activerecord/lib/active_record/relation/delegation.rb
  214. +2 −6 activerecord/lib/active_record/relation/finder_methods.rb
  215. +2 −2 activerecord/lib/active_record/relation/predicate_builder.rb
  216. +35 −61 activerecord/lib/active_record/relation/query_methods.rb
  217. +3 −4 activerecord/lib/active_record/relation/spawn_methods.rb
  218. +12 −12 activerecord/lib/active_record/sanitization.rb
  219. +7 −7 activerecord/lib/active_record/serializers/xml_serializer.rb
  220. +0 −3 activerecord/lib/active_record/timestamp.rb
  221. +14 −14 activerecord/lib/active_record/transactions.rb
  222. +0 −15 activerecord/lib/rails/generators/active_record/observer/observer_generator.rb
  223. +0 −4 activerecord/lib/rails/generators/active_record/observer/templates/observer.rb
  224. +29 −0 activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
  225. +18 −0 activerecord/test/cases/adapters/postgresql/sql_types_test.rb
  226. +9 −0 activerecord/test/cases/adapters/postgresql/timestamp_test.rb
  227. +28 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  228. +4 −4 activerecord/test/cases/associations/eager_test.rb
  229. +11 −6 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  230. +69 −6 activerecord/test/cases/associations/has_many_associations_test.rb
  231. +13 −6 activerecord/test/cases/associations/has_many_through_associations_test.rb
  232. +36 −0 activerecord/test/cases/associations/has_one_associations_test.rb
  233. +13 −0 activerecord/test/cases/associations/inverse_associations_test.rb
  234. +8 −0 activerecord/test/cases/associations_test.rb
  235. +6 −27 activerecord/test/cases/attribute_methods_test.rb
  236. +13 −0 activerecord/test/cases/base_test.rb
  237. +8 −0 activerecord/test/cases/batches_test.rb
  238. +10 −18 activerecord/test/cases/calculations_test.rb
  239. +5 −6 activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
  240. +12 −8 activerecord/test/cases/connection_adapters/connection_handler_test.rb
  241. +17 −14 activerecord/test/cases/dirty_test.rb
  242. +10 −0 activerecord/test/cases/explain_test.rb
  243. +5 −0 activerecord/test/cases/finder_test.rb
  244. +15 −0 activerecord/test/cases/forbidden_attributes_protection_test.rb
  245. +15 −2 activerecord/test/cases/helper.rb
  246. +23 −0 activerecord/test/cases/inheritance_test.rb
  247. +0 −256 activerecord/test/cases/lifecycle_test.rb
  248. +7 −0 activerecord/test/cases/migration/change_table_test.rb
  249. +6 −0 activerecord/test/cases/migration/create_join_table_test.rb
  250. +2 −4 activerecord/test/cases/migration/helper.rb
  251. +16 −0 activerecord/test/cases/migration/index_test.rb
  252. +2 −2 activerecord/test/cases/migration/references_statements_test.rb
  253. +15 −6 activerecord/test/cases/nested_attributes_test.rb
  254. +13 −2 activerecord/test/cases/persistence_test.rb
  255. +24 −21 activerecord/test/cases/relation_test.rb
  256. +46 −3 activerecord/test/cases/relations_test.rb
  257. +13 −3 activerecord/test/cases/serialized_attribute_test.rb
  258. +0 −81 activerecord/test/cases/transaction_callbacks_test.rb
  259. +1 −0 activerecord/test/models/author.rb
  260. +1 −0 activerecord/test/models/company.rb
  261. +2 −3 activerecord/test/models/reference.rb
  262. +7 −0 activerecord/test/models/topic.rb
  263. +15 −9 activerecord/test/schema/postgresql_specific_schema.rb
  264. +1 −0 activerecord/test/schema/schema.rb
  265. +0 −11 activerecord/test/support/mysql.rb
  266. +53 −3 activesupport/CHANGELOG.md
  267. +10 −9 activesupport/activesupport.gemspec
  268. +1 −0 activesupport/lib/active_support/cache/file_store.rb
  269. +1 −0 activesupport/lib/active_support/cache/mem_cache_store.rb
  270. +5 −5 activesupport/lib/active_support/concern.rb
  271. +3 −3 activesupport/lib/active_support/core_ext/array/conversions.rb
  272. +4 −4 activesupport/lib/active_support/core_ext/array/grouping.rb
  273. +1 −1 activesupport/lib/active_support/core_ext/array/wrap.rb
  274. +2 −0 activesupport/lib/active_support/core_ext/date/calculations.rb
  275. +9 −0 activesupport/lib/active_support/core_ext/date_time/calculations.rb
  276. +12 −12 activesupport/lib/active_support/core_ext/hash/conversions.rb
  277. +3 −3 activesupport/lib/active_support/core_ext/hash/deep_merge.rb
  278. +1 −0 activesupport/lib/active_support/core_ext/hash/diff.rb
  279. +3 −3 activesupport/lib/active_support/core_ext/hash/slice.rb
  280. +26 −11 activesupport/lib/active_support/core_ext/kernel/reporting.rb
  281. +21 −0 activesupport/lib/active_support/core_ext/marshal.rb
  282. +2 −2 activesupport/lib/active_support/core_ext/string/inflections.rb
  283. +2 −9 activesupport/lib/active_support/core_ext/string/multibyte.rb
  284. +6 −0 activesupport/lib/active_support/core_ext/struct.rb
  285. +9 −0 activesupport/lib/active_support/core_ext/time/calculations.rb
  286. +2 −0 activesupport/lib/active_support/core_ext/time/zones.rb
  287. +52 −10 activesupport/lib/active_support/dependencies.rb
  288. +3 −3 activesupport/lib/active_support/deprecation/instance_delegator.rb
  289. +4 −2 activesupport/lib/active_support/inflector/methods.rb
  290. +1 −1 activesupport/lib/active_support/json/encoding.rb
  291. +54 −0 activesupport/lib/active_support/key_generator.rb
  292. +5 −2 activesupport/lib/active_support/message_encryptor.rb
  293. +9 −9 activesupport/lib/active_support/notifications.rb
  294. +7 −3 activesupport/lib/active_support/test_case.rb
  295. +0 −22 activesupport/lib/active_support/testing/mocha_module.rb
  296. +14 −0 activesupport/lib/active_support/testing/pending.rb
  297. +0 −4 activesupport/lib/active_support/testing/tagged_logging.rb
  298. +17 −12 activesupport/lib/active_support/values/time_zone.rb
  299. +29 −9 activesupport/lib/active_support/xml_mini.rb
  300. +1 −0 activesupport/test/autoloading_fixtures/should_not_be_required.rb
Sorry, we could not display the entire diff because too many files (419) changed.
View
4 .travis.yml
@@ -3,6 +3,7 @@ before_install:
- gem install bundler
rvm:
- 1.9.3
+ - 2.0.0
env:
- "GEM=railties"
- "GEM=ap,am,amo,as"
@@ -23,3 +24,6 @@ notifications:
rooms:
- secure: "CGWvthGkBKNnTnk9YSmf9AXKoiRI33fCl5D3jU4nx3cOPu6kv2R9nMjt9EAo\nOuS4Q85qNSf4VNQ2cUPNiNYSWQ+XiTfivKvDUw/QW9r1FejYyeWarMsSBWA+\n0fADjF1M2dkDIVLgYPfwoXEv7l+j654F1KLKB69F0F/netwP9CQ="
bundler_args: --path vendor/bundle
+matrix:
+ allow_failures:
+ - rvm: 2.0.0
View
10 Gemfile
@@ -4,7 +4,7 @@ gemspec
gem 'arel', github: 'rails/arel', branch: 'master'
-gem 'mocha', '>= 0.11.2', require: false
+gem 'mocha', '~> 0.13.0', require: false
gem 'rack-test', github: 'brynary/rack-test'
gem 'rack-cache', '~> 1.2'
gem 'bcrypt-ruby', '~> 3.0.0'
@@ -23,11 +23,7 @@ gem 'uglifier', require: false
gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
group :doc do
- # The current sdoc cannot generate GitHub links due
- # to a bug, but the PR that fixes it has been there
- # for some weeks unapplied. As a temporary solution
- # this is our own fork with the fix.
- gem 'sdoc', github: 'fxn/sdoc'
+ gem 'sdoc', github: 'voloko/sdoc'
gem 'redcarpet', '~> 2.2.2', platforms: :ruby
gem 'w3c_validators'
end
@@ -55,7 +51,7 @@ platforms :ruby do
group :db do
gem 'pg', '>= 0.11.0'
- gem 'mysql', '>= 2.8.1' if RUBY_VERSION < '2.0.0'
+ gem 'mysql', '>= 2.9.0'
gem 'mysql2', '>= 0.3.10'
end
end
View
3 actionmailer/CHANGELOG.md
@@ -1,5 +1,8 @@
## Rails 4.0.0 (unreleased) ##
+* Explicit multipart messages no longer set the order of the MIME parts.
+ *Nate Berkopec*
+
* Do not render views when mail() isn't called.
Fix #7761
View
17 actionmailer/actionmailer.gemspec
@@ -1,22 +1,25 @@
-version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
+version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionmailer'
s.version = version
s.summary = 'Email composition, delivery, and receiving framework (part of Rails).'
s.description = 'Email on Rails. Compose, deliver, receive, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments.'
+
s.required_ruby_version = '>= 1.9.3'
- s.license = 'MIT'
- s.author = 'David Heinemeier Hansson'
- s.email = 'david@loudthinking.com'
- s.homepage = 'http://www.rubyonrails.org'
+ s.license = 'MIT'
+
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
s.files = Dir['CHANGELOG.md', 'README.rdoc', 'MIT-LICENSE', 'lib/**/*']
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency('actionpack', version)
- s.add_dependency('mail', '~> 2.4.4')
+ s.add_dependency 'actionpack', version
+
+ s.add_dependency 'mail', '~> 2.5.2'
end
View
1 actionmailer/lib/action_mailer.rb
@@ -44,4 +44,5 @@ module ActionMailer
autoload :MailHelper
autoload :TestCase
autoload :TestHelper
+ autoload :QueuedMessage
end
View
37 actionmailer/lib/action_mailer/base.rb
@@ -70,7 +70,7 @@ module ActionMailer
# The block syntax is also useful in providing information specific to a part:
#
# mail(to: user.email) do |format|
- # format.text(:content_transfer_encoding => "base64")
+ # format.text(content_transfer_encoding: "base64")
# format.html
# end
#
@@ -129,12 +129,12 @@ module ActionMailer
# It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt>
# option as a configuration option in <tt>config/application.rb</tt>:
#
- # config.action_mailer.default_url_options = { :host => "example.com" }
+ # config.action_mailer.default_url_options = { host: "example.com" }
#
# When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the
- # <tt>:only_path => false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper
+ # <tt>only_path: false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper
# will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing
- # <tt>:only_path => false</tt> will ensure that absolute URLs are generated.
+ # <tt>only_path: false</tt> will ensure that absolute URLs are generated.
#
# = Sending mail
#
@@ -246,10 +246,10 @@ module ActionMailer
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
# <tt>ActionMailer::Base</tt> sets the following:
#
- # * <tt>:mime_version => "1.0"</tt>
- # * <tt>:charset => "UTF-8",</tt>
- # * <tt>:content_type => "text/plain",</tt>
- # * <tt>:parts_order => [ "text/plain", "text/enriched", "text/html" ]</tt>
+ # * <tt>mime_version: "1.0"</tt>
+ # * <tt>charset: "UTF-8",</tt>
+ # * <tt>content_type: "text/plain",</tt>
+ # * <tt>parts_order: [ "text/plain", "text/enriched", "text/html" ]</tt>
#
# <tt>parts_order</tt> and <tt>charset</tt> are not actually valid <tt>Mail::Message</tt> header fields,
# but Action Mailer translates them appropriately and sets the correct values.
@@ -508,10 +508,7 @@ def initialize(method_name=nil, *args)
def process(*args) #:nodoc:
lookup_context.skip_default_locale!
- generated_mail = super
- unless generated_mail
- @_message = NullMail.new
- end
+ @_message = NullMail.new unless super
end
class NullMail #:nodoc:
@@ -665,7 +662,7 @@ def attachments
#
# The block syntax also allows you to customize the part headers if desired:
#
- # mail(:to => 'mikel@test.lindsaar.net') do |format|
+ # mail(to: 'mikel@test.lindsaar.net') do |format|
# format.text(content_transfer_encoding: "base64")
# format.html
# end
@@ -698,16 +695,15 @@ def mail(headers={}, &block)
assignable.each { |k, v| m[k] = v }
# Render the templates and blocks
- responses, explicit_order = collect_responses_and_parts_order(headers, &block)
+ responses = collect_responses(headers, &block)
create_parts_from_responses(m, responses)
# Setup content type, reapply charset and handle parts order
m.content_type = set_content_type(m, content_type, headers[:content_type])
m.charset = charset
if m.multipart?
- parts_order ||= explicit_order || headers[:parts_order]
- m.body.set_sort_order(parts_order)
+ m.body.set_sort_order(headers[:parts_order])
m.body.sort_parts!
end
@@ -742,14 +738,13 @@ def default_i18n_subject #:nodoc:
I18n.t(:subject, scope: [mailer_scope, action_name], default: action_name.humanize)
end
- def collect_responses_and_parts_order(headers) #:nodoc:
- responses, parts_order = [], nil
+ def collect_responses(headers) #:nodoc:
+ responses = []
if block_given?
collector = ActionMailer::Collector.new(lookup_context) { render(action_name) }
yield(collector)
- parts_order = collector.responses.map { |r| r[:content_type] }
- responses = collector.responses
+ responses = collector.responses
elsif headers[:body]
responses << {
body: headers.delete(:body),
@@ -769,7 +764,7 @@ def collect_responses_and_parts_order(headers) #:nodoc:
end
end
- [responses, parts_order]
+ responses
end
def each_template(paths, name, &block) #:nodoc:
View
42 actionmailer/test/base_test.rb
@@ -322,19 +322,6 @@ def teardown
assert_not_nil(mail.content_type_parameters[:boundary])
end
- test "explicit multipart does not sort order" do
- order = ["text/html", "text/plain"]
- with_default BaseMailer, parts_order: order do
- email = BaseMailer.explicit_multipart
- assert_equal("text/plain", email.parts[0].mime_type)
- assert_equal("text/html", email.parts[1].mime_type)
-
- email = BaseMailer.explicit_multipart(parts_order: order.reverse)
- assert_equal("text/plain", email.parts[0].mime_type)
- assert_equal("text/html", email.parts[1].mime_type)
- end
- end
-
test "explicit multipart with attachments creates nested parts" do
email = BaseMailer.explicit_multipart(attachments: true)
assert_equal("application/pdf", email.parts[0].mime_type)
@@ -349,10 +336,10 @@ def teardown
email = BaseMailer.explicit_multipart_templates
assert_equal(2, email.parts.size)
assert_equal("multipart/alternative", email.mime_type)
- assert_equal("text/html", email.parts[0].mime_type)
- assert_equal("HTML Explicit Multipart Templates", email.parts[0].body.encoded)
- assert_equal("text/plain", email.parts[1].mime_type)
- assert_equal("TEXT Explicit Multipart Templates", email.parts[1].body.encoded)
+ assert_equal("text/plain", email.parts[0].mime_type)
+ assert_equal("TEXT Explicit Multipart Templates", email.parts[0].body.encoded)
+ assert_equal("text/html", email.parts[1].mime_type)
+ assert_equal("HTML Explicit Multipart Templates", email.parts[1].body.encoded)
end
test "explicit multipart with format.any" do
@@ -387,10 +374,23 @@ def teardown
email = BaseMailer.explicit_multipart_with_one_template
assert_equal(2, email.parts.size)
assert_equal("multipart/alternative", email.mime_type)
- assert_equal("text/html", email.parts[0].mime_type)
- assert_equal("[:html]", email.parts[0].body.encoded)
- assert_equal("text/plain", email.parts[1].mime_type)
- assert_equal("[:text]", email.parts[1].body.encoded)
+ assert_equal("text/plain", email.parts[0].mime_type)
+ assert_equal("[:text]", email.parts[0].body.encoded)
+ assert_equal("text/html", email.parts[1].mime_type)
+ assert_equal("[:html]", email.parts[1].body.encoded)
+ end
+
+ test "explicit multipart with sort order" do
+ order = ["text/html", "text/plain"]
+ with_default BaseMailer, parts_order: order do
+ email = BaseMailer.explicit_multipart
+ assert_equal("text/html", email.parts[0].mime_type)
+ assert_equal("text/plain", email.parts[1].mime_type)
+
+ email = BaseMailer.explicit_multipart(parts_order: order.reverse)
+ assert_equal("text/plain", email.parts[0].mime_type)
+ assert_equal("text/html", email.parts[1].mime_type)
+ end
end
# Class level API with method missing
View
116 actionpack/CHANGELOG.md
@@ -1,5 +1,111 @@
## Rails 4.0.0 (unreleased) ##
+* More descriptive error messages when calling `render :partial` with
+ an invalid `:layout` argument.
+ #8376
+
+ render :partial => 'partial', :layout => true
+
+ # results in ActionView::MissingTemplate: Missing partial /true
+
+ *Yves Senn*
+
+* Sweepers was extracted from Action Controller as `rails-observers` gem.
+
+ *Rafael Mendonça França*
+
+* Add option flag to `CacheHelper#cache` to manually bypass automatic template digests:
+
+ <% cache project, skip_digest: true do %>
+ ...
+ <% end %>
+
+ *Drew Ulmer*
+
+* No sort Hash options in #grouped_options_for_select. *Sergey Kojin*
+
+* Accept symbols as #send_data :disposition value *Elia Schito*
+
+* Add i18n scope to distance_of_time_in_words. *Steve Klabnik*
+
+* `assert_template`:
+ - is no more passing with empty string.
+ - is now validating option keys. It accepts: `:layout`, `:partial`, `:locals` and `:count`.
+
+ *Roberto Soares*
+
+* Allow setting a symbol as path in scope on routes. This is now allowed:
+
+ scope :api do
+ resources :users
+ end
+
+ It is also possible to pass multiple symbols to scope to shorten multiple nested scopes:
+
+ scope :api do
+ scope :v1 do
+ resources :users
+ end
+ end
+
+ can be rewritten as:
+
+ scope :api, :v1 do
+ resources :users
+ end
+
+ *Guillermo Iguaran*
+
+* Fix error when using a non-hash query argument named "params" in `url_for`.
+
+ Before:
+
+ url_for(params: "") # => undefined method `reject!' for "":String
+
+ After:
+
+ url_for(params: "") # => http://www.example.com?params=
+
+ *tumayun + Carlos Antonio da Silva*
+
+* Render every partial with a new `ActionView::PartialRenderer`. This resolves
+ issues when rendering nested partials.
+ Fix #8197
+
+ *Yves Senn*
+
+* Introduce `ActionView::Template::Handlers::ERB.escape_whitelist`. This is a list
+ of mime types where template text is not html escaped by default. It prevents `Jack & Joe`
+ from rendering as `Jack &amp; Joe` for the whitelisted mime types. The default whitelist
+ contains text/plain. Fix #7976
+
+ *Joost Baaij*
+
+* Fix input name when `:multiple => true` and `:index` are set.
+
+ Before:
+
+ check_box("post", "comment_ids", { :multiple => true, :index => "foo" }, 1)
+ #=> <input name=\"post[foo][comment_ids]\" type=\"hidden\" value=\"0\" /><input id=\"post_foo_comment_ids_1\" name=\"post[foo][comment_ids]\" type=\"checkbox\" value=\"1\" />
+
+ After:
+
+ check_box("post", "comment_ids", { :multiple => true, :index => "foo" }, 1)
+ #=> <input name=\"post[foo][comment_ids][]\" type=\"hidden\" value=\"0\" /><input id=\"post_foo_comment_ids_1\" name=\"post[foo][comment_ids][]\" type=\"checkbox\" value=\"1\" />
+
+ Fix #8108
+
+ *Daniel Fox, Grant Hutchins & Trace Wax*
+
+* Clear url helpers when reloading routes.
+
+ *Santiago Pastorino*
+
+* `BestStandardsSupport` middleware now appends it's `X-UA-Compatible` value to app's
+ returned value if any. Fix #8086
+
+ *Nikita Afanasenko*
+
* `date_select` helper accepts `with_css_classes: true` to add css classes similar with type
of generated select tags.
@@ -134,16 +240,6 @@
*Tima Maslyuchenko*
-* Fixed a bug with shorthand routes scoped with the `:module` option not
- adding the module to the controller as described in issue #6497.
- This should now work properly:
-
- scope :module => "engine" do
- get "api/version" # routes to engine/api#version
- end
-
- *Luiz Felipe Garcia Pereira*
-
* Sprockets integration has been extracted from Action Pack to the `sprockets-rails`
gem. `rails` gem is depending on `sprockets-rails` by default.
View
28 actionpack/actionpack.gemspec
@@ -1,29 +1,31 @@
-version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
+version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionpack'
s.version = version
s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).'
s.description = 'Web apps on Rails. Simple, battle-tested conventions for building and testing MVC web applications. Works with any Rack-compatible server.'
+
s.required_ruby_version = '>= 1.9.3'
- s.license = 'MIT'
- s.author = 'David Heinemeier Hansson'
- s.email = 'david@loudthinking.com'
- s.homepage = 'http://www.rubyonrails.org'
+ s.license = 'MIT'
+
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
s.files = Dir['CHANGELOG.md', 'README.rdoc', 'MIT-LICENSE', 'lib/**/*']
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency('activesupport', version)
- s.add_dependency('builder', '~> 3.1.0')
- s.add_dependency('rack', '~> 1.4.1')
- s.add_dependency('rack-test', '~> 0.6.1')
- s.add_dependency('journey', '~> 2.0.0')
- s.add_dependency('erubis', '~> 2.7.0')
+ s.add_dependency 'activesupport', version
+ s.add_dependency 'builder', '~> 3.1.0'
+ s.add_dependency 'rack', '~> 1.4.1'
+ s.add_dependency 'rack-test', '~> 0.6.1'
+ s.add_dependency 'journey', '~> 2.0.0'
+ s.add_dependency 'erubis', '~> 2.7.0'
- s.add_development_dependency('activemodel', version)
- s.add_development_dependency('tzinfo', '~> 0.3.33')
+ s.add_development_dependency 'activemodel', version
+ s.add_development_dependency 'tzinfo', '~> 0.3.33'
end
View
15 actionpack/lib/abstract_controller/callbacks.rb
@@ -29,13 +29,14 @@ module ClassMethods
# * <tt>only</tt> - The callback should be run only for this action
# * <tt>except</tt> - The callback should be run for all actions except this action
def _normalize_callback_options(options)
- if only = options[:only]
- only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
- options[:if] = Array(options[:if]) << only
- end
- if except = options[:except]
- except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
- options[:unless] = Array(options[:unless]) << except
+ _normalize_callback_option(options, :only, :if)
+ _normalize_callback_option(options, :except, :unless)
+ end
+
+ def _normalize_callback_option(options, from, to) # :nodoc:
+ if from = options[from]
+ from = Array(from).map {|o| "action_name == '#{o}'"}.join(" || ")
+ options[to] = Array(options[to]) << from
end
end
View
6 actionpack/lib/abstract_controller/layouts.rb
@@ -170,7 +170,7 @@ module AbstractController
# <tt>:only</tt> and <tt>:except</tt> options can be passed to the layout call. For example:
#
# class WeblogController < ActionController::Base
- # layout "weblog_standard", :except => :rss
+ # layout "weblog_standard", except: :rss
#
# # ...
#
@@ -180,7 +180,7 @@ module AbstractController
# be rendered directly, without wrapping a layout around the rendered view.
#
# Both the <tt>:only</tt> and <tt>:except</tt> condition can accept an arbitrary number of method references, so
- # #<tt>:except => [ :rss, :text_only ]</tt> is valid, as is <tt>:except => :rss</tt>.
+ # #<tt>except: [ :rss, :text_only ]</tt> is valid, as is <tt>except: :rss</tt>.
#
# == Using a different layout in the action render call
#
@@ -192,7 +192,7 @@ module AbstractController
# layout "weblog_standard"
#
# def help
- # render :action => "help", :layout => "help"
+ # render action: "help", layout: "help"
# end
# end
#
View
1 actionpack/lib/action_controller/base.rb
@@ -1,4 +1,5 @@
require "action_controller/log_subscriber"
+require "action_controller/metal/params_wrapper"
module ActionController
# Action Controllers are the core of a web request in \Rails. They are made up of one or more actions that are executed
View
7 actionpack/lib/action_controller/caching.rb
@@ -6,10 +6,10 @@ module ActionController
# \Caching is a cheap way of speeding up slow applications by keeping the result of
# calculations, renderings, and database calls around for subsequent requests.
#
- # You can read more about each approach and the sweeping assistance by clicking the
+ # You can read more about each approach and the by clicking the
# modules below.
#
- # Note: To turn off all caching and sweeping, set
+ # Note: To turn off all caching, set
# config.action_controller.perform_caching = false.
#
# == \Caching stores
@@ -30,8 +30,6 @@ module Caching
eager_autoload do
autoload :Fragments
- autoload :Sweeper, 'action_controller/caching/sweeping'
- autoload :Sweeping, 'action_controller/caching/sweeping'
end
module ConfigMethods
@@ -54,7 +52,6 @@ def cache_configured?
include ConfigMethods
include Fragments
- include Sweeping if defined?(ActiveRecord)
included do
extend ConfigMethods
View
116 actionpack/lib/action_controller/caching/sweeping.rb
@@ -1,116 +0,0 @@
-module ActionController
- module Caching
- # Sweepers are the terminators of the caching world and responsible for expiring
- # caches when Active Record objects change. They do this by being half-observers,
- # half-filters and implementing callbacks for both roles.
- #
- # class ListSweeper < ActionController::Caching::Sweeper
- # observe List, Item
- #
- # def after_save(record)
- # list = record.is_a?(List) ? record : record.list
- # expire_page(controller: 'lists', action: %w( show public feed ), id: list.id)
- # expire_action(controller: 'lists', action: 'all')
- # list.shares.each { |share| expire_page(controller: 'lists', action: 'show', id: share.url_key) }
- # end
- # end
- #
- # The sweeper is assigned in the controllers that wish to have its job performed using
- # the +cache_sweeper+ class method:
- #
- # class ListsController < ApplicationController
- # caches_action :index, :show, :public, :feed
- # cache_sweeper :list_sweeper, only: [ :edit, :destroy, :share ]
- # end
- #
- # In the example above, four actions are cached and three actions are responsible for expiring those caches.
- #
- # You can also name an explicit class in the declaration of a sweeper, which is needed
- # if the sweeper is in a module:
- #
- # class ListsController < ApplicationController
- # caches_action :index, :show, :public, :feed
- # cache_sweeper OpenBar::Sweeper, only: [ :edit, :destroy, :share ]
- # end
- module Sweeping
- extend ActiveSupport::Concern
-
- module ClassMethods # :nodoc:
- def cache_sweeper(*sweepers)
- configuration = sweepers.extract_options!
-
- sweepers.each do |sweeper|
- ActiveRecord::Base.observers << sweeper if defined?(ActiveRecord) and defined?(ActiveRecord::Base)
- sweeper_instance = (sweeper.is_a?(Symbol) ? Object.const_get(sweeper.to_s.classify) : sweeper).instance
-
- if sweeper_instance.is_a?(Sweeper)
- around_filter(sweeper_instance, :only => configuration[:only])
- else
- after_filter(sweeper_instance, :only => configuration[:only])
- end
- end
- end
- end
- end
-
- if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)
- class Sweeper < ActiveRecord::Observer # :nodoc:
- attr_accessor :controller
-
- def initialize(*args)
- super
- @controller = nil
- end
-
- def before(controller)
- self.controller = controller
- callback(:before) if controller.perform_caching
- true # before method from sweeper should always return true
- end
-
- def after(controller)
- self.controller = controller
- callback(:after) if controller.perform_caching
- end
-
- def around(controller)
- before(controller)
- yield
- after(controller)
- ensure
- clean_up
- end
-
- protected
- # gets the action cache path for the given options.
- def action_path_for(options)
- Actions::ActionCachePath.new(controller, options).path
- end
-
- # Retrieve instance variables set in the controller.
- def assigns(key)
- controller.instance_variable_get("@#{key}")
- end
-
- private
- def clean_up
- # Clean up, so that the controller can be collected after this request
- self.controller = nil
- end
-
- def callback(timing)
- controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
- action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
-
- __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
- __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
- end
-
- def method_missing(method, *arguments, &block)
- return super unless @controller
- @controller.__send__(method, *arguments, &block)
- end
- end
- end
- end
-end
View
4 actionpack/lib/action_controller/metal.rb
@@ -5,7 +5,7 @@ module ActionController
# allowing the following syntax in controllers:
#
# class PostsController < ApplicationController
- # use AuthenticationMiddleware, :except => [:index, :show]
+ # use AuthenticationMiddleware, except: [:index, :show]
# end
#
class MiddlewareStack < ActionDispatch::MiddlewareStack #:nodoc:
@@ -56,7 +56,7 @@ def build(action, app=nil, &block)
# And then to route requests to your metal controller, you would add
# something like this to <tt>config/routes.rb</tt>:
#
- # match 'hello', :to => HelloController.action(:index)
+ # match 'hello', to: HelloController.action(:index)
#
# The +action+ method returns a valid Rack application for the \Rails
# router to dispatch to.
View
2 actionpack/lib/action_controller/metal/conditional_get.rb
@@ -64,7 +64,7 @@ def etag(&etagger)
#
# def show
# @article = Article.find(params[:id])
- # fresh_when(@article, :public => true)
+ # fresh_when(@article, public: true)
# end
def fresh_when(record_or_options, additional_options = {})
if record_or_options.is_a? Hash
View
11 actionpack/lib/action_controller/metal/data_streaming.rb
@@ -47,11 +47,11 @@ module DataStreaming
#
# Show a JPEG in the browser:
#
- # send_file '/path/to.jpeg', :type => 'image/jpeg', :disposition => 'inline'
+ # send_file '/path/to.jpeg', type: 'image/jpeg', disposition: 'inline'
#
# Show a 404 page in the browser:
#
- # send_file '/path/to/404.html', :type => 'text/html; charset=utf-8', :status => 404
+ # send_file '/path/to/404.html', type: 'text/html; charset=utf-8', status: 404
#
# Read about the other Content-* HTTP headers if you'd like to
# provide the user with more information (such as Content-Description) in
@@ -96,7 +96,7 @@ def each
end
# Sends the given binary data to the browser. This method is similar to
- # <tt>render :text => data</tt>, but also allows you to specify whether
+ # <tt>render text: data</tt>, but also allows you to specify whether
# the browser should display the response as a file attachment (i.e. in a
# download dialog) or as inline data. You may also set the content type,
# the apparent file name, and other things.
@@ -117,11 +117,11 @@ def each
#
# Download a dynamically-generated tarball:
#
- # send_data generate_tgz('dir'), :filename => 'dir.tgz'
+ # send_data generate_tgz('dir'), filename: 'dir.tgz'
#
# Display an image Active Record in the browser:
#
- # send_data image.data, :type => image.content_type, :disposition => 'inline'
+ # send_data image.data, type: image.content_type, disposition: 'inline'
#
# See +send_file+ for more information on HTTP Content-* headers and caching.
def send_data(data, options = {}) #:doc:
@@ -150,6 +150,7 @@ def send_file_headers!(options)
disposition = options.fetch(:disposition, DEFAULT_SEND_FILE_DISPOSITION)
unless disposition.nil?
+ disposition = disposition.to_s
disposition += %(; filename="#{options[:filename]}") if options[:filename]
headers['Content-Disposition'] = disposition
end
View
2 actionpack/lib/action_controller/metal/force_ssl.rb
@@ -22,7 +22,7 @@ module ClassMethods
# an +:if+ or +:unless+ condition.
#
# class AccountsController < ApplicationController
- # force_ssl :if => :ssl_configured?
+ # force_ssl if: :ssl_configured?
#
# def ssl_configured?
# !Rails.env.development?
View
4 actionpack/lib/action_controller/metal/head.rb
@@ -7,9 +7,9 @@ module Head
# This allows you to easily return a response that consists only of
# significant headers:
#
- # head :created, :location => person_path(@person)
+ # head :created, location: person_path(@person)
#
- # head :created, :location => @person
+ # head :created, location: @person
#
# It can also be used to return exceptional conditions:
#
View
26 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -8,14 +8,14 @@ module HttpAuthentication
# === Simple \Basic example
#
# class PostsController < ApplicationController
- # http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index
+ # http_basic_authenticate_with name: "dhh", password: "secret", except: :index
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
# end
#
@@ -124,14 +124,14 @@ def authentication_request(controller, realm)
# USERS = {"dhh" => "secret", #plain text password
# "dap" => Digest::MD5.hexdigest(["dap",REALM,"secret"].join(":"))} #ha1 digest password
#
- # before_filter :authenticate, :except => [:index]
+ # before_filter :authenticate, except: [:index]
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
#
# private
@@ -249,9 +249,9 @@ def authentication_request(controller, realm, message = nil)
end
def secret_token(request)
- secret = request.env["action_dispatch.secret_token"]
- raise "You must set config.secret_token in your app's config" if secret.blank?
- secret
+ key_generator = request.env["action_dispatch.key_generator"]
+ http_auth_salt = request.env["action_dispatch.http_auth_salt"]
+ key_generator.generate_key(http_auth_salt)
end
# Uses an MD5 digest based on time to generate a value to be used only once.
@@ -317,14 +317,14 @@ def opaque(secret_key)
# class PostsController < ApplicationController
# TOKEN = "secret"
#
- # before_filter :authenticate, :except => [ :index ]
+ # before_filter :authenticate, except: [ :index ]
#
# def index
- # render :text => "Everyone can see me!"
+ # render text: "Everyone can see me!"
# end
#
# def edit
- # render :text => "I'm only accessible if you know the password"
+ # render text: "I'm only accessible if you know the password"
# end
#
# private
@@ -424,7 +424,7 @@ def authenticate(controller, &login_procedure)
# Parses the token and options out of the token authorization header. If
# the header looks like this:
# Authorization: Token token="abc", nonce="def"
- # Then the returned token is "abc", and the options is {:nonce => "def"}
+ # Then the returned token is "abc", and the options is {nonce: "def"}
#
# request - ActionDispatch::Request instance with the current headers.
#
View
26 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -23,13 +23,13 @@ module ClassMethods
# <tt>:except</tt> with an array of actions or a single action:
#
# respond_to :html
- # respond_to :xml, :json, :except => [ :edit ]
+ # respond_to :xml, :json, except: [ :edit ]
#
# This specifies that all actions respond to <tt>:html</tt>
# and all actions except <tt>:edit</tt> respond to <tt>:xml</tt> and
# <tt>:json</tt>.
#
- # respond_to :json, :only => :create
+ # respond_to :json, only: :create
#
# This specifies that the <tt>:create</tt> action and no other responds
# to <tt>:json</tt>.
@@ -70,7 +70,7 @@ def clear_respond_to
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people }
+ # format.xml { render xml: @people }
# end
# end
#
@@ -98,7 +98,7 @@ def clear_respond_to
# respond_to do |format|
# format.html { redirect_to(person_list_url) }
# format.js
- # format.xml { render :xml => @person.to_xml(:include => @company) }
+ # format.xml { render xml: @person.to_xml(include: @company) }
# end
# end
#
@@ -162,11 +162,11 @@ def clear_respond_to
#
# In the example above, if the format is xml, it will render:
#
- # render :xml => @people
+ # render xml: @people
#
# Or if the format is json:
#
- # render :json => @people
+ # render json: @people
#
# Since this is a common pattern, you can use the class method respond_to
# with the respond_with method to have the same results:
@@ -246,10 +246,10 @@ def respond_to(*mimes, &block)
# if @user.save
# flash[:notice] = 'User was successfully created.'
# format.html { redirect_to(@user) }
- # format.xml { render :xml => @user }
+ # format.xml { render xml: @user }
# else
- # format.html { render :action => "new" }
- # format.xml { render :xml => @user }
+ # format.html { render action: "new" }
+ # format.xml { render xml: @user }
# end
# end
# end
@@ -259,8 +259,8 @@ def respond_to(*mimes, &block)
# * for other requests - i.e. data formats such as xml, json, csv etc, if
# the resource passed to +respond_with+ responds to <code>to_<format></code>,
# the method attempts to render the resource in the requested format
- # directly, e.g. for an xml request, the response is equivalent to calling
- # <code>render :xml => resource</code>.
+ # directly, e.g. for an xml request, the response is equivalent to calling
+ # <code>render xml: resource</code>.
#
# === Nested resources
#
@@ -309,7 +309,7 @@ def respond_to(*mimes, &block)
# Also, a hash passed to +respond_with+ immediately after the specified
# resource(s) is interpreted as a set of options relevant to all
# formats. Any option accepted by +render+ can be used, e.g.
- # respond_with @people, :status => 200
+ # respond_with @people, status: 200
# However, note that these options are ignored after an unsuccessful attempt
# to save a resource, e.g. when automatically rendering <tt>:new</tt>
# after a post request.
@@ -381,7 +381,7 @@ def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
#
# respond_to do |format|
# format.html
- # format.xml { render :xml => @people }
+ # format.xml { render xml: @people }
# end
#
# In this usage, the argument passed to the block (+format+ above) is an
View
166 actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -1,7 +1,8 @@
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/module/anonymous'
-require 'action_dispatch/http/mime_types'
+require 'active_support/core_ext/struct'
+require 'action_dispatch/http/mime_type'
module ActionController
# Wraps the parameters hash into a nested hash. This will allow clients to submit
@@ -72,17 +73,104 @@ module ParamsWrapper
EXCLUDE_PARAMETERS = %w(authenticity_token _method utf8)
+ require 'mutex_m'
+
+ class Options < Struct.new(:name, :format, :include, :exclude, :klass, :model) # :nodoc:
+ include Mutex_m
+
+ def self.from_hash(hash)
+ name = hash[:name]
+ format = Array(hash[:format])
+ include = hash[:include] && Array(hash[:include]).collect(&:to_s)
+ exclude = hash[:exclude] && Array(hash[:exclude]).collect(&:to_s)
+ new name, format, include, exclude, nil, nil
+ end
+
+ def initialize(name, format, include, exclude, klass, model) # nodoc
+ super
+ @include_set = include
+ @name_set = name
+ end
+
+ def model
+ super || synchronize { super || self.model = _default_wrap_model }
+ end
+
+ def include
+ return super if @include_set
+
+ m = model
+ synchronize do
+ return super if @include_set
+
+ @include_set = true
+
+ unless super || exclude
+ if m.respond_to?(:attribute_names) && m.attribute_names.any?
+ self.include = m.attribute_names
+ end
+ end
+ end
+ end
+
+ def name
+ return super if @name_set
+
+ m = model
+ synchronize do
+ return super if @name_set
+
+ @name_set = true
+
+ unless super || klass.anonymous?
+ self.name = m ? m.to_s.demodulize.underscore :
+ klass.controller_name.singularize
+ end
+ end
+ end
+
+ private
+ # Determine the wrapper model from the controller's name. By convention,
+ # this could be done by trying to find the defined model that has the
+ # same singularize name as the controller. For example, +UsersController+
+ # will try to find if the +User+ model exists.
+ #
+ # This method also does namespace lookup. Foo::Bar::UsersController will
+ # try to find Foo::Bar::User, Foo::User and finally User.
+ def _default_wrap_model #:nodoc:
+ return nil if klass.anonymous?
+ model_name = klass.name.sub(/Controller$/, '').classify
+
+ begin
+ if model_klass = model_name.safe_constantize
+ model_klass
+ else
+ namespaces = model_name.split("::")
+ namespaces.delete_at(-2)
+ break if namespaces.last == model_name
+ model_name = namespaces.join("::")
+ end
+ end until model_klass
+
+ model_klass
+ end
+ end
+
included do
class_attribute :_wrapper_options
- self._wrapper_options = { :format => [] }
+ self._wrapper_options = Options.from_hash(format: [])
end
module ClassMethods
+ def _set_wrapper_options(options)
+ self._wrapper_options = Options.from_hash(options)
+ end
+
# Sets the name of the wrapper key, or the model which +ParamsWrapper+
# would use to determine the attribute names from.
#
# ==== Examples
- # wrap_parameters :format => :xml
+ # wrap_parameters format: :xml
# # enables the parameter wrapper for XML format
#
# wrap_parameters :person
@@ -92,7 +180,7 @@ module ClassMethods
# # wraps parameters by determining the wrapper key from Person class
# (+person+, in this case) and the list of attribute names
#
- # wrap_parameters :include => [:username, :title]
+ # wrap_parameters include: [:username, :title]
# # wraps only +:username+ and +:title+ attributes from parameters.
#
# wrap_parameters false
@@ -119,68 +207,24 @@ def wrap_parameters(name_or_model_or_options, options = {})
model = name_or_model_or_options
end
- _set_wrapper_defaults(_wrapper_options.slice(:format).merge(options), model)
+ opts = Options.from_hash _wrapper_options.to_h.slice(:format).merge(options)
+ opts.model = model
+ opts.klass = self
+
+ self._wrapper_options = opts
end
# Sets the default wrapper key or model which will be used to determine
# wrapper key and attribute names. Will be called automatically when the
# module is inherited.
def inherited(klass)
- if klass._wrapper_options[:format].present?
- klass._set_wrapper_defaults(klass._wrapper_options.slice(:format))
+ if klass._wrapper_options.format.any?
+ params = klass._wrapper_options.dup
+ params.klass = klass
+ klass._wrapper_options = params
end
super
end
-
- protected
-
- # Determine the wrapper model from the controller's name. By convention,
- # this could be done by trying to find the defined model that has the
- # same singularize name as the controller. For example, +UsersController+
- # will try to find if the +User+ model exists.
- #
- # This method also does namespace lookup. Foo::Bar::UsersController will
- # try to find Foo::Bar::User, Foo::User and finally User.
- def _default_wrap_model #:nodoc:
- return nil if self.anonymous?
- model_name = self.name.sub(/Controller$/, '').classify
-
- begin
- if model_klass = model_name.safe_constantize
- model_klass
- else
- namespaces = model_name.split("::")
- namespaces.delete_at(-2)
- break if namespaces.last == model_name
- model_name = namespaces.join("::")
- end
- end until model_klass
-
- model_klass
- end
-
- def _set_wrapper_defaults(options, model=nil)
- options = options.dup
-
- unless options[:include] || options[:exclude]
- model ||= _default_wrap_model
- if model.respond_to?(:attribute_names) && model.attribute_names.present?
- options[:include] = model.attribute_names
- end
- end
-
- unless options[:name] || self.anonymous?
- model ||= _default_wrap_model
- options[:name] = model ? model.to_s.demodulize.underscore :
- controller_name.singularize
- end
-
- options[:include] = Array(options[:include]).collect(&:to_s) if options[:include]
- options[:exclude] = Array(options[:exclude]).collect(&:to_s) if options[:exclude]
- options[:format] = Array(options[:format])
-
- self._wrapper_options = options
- end
end
# Performs parameters wrapping upon the request. Will be called automatically
@@ -205,20 +249,20 @@ def process_action(*args)
# Returns the wrapper key which will use to stored wrapped parameters.
def _wrapper_key
- _wrapper_options[:name]
+ _wrapper_options.name
end
# Returns the list of enabled formats.
def _wrapper_formats
- _wrapper_options[:format]
+ _wrapper_options.format
end
# Returns the list of parameters which will be selected for wrapped.
def _wrap_parameters(parameters)
- value = if include_only = _wrapper_options[:include]
+ value = if include_only = _wrapper_options.include
parameters.slice(*include_only)
else
- exclude = _wrapper_options[:exclude] || []
+ exclude = _wrapper_options.exclude || []
parameters.except(*(exclude + EXCLUDE_PARAMETERS))
end
View
22 actionpack/lib/action_controller/metal/redirecting.rb
@@ -24,7 +24,7 @@ module Redirecting
# * <tt>:back</tt> - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
# Short-hand for <tt>redirect_to(request.env["HTTP_REFERER"])</tt>
#
- # redirect_to :action => "show", :id => 5
+ # redirect_to action: "show", id: 5
# redirect_to post
# redirect_to "http://www.rubyonrails.org"
# redirect_to "/images/screenshot.jpg"
@@ -34,10 +34,10 @@ module Redirecting
#
# The redirection happens as a "302 Moved" header unless otherwise specified.
#
- # redirect_to post_url(@post), :status => :found
- # redirect_to :action=>'atom', :status => :moved_permanently
- # redirect_to post_url(@post), :status => 301
- # redirect_to :action=>'atom', :status => 302
+ # redirect_to post_url(@post), status: :found
+ # redirect_to action: 'atom', status: :moved_permanently
+ # redirect_to post_url(@post), status: 301
+ # redirect_to action: 'atom', status: 302
#
# The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
# integer, or a symbol representing the downcased, underscored and symbolized description.
@@ -49,16 +49,16 @@ module Redirecting
# around this you can return a <tt>303 See Other</tt> status code which will be
# followed using a GET request.
#
- # redirect_to posts_url, :status => :see_other
- # redirect_to :action => 'index', :status => 303
+ # redirect_to posts_url, status: :see_other
+ # redirect_to action: 'index', status: 303
#
# It is also possible to assign a flash message as part of the redirection. There are two special accessors for the commonly used flash names
# +alert+ and +notice+ as well as a general purpose +flash+ bucket.
#
- # redirect_to post_url(@post), :alert => "Watch it, mister!"
- # redirect_to post_url(@post), :status=> :found, :notice => "Pay attention to the road"
- # redirect_to post_url(@post), :status => 301, :flash => { :updated_post_id => @post.id }
- # redirect_to { :action=>'atom' }, :alert => "Something serious happened"
+ # redirect_to post_url(@post), alert: "Watch it, mister!"
+ # redirect_to post_url(@post), status: :found, notice: "Pay attention to the road"
+ # redirect_to post_url(@post), status: 301, flash: { updated_post_id: @post.id }
+ # redirect_to { action: 'atom' }, alert: "Something serious happened"
#
# When using <tt>redirect_to :back</tt>, if there is no referrer, ActionController::RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing ActionController::RedirectBackError.
View
6 actionpack/lib/action_controller/metal/renderers.rb
@@ -52,8 +52,8 @@ def _handle_render_options(options)
# ActionController::Renderers.add :csv do |obj, options|
# filename = options[:filename] || 'data'
# str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
- # send_data str, :type => Mime::CSV,
- # :disposition => "attachment; filename=#{filename}.csv"
+ # send_data str, type: Mime::CSV,
+ # disposition: "attachment; filename=#{filename}.csv"
# end
#
# Note that we used Mime::CSV for the csv mime type as it comes with Rails.
@@ -66,7 +66,7 @@ def _handle_render_options(options)
# @csvable = Csvable.find(params[:id])
# respond_to do |format|
# format.html
- # format.csv { render :csv => @csvable, :filename => @csvable.name }
+ # format.csv { render csv: @csvable, filename: @csvable.name }
# }
# end
# To use renderers and their mime types in more concise ways, see
View
14 actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -19,7 +19,7 @@ class InvalidAuthenticityToken < ActionControllerError #:nodoc:
#
# class ApplicationController < ActionController::Base
# protect_from_forgery
- # skip_before_filter :verify_authenticity_token, :if => :json_request?
+ # skip_before_filter :verify_authenticity_token, if: :json_request?
#
# protected
#
@@ -62,15 +62,15 @@ module ClassMethods
# Turn on request forgery protection. Bear in mind that only non-GET, HTML/JavaScript requests are checked.
#
# class FooController < ApplicationController
- # protect_from_forgery :except => :index
+ # protect_from_forgery except: :index
#
# You can disable csrf protection on controller-by-controller basis:
#
# skip_before_filter :verify_authenticity_token
#
# It can also be disabled for specific controller actions:
#
- # skip_before_filter :verify_authenticity_token, :except => [:create]
+ # skip_before_filter :verify_authenticity_token, except: [:create]
#
# Valid Options:
#
@@ -121,11 +121,11 @@ def exists?
class NullCookieJar < ActionDispatch::Cookies::CookieJar #:nodoc:
def self.build(request)
- secret = request.env[ActionDispatch::Cookies::TOKEN_KEY]
- host = request.host
- secure = request.ssl?
+ key_generator = request.env[ActionDispatch::Cookies::GENERATOR_KEY]
+ host = request.host
+ secure = request.ssl?
- new(secret, host, secure)
+ new(key_generator, host, secure)
end
def write(*)
View
20 actionpack/lib/action_controller/metal/responder.rb
@@ -45,10 +45,10 @@ module ActionController #:nodoc:
# if @user.save
# flash[:notice] = 'User was successfully created.'
# format.html { redirect_to(@user) }
- # format.xml { render :xml => @user, :status => :created, :location => @user }
+ # format.xml { render xml: @user, status: :created, location: @user }
# else
- # format.html { render :action => "new" }
- # format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ # format.html { render action: "new" }
+ # format.xml { render xml: @user.errors, status: :unprocessable_entity }
# end
# end
# end
@@ -92,7 +92,7 @@ module ActionController #:nodoc:
# @project = Project.find(params[:project_id])
# @task = @project.tasks.build(params[:task])
# flash[:notice] = 'Task was successfully created.' if @task.save
- # respond_with(@project, @task, :status => 201)
+ # respond_with(@project, @task, status: 201)
# end
#
# This will return status 201 if the task was saved successfully. If not,
@@ -103,7 +103,7 @@ module ActionController #:nodoc:
# def create
# @project = Project.find(params[:project_id])
# @task = @project.tasks.build(params[:task])
- # respond_with(@project, @task, :status => 201) do |format|
+ # respond_with(@project, @task, status: 201) do |format|
# if @task.save
# flash[:notice] = 'Task was successfully created.'
# else
@@ -236,20 +236,20 @@ def default_render
# Display is just a shortcut to render a resource with the current format.
#
- # display @user, :status => :ok
+ # display @user, status: :ok
#
# For XML requests it's equivalent to:
#
- # render :xml => @user, :status => :ok
+ # render xml: @user, status: :ok
#
# Options sent by the user are also used:
#
- # respond_with(@user, :status => :created)
- # display(@user, :status => :ok)
+ # respond_with(@user, status: :created)
+ # display(@user, status: :ok)
#
# Results in:
#
- # render :xml => @user, :status => :created
+ # render xml: @user, status: :created
#
def display(resource, given_options={})
controller.render given_options.merge!(options).merge!(format => resource)
View
6 actionpack/lib/action_controller/metal/streaming.rb
@@ -29,7 +29,7 @@ module ActionController #:nodoc:
# class PostsController
# def index
# @posts = Post.scoped
- # render :stream => true
+ # render stream: true
# end
# end
#
@@ -56,7 +56,7 @@ module ActionController #:nodoc:
# @posts = Post.scoped
# @pages = Page.scoped
# @articles = Article.scoped
- # render :stream => true
+ # render stream: true
# end
#
# Notice that :stream only works with templates. Rendering :json
@@ -176,7 +176,7 @@ module ActionController #:nodoc:
# need to create a config file as follow:
#
# # unicorn.config.rb
- # listen 3000, :tcp_nopush => false
+ # listen 3000, tcp_nopush: false
#
# And use it on initialization:
#
View
20 actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -65,14 +65,12 @@ def initialize(param) # :nodoc:
# params["key"] # => "value"
class Parameters < ActiveSupport::HashWithIndifferentAccess
cattr_accessor :permit_all_parameters, instance_accessor: false
- attr_accessor :permitted # :nodoc:
# Returns a new instance of <tt>ActionController::Parameters</tt>.
# Also, sets the +permitted+ attribute to the default value of
# <tt>ActionController::Parameters.permit_all_parameters</tt>.
#
- # class Person
- # include ActiveRecord::Base
+ # class Person < ActiveRecord::Base
# end
#
# params = ActionController::Parameters.new(name: 'Francesco')
@@ -126,10 +124,10 @@ def permit!
# <tt>ActionController::ParameterMissing</tt> error.
#
# ActionController::Parameters.new(person: { name: 'Francesco' }).require(:person)
- # # => {"name"=>"Francesco"}
+ # # => {"name"=>"Francesco"}