Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
commit bae00bb1cc392e1cf408369809b9cf85468bef42 2 parents 93c76b2 + ffd2cf1
@lifo lifo authored
Showing with 5,057 additions and 8,853 deletions.
  1. 0  .gitmodules
  2. +9 −2 Rakefile
  3. +2 −0  actionpack/CHANGELOG
  4. +2 −0  actionpack/Rakefile
  5. +0 −118 actionpack/examples/minimal.rb
  6. +0 −50 actionpack/examples/very_simple.rb
  7. +0 −1  actionpack/examples/views/_collection.erb
  8. +0 −1  actionpack/examples/views/_hello.erb
  9. +0 −10 actionpack/examples/views/_many_partials.erb
  10. +0 −10 actionpack/examples/views/_partial.erb
  11. +0 −1  actionpack/examples/views/layouts/alt.html.erb
  12. +0 −1  actionpack/examples/views/layouts/kaigi.html.erb
  13. +0 −1  actionpack/examples/views/template.html.erb
  14. +0 −1  actionpack/lib/abstract_controller/base.rb
  15. +57 −20 actionpack/lib/abstract_controller/layouts.rb
  16. +3 −1 actionpack/lib/abstract_controller/logger.rb
  17. +14 −3 actionpack/lib/abstract_controller/rendering_controller.rb
  18. +3 −3 actionpack/lib/action_controller.rb
  19. +13 −5 actionpack/lib/action_controller/metal.rb
  20. +6 −12 actionpack/lib/action_controller/metal/compatibility.rb
  21. +13 −1 actionpack/lib/action_controller/metal/hide_actions.rb
  22. +11 −9 actionpack/lib/action_controller/metal/http_authentication.rb
  23. +29 −23 actionpack/lib/action_controller/metal/mime_responds.rb
  24. +1 −7 actionpack/lib/action_controller/metal/rack_convenience.rb
  25. +3 −0  actionpack/lib/action_controller/metal/redirector.rb
  26. +44 −4 actionpack/lib/action_controller/metal/rendering_controller.rb
  27. +31 −12 actionpack/lib/action_controller/metal/responder.rb
  28. +2 −1  actionpack/lib/action_controller/metal/streaming.rb
  29. +1 −9 actionpack/lib/action_controller/metal/url_for.rb
  30. +38 −0 actionpack/lib/action_controller/middleware.rb
  31. +1 −1  actionpack/lib/action_controller/routing/generation/url_rewriter.rb
  32. +17 −13 actionpack/lib/action_controller/routing/resources.rb
  33. +14 −11 actionpack/lib/action_controller/routing/route_set.rb
  34. +2 −1  actionpack/lib/action_controller/testing/integration.rb
  35. +6 −4 actionpack/lib/action_controller/testing/process.rb
  36. +0 −1  actionpack/lib/action_controller/testing/test_case.rb
  37. +3 −7 actionpack/lib/action_dispatch.rb
  38. +14 −42 actionpack/lib/action_dispatch/http/request.rb
  39. +95 −50 actionpack/lib/action_dispatch/http/response.rb
  40. +13 −5 actionpack/lib/action_dispatch/middleware/params_parser.rb
  41. +2 −0  actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  42. +2 −0  actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  43. +3 −3 actionpack/lib/action_dispatch/middleware/stack.rb
  44. +297 −2 actionpack/lib/action_dispatch/testing/test_request.rb
  45. +0 −90 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack.rb
  46. +0 −22 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/adapter/camping.rb
  47. +0 −37 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/abstract/handler.rb
  48. +0 −37 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/abstract/request.rb
  49. +0 −58 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/basic.rb
  50. +0 −124 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/digest/md5.rb
  51. +0 −51 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/digest/nonce.rb
  52. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/digest/params.rb
  53. +0 −40 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/digest/request.rb
  54. +0 −480 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/auth/openid.rb
  55. +0 −63 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/builder.rb
  56. +0 −36 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/cascade.rb
  57. +0 −49 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/chunked.rb
  58. +0 −61 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/commonlogger.rb
  59. +0 −47 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/conditionalget.rb
  60. +0 −29 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/content_length.rb
  61. +0 −23 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/content_type.rb
  62. +0 −96 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/deflater.rb
  63. +0 −153 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/directory.rb
  64. +0 −88 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/file.rb
  65. +0 −69 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler.rb
  66. +0 −61 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/cgi.rb
  67. +0 −8 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/evented_mongrel.rb
  68. +0 −88 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/fastcgi.rb
  69. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/lsws.rb
  70. +0 −84 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/mongrel.rb
  71. +0 −59 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/scgi.rb
  72. +0 −8 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/swiftiplied_mongrel.rb
  73. +0 −18 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/thin.rb
  74. +0 −67 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/handler/webrick.rb
  75. +0 −19 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/head.rb
  76. +0 −537 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/lint.rb
  77. +0 −65 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/lobster.rb
  78. +0 −16 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/lock.rb
  79. +0 −27 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/methodoverride.rb
  80. +0 −204 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/mime.rb
  81. +0 −184 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/mock.rb
  82. +0 −57 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/recursive.rb
  83. +0 −106 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/reloader.rb
  84. +0 −254 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/request.rb
  85. +0 −183 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/response.rb
  86. +0 −98 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/rewindable_input.rb
  87. +0 −142 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/session/abstract/id.rb
  88. +0 −91 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/session/cookie.rb
  89. +0 −109 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/session/memcache.rb
  90. +0 −100 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/session/pool.rb
  91. +0 −349 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/showexceptions.rb
  92. +0 −106 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/showstatus.rb
  93. +0 −38 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/static.rb
  94. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/urlmap.rb
  95. +0 −516 actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/utils.rb
  96. +0 −50 actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb
  97. +0 −239 actionpack/lib/action_dispatch/vendor/rack-test/rack/test.rb
  98. +0 −169 actionpack/lib/action_dispatch/vendor/rack-test/rack/test/cookie_jar.rb
  99. +0 −45 actionpack/lib/action_dispatch/vendor/rack-test/rack/test/methods.rb
  100. +0 −27 actionpack/lib/action_dispatch/vendor/rack-test/rack/test/mock_digest_request.rb
  101. +0 −36 actionpack/lib/action_dispatch/vendor/rack-test/rack/test/uploaded_file.rb
  102. +0 −75 actionpack/lib/action_dispatch/vendor/rack-test/rack/test/utils.rb
  103. +12 −17 actionpack/lib/action_view/base.rb
  104. +1 −0  actionpack/lib/action_view/helpers/form_helper.rb
  105. +69 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
  106. +3 −2 actionpack/lib/action_view/helpers/prototype_helper.rb
  107. +1 −1  actionpack/lib/action_view/helpers/url_helper.rb
  108. +4 −0 actionpack/lib/action_view/locale/en.yml
  109. +0 −3  actionpack/lib/action_view/paths.rb
  110. +106 −53 actionpack/lib/action_view/render/partials.rb
  111. +22 −57 actionpack/lib/action_view/render/rendering.rb
  112. +1 −5 actionpack/lib/action_view/template/handler.rb
  113. +23 −15 actionpack/lib/action_view/template/resolver.rb
  114. +25 −3 actionpack/lib/action_view/template/template.rb
  115. +11 −10 actionpack/lib/action_view/test_case.rb
  116. +32 −21 actionpack/test/abstract_controller/abstract_controller_test.rb
  117. +58 −36 actionpack/test/abstract_controller/callbacks_test.rb
  118. +3 −2 actionpack/test/abstract_controller/helper_test.rb
  119. +33 −22 actionpack/test/abstract_controller/layouts_test.rb
  120. +16 −1 actionpack/test/abstract_unit.rb
  121. +14 −11 actionpack/test/activerecord/active_record_store_test.rb
  122. +0 −12 actionpack/test/controller/action_pack_assertions_test.rb
  123. +17 −17 actionpack/test/controller/base_test.rb
  124. +1 −5 actionpack/test/controller/caching_test.rb
  125. +1 −1  actionpack/test/controller/content_type_test.rb
  126. +45 −41 actionpack/test/controller/mime_responds_test.rb
  127. +13 −11 actionpack/test/controller/redirect_test.rb
  128. +3 −3 actionpack/test/controller/render_js_test.rb
  129. +10 −17 actionpack/test/controller/render_test.rb
  130. +8 −6 actionpack/test/controller/render_xml_test.rb
  131. +1 −5 actionpack/test/controller/request_forgery_protection_test.rb
  132. +44 −0 actionpack/test/controller/resources_test.rb
  133. +225 −857 actionpack/test/controller/routing_test.rb
  134. +0 −7 actionpack/test/controller/test_test.rb
  135. +97 −70 actionpack/test/controller/url_rewriter_test.rb
  136. +4 −1 actionpack/test/controller/verification_test.rb
  137. +68 −62 actionpack/test/controller/webservice_test.rb
  138. +1 −1  actionpack/test/dispatch/mime_type_test.rb
  139. +25 −4 actionpack/test/dispatch/request/json_params_parsing_test.rb
  140. +1 −0  actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  141. +1 −0  actionpack/test/dispatch/request/query_string_parsing_test.rb
  142. +1 −0  actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
  143. +17 −1 actionpack/test/dispatch/request/xml_params_parsing_test.rb
  144. +31 −34 actionpack/test/dispatch/request_test.rb
  145. +11 −8 actionpack/test/dispatch/session/cookie_store_test.rb
  146. +8 −8 actionpack/test/dispatch/session/mem_cache_store_test.rb
  147. 0  ...nder_default_content_types_for_respond_to.rhtml → render_default_content_types_for_respond_to.xml.erb}
  148. +1 −1  actionpack/test/fixtures/test/_customer_with_var.erb
  149. +1 −1  actionpack/test/fixtures/test/_hash_object.erb
  150. +0 −1  actionpack/test/fixtures/test/using_layout_around_block_with_args.html.erb
  151. +5 −4 actionpack/test/lib/controller/fake_controllers.rb
  152. +8 −4 actionpack/test/lib/controller/fake_models.rb
  153. +10 −10 actionpack/test/lib/fixture_template.rb
  154. +2 −2 actionpack/test/new_base/content_type_test.rb
  155. +44 −0 actionpack/test/new_base/metal_test.rb
  156. +1 −1  actionpack/test/new_base/render_layout_test.rb
  157. +3 −4 actionpack/test/new_base/render_rjs_test.rb
  158. +1 −1  actionpack/test/new_base/render_template_test.rb
  159. +17 −7 actionpack/test/new_base/test_helper.rb
  160. +16 −0 actionpack/test/template/form_helper_test.rb
  161. +27 −0 actionpack/test/template/form_options_helper_i18n_test.rb
  162. +34 −0 actionpack/test/template/form_options_helper_test.rb
  163. +4 −0 actionpack/test/template/javascript_helper_test.rb
  164. +4 −0 actionpack/test/template/prototype_helper_test.rb
  165. +26 −12 actionpack/test/template/render_test.rb
  166. +18 −12 actionpack/test/template/text_helper_test.rb
  167. +8 −0 actionpack/test/template/url_helper_test.rb
  168. 0  actionpack/test/tmp/.gitignore
  169. +11 −0 activemodel/CHANGELOG
  170. +1 −1  activemodel/CHANGES
  171. +3 −1 activemodel/lib/active_model.rb
  172. +32 −11 activemodel/lib/active_model/attribute_methods.rb
  173. +126 −0 activemodel/lib/active_model/dirty.rb
  174. +96 −0 activemodel/lib/active_model/lint.rb
  175. +30 −0 activemodel/lib/active_model/serialization.rb
  176. +0 −60 activemodel/lib/active_model/serializer.rb
  177. +4 −14 activemodel/lib/active_model/serializers/json.rb
  178. +52 −24 activemodel/lib/active_model/serializers/xml.rb
  179. +31 −10 activemodel/lib/active_model/validations/format.rb
  180. +20 −1 activemodel/lib/active_model/validations/numericality.rb
  181. +64 −0 activemodel/lib/active_model/validations/with.rb
  182. +50 −0 activemodel/test/cases/lint_test.rb
  183. +4 −9 activemodel/test/cases/tests_database.rb
  184. +29 −0 activemodel/test/cases/validations/format_validation_test.rb
  185. +18 −0 activemodel/test/cases/validations/numericality_validation_test.rb
  186. +116 −0 activemodel/test/cases/validations/with_validation_test.rb
  187. +6 −2 activerecord/CHANGELOG
  188. +30 −10 activerecord/Rakefile
  189. +1 −0  activerecord/examples/.gitignore
  190. +162 −0 activerecord/examples/performance.rb
  191. +1 −0  activerecord/lib/active_record.rb
  192. +29 −2 activerecord/lib/active_record/associations.rb
  193. +1 −0  activerecord/lib/active_record/associations/association_collection.rb
  194. +16 −0 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  195. +1 −0  activerecord/lib/active_record/associations/has_many_association.rb
  196. +17 −16 activerecord/lib/active_record/associations/has_many_through_association.rb
  197. +9 −3 activerecord/lib/active_record/associations/has_one_through_association.rb
  198. +1 −1  activerecord/lib/active_record/associations/through_association_scope.rb
  199. +16 −131 activerecord/lib/active_record/attribute_methods/dirty.rb
  200. +18 −10 activerecord/lib/active_record/base.rb
  201. +1 −1  activerecord/lib/active_record/calculations.rb
  202. +15 −0 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  203. +2 −2 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  204. +7 −0 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  205. +13 −8 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  206. +32 −13 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  207. +0 −5 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  208. +7 −37 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  209. +9 −7 activerecord/lib/active_record/fixtures.rb
  210. +1 −0  activerecord/lib/active_record/locale/en.yml
  211. +1 −1  activerecord/lib/active_record/reflection.rb
  212. +39 −41 activerecord/lib/active_record/serialization.rb
  213. +0 −14 activerecord/lib/active_record/serializers/json_serializer.rb
  214. +10 −9 activerecord/lib/active_record/serializers/xml_serializer.rb
  215. +2 −1  activerecord/lib/active_record/validations.rb
  216. +1 −1  activerecord/lib/active_record/validations/uniqueness.rb
  217. +68 −0 activerecord/lib/active_record/validator.rb
  218. +12 −0 activerecord/test/cases/adapter_test.rb
  219. +0 −18 activerecord/test/cases/associations/belongs_to_associations_test.rb
  220. +56 −0 activerecord/test/cases/associations/habtm_join_table_test.rb
  221. +56 −2 activerecord/test/cases/associations/has_many_associations_test.rb
  222. +54 −1 activerecord/test/cases/associations/has_many_through_associations_test.rb
  223. +10 −0 activerecord/test/cases/associations/has_one_through_associations_test.rb
  224. +4 −4 activerecord/test/cases/associations/join_model_test.rb
  225. +54 −11 activerecord/test/cases/base_test.rb
  226. +34 −0 activerecord/test/cases/column_definition_test.rb
  227. +78 −0 activerecord/test/cases/dirty_test.rb
  228. +5 −0 activerecord/test/cases/i18n_test.rb
  229. +39 −11 activerecord/test/cases/migration_test.rb
  230. +6 −0 activerecord/test/cases/named_scope_test.rb
  231. +18 −0 activerecord/test/cases/pk_test.rb
  232. +2 −2 activerecord/test/cases/reflection_test.rb
  233. +11 −1 activerecord/test/cases/schema_dumper_test.rb
  234. +188 −0 activerecord/test/cases/validations/i18n_validation_test.rb
  235. +15 −4 activerecord/test/cases/validations/uniqueness_validation_test.rb
  236. +0 −25 activerecord/test/connections/native_sqlite/connection.rb
  237. +3 −0  activerecord/test/fixtures/posts.yml
  238. +1 −0  activerecord/test/models/author.rb
  239. +5 −1 activerecord/test/models/comment.rb
  240. +2 −0  activerecord/test/models/company.rb
  241. +4 −0 activerecord/test/models/contract.rb
  242. +13 −2 activerecord/test/schema/postgresql_specific_schema.rb
  243. +4 −0 activerecord/test/schema/schema.rb
  244. +6 −0 activeresource/CHANGELOG
  245. +123 −13 activeresource/lib/active_resource/base.rb
  246. +37 −5 activeresource/lib/active_resource/connection.rb
  247. +11 −0 activeresource/lib/active_resource/exceptions.rb
  248. +58 −8 activeresource/lib/active_resource/validations.rb
  249. +0 −48 activeresource/test/base_errors_test.rb
  250. 0  activeresource/test/{ → cases}/authorization_test.rb
  251. 0  activeresource/test/{ → cases}/base/custom_methods_test.rb
  252. 0  activeresource/test/{ → cases}/base/equality_test.rb
  253. +16 −1 activeresource/test/{ → cases}/base/load_test.rb
  254. +83 −0 activeresource/test/cases/base_errors_test.rb
  255. +89 −76 activeresource/test/{ → cases}/base_test.rb
  256. +233 −0 activeresource/test/cases/finder_test.rb
  257. 0  activeresource/test/{ → cases}/format_test.rb
  258. 0  activeresource/test/{ → cases}/observing_test.rb
  259. +55 −0 activeresource/test/cases/validations_test.rb
  260. +21 −0 activeresource/test/connection_test.rb
  261. +25 −0 activeresource/test/fixtures/project.rb
  262. +15 −7 activesupport/lib/active_support/cache.rb
  263. +1 −0  activesupport/lib/active_support/core_ext/array/conversions.rb
  264. +3 −2 activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
  265. +4 −3 activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
  266. +1 −0  activesupport/lib/active_support/core_ext/date/calculations.rb
  267. +1 −0  activesupport/lib/active_support/core_ext/hash/conversions.rb
  268. +5 −4 activesupport/lib/active_support/core_ext/hash/deep_merge.rb
  269. +9 −4 activesupport/lib/active_support/core_ext/module/delegation.rb
  270. +2 −0  activesupport/lib/active_support/core_ext/regexp.rb
  271. +2 −1  activesupport/lib/active_support/core_ext/time/calculations.rb
  272. +3 −0  activesupport/lib/active_support/inflector.rb
  273. +4 −1 activesupport/lib/active_support/json/backends/yaml.rb
  274. +1 −1  activesupport/lib/active_support/memoizable.rb
  275. +16 −1 activesupport/lib/active_support/multibyte/chars.rb
  276. +7 −0 activesupport/test/core_ext/array_ext_test.rb
  277. +6 −0 activesupport/test/core_ext/date_ext_test.rb
  278. +1 −1  activesupport/test/core_ext/enumerable_test.rb
  279. +19 −0 activesupport/test/core_ext/hash_ext_test.rb
  280. +12 −1 activesupport/test/core_ext/module_test.rb
  281. +9 −9 activesupport/test/core_ext/regexp_ext_test.rb
  282. +42 −35 activesupport/test/dependencies_test.rb
  283. +44 −0 activesupport/test/flush_cache_on_private_memoization_test.rb
  284. +10 −0 activesupport/test/inflector_test.rb
  285. +5 −3 activesupport/test/isolation_test.rb
  286. +5 −3 activesupport/test/json/decoding_test.rb
  287. +13 −2 activesupport/test/multibyte_chars_test.rb
  288. +2 −10 ci/ci_build.rb
  289. +2 −2 ci/ci_setup_notes.txt
  290. +7 −4 ci/cruise_config.rb
  291. +3 −1 ci/geminstaller.yml
  292. +2 −0  railties/CHANGELOG
  293. +8 −4 railties/lib/commands/dbconsole.rb
  294. +36 −57 railties/lib/generators.rb
  295. +5 −7 railties/lib/generators/actions.rb
  296. +0 −1  railties/lib/generators/active_record.rb
  297. +49 −3 railties/lib/generators/base.rb
  298. +2 −3 railties/lib/generators/erb/scaffold/scaffold_generator.rb
  299. +17 −0 railties/lib/generators/erb/scaffold/templates/_form.html.erb
  300. +2 −14 railties/lib/generators/erb/scaffold/templates/edit.html.erb
Sorry, we could not display the entire diff because too many files (385) changed.
View
0  .gitmodules
No changes.
View
11 Rakefile
@@ -3,7 +3,7 @@ require 'rake/rdoctask'
env = %(PKG_BUILD="#{ENV['PKG_BUILD']}") if ENV['PKG_BUILD']
-PROJECTS = %w(activesupport actionpack actionmailer activemodel activeresource activerecord railties)
+PROJECTS = %w(activesupport actionpack actionmailer activeresource activerecord railties)
Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
require version_path
@@ -12,7 +12,7 @@ end
desc 'Run all tests by default'
task :default => :test
-%w(test isolated_test rdoc pgem package release).each do |task_name|
+%w(test isolated_test rdoc pgem package release gem).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
errors = []
@@ -23,6 +23,13 @@ task :default => :test
end
end
+task :install => :gem do
+ (PROJECTS - ["railties"]).each do |project|
+ system("gem install #{project}/pkg/#{project}-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
+ end
+ system("gem install railties/pkg/rails-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc")
+end
+
desc "Generate documentation for the Rails framework"
Rake::RDocTask.new do |rdoc|
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Introduce grouped_collection_select helper. #1249 [Dan Codeape, Erik Ostrom]
+
* Make sure javascript_include_tag/stylesheet_link_tag does not append ".js" or ".css" onto external urls. #1664 [Matthew Rudy Jacobs]
* Ruby 1.9: fix Content-Length for multibyte send_data streaming. #2661 [Sava Chankov]
View
2  actionpack/Rakefile
@@ -116,6 +116,8 @@ spec = Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD)
+ s.add_dependency('rack', '~> 1.0.0')
+ s.add_dependency('rack-test', '~> 0.4.2')
s.require_path = 'lib'
s.autorequire = 'action_controller'
View
118 actionpack/examples/minimal.rb
@@ -1,118 +0,0 @@
-# Pass NEW=1 to run with the new Base
-ENV['RAILS_ENV'] ||= 'production'
-ENV['NO_RELOAD'] ||= '1'
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
-require 'action_controller'
-require 'action_controller/new_base' if ENV['NEW']
-require 'action_view'
-require 'benchmark'
-
-class Runner
- def initialize(app, output)
- @app, @output = app, output
- end
-
- def puts(*)
- super if @output
- end
-
- def call(env)
- env['n'].to_i.times { @app.call(env) }
- @app.call(env).tap { |response| report(env, response) }
- end
-
- def report(env, response)
- return unless ENV["DEBUG"]
- out = env['rack.errors']
- out.puts response[0], response[1].to_yaml, '---'
- response[2].each { |part| out.puts part }
- out.puts '---'
- end
-
- def self.puts(*)
- super if @output
- end
-
- def self.run(app, n, label, output = true)
- @output = output
- puts label, '=' * label.size if label
- env = Rack::MockRequest.env_for("/").merge('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
- t = Benchmark.realtime { new(app, output).call(env) }
- puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
- puts
- end
-end
-
-
-N = (ENV['N'] || 1000).to_i
-
-module ActionController::Rails2Compatibility
- instance_methods.each do |name|
- remove_method name
- end
-end
-
-class BasePostController < ActionController::Base
- append_view_path "#{File.dirname(__FILE__)}/views"
-
- def overhead
- self.response_body = ''
- end
-
- def index
- render :text => ''
- end
-
- def partial
- render :partial => "/partial"
- end
-
- def many_partials
- render :partial => "/many_partials"
- end
-
- def partial_collection
- render :partial => "/collection", :collection => [1,2,3,4,5,6,7,8,9,10]
- end
-
- def show_template
- render :template => "template"
- end
-end
-
-OK = [200, {}, []]
-MetalPostController = lambda { OK }
-
-class HttpPostController < ActionController::Metal
- def index
- self.response_body = ''
- end
-end
-
-unless ENV["PROFILE"]
- Runner.run(BasePostController.action(:overhead), N, 'overhead', false)
- Runner.run(BasePostController.action(:index), N, 'index', false)
- Runner.run(BasePostController.action(:partial), N, 'partial', false)
- Runner.run(BasePostController.action(:many_partials), N, 'many_partials', false)
- Runner.run(BasePostController.action(:partial_collection), N, 'collection', false)
- Runner.run(BasePostController.action(:show_template), N, 'template', false)
-
- (ENV["M"] || 1).to_i.times do
- Runner.run(BasePostController.action(:overhead), N, 'overhead')
- Runner.run(BasePostController.action(:index), N, 'index')
- Runner.run(BasePostController.action(:partial), N, 'partial')
- Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
- Runner.run(BasePostController.action(:partial_collection), N, 'collection')
- Runner.run(BasePostController.action(:show_template), N, 'template')
- end
-else
- Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
- require "ruby-prof"
- RubyProf.start
- Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
- result = RubyProf.stop
- printer = RubyProf::CallStackPrinter.new(result)
- printer.print(File.open("output.html", "w"))
-end
View
50 actionpack/examples/very_simple.rb
@@ -1,50 +0,0 @@
-$:.push "rails/activesupport/lib"
-$:.push "rails/actionpack/lib"
-
-require "action_controller"
-
-class Kaigi < ActionController::Metal
- include AbstractController::Callbacks
- include ActionController::RackConvenience
- include ActionController::RenderingController
- include ActionController::Layouts
- include ActionView::Context
-
- before_filter :set_name
- append_view_path "views"
-
- def view_context
- self
- end
-
- def controller
- self
- end
-
- DEFAULT_LAYOUT = Object.new.tap {|l| def l.render(*) yield end }
-
- def render_template(template, layout = DEFAULT_LAYOUT, options = {}, partial = false)
- ret = template.render(self, {})
- layout.render(self, {}) { ret }
- end
-
- def index
- render :template => "template"
- end
-
- def alt
- render :template => "template", :layout => "alt"
- end
-
- private
- def set_name
- @name = params[:name]
- end
-end
-
-app = Rack::Builder.new do
- map("/kaigi") { run Kaigi.action(:index) }
- map("/kaigi/alt") { run Kaigi.action(:alt) }
-end.to_app
-
-Rack::Handler::Mongrel.run app, :Port => 3000
View
1  actionpack/examples/views/_collection.erb
@@ -1 +0,0 @@
-<%= collection %>
View
1  actionpack/examples/views/_hello.erb
@@ -1 +0,0 @@
-Hello
View
10 actionpack/examples/views/_many_partials.erb
@@ -1,10 +0,0 @@
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
-<%= render :partial => '/hello' %>
View
10 actionpack/examples/views/_partial.erb
@@ -1,10 +0,0 @@
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
-<%= "Hello" %>
View
1  actionpack/examples/views/layouts/alt.html.erb
@@ -1 +0,0 @@
-+ <%= yield %> +
View
1  actionpack/examples/views/layouts/kaigi.html.erb
@@ -1 +0,0 @@
-Hello <%= yield %> Goodbye
View
1  actionpack/examples/views/template.html.erb
@@ -1 +0,0 @@
-Hello
View
1  actionpack/lib/abstract_controller/base.rb
@@ -89,7 +89,6 @@ def process(action)
end
process_action(action_name)
- self
end
private
View
77 actionpack/lib/abstract_controller/layouts.rb
@@ -6,13 +6,56 @@ module Layouts
included do
extlib_inheritable_accessor(:_layout_conditions) { Hash.new }
+ extlib_inheritable_accessor(:_action_has_layout) { Hash.new }
_write_layout_method
end
module ClassMethods
def inherited(klass)
super
- klass._write_layout_method
+ klass.class_eval do
+ _write_layout_method
+ @found_layouts = {}
+ end
+ end
+
+ def clear_template_caches!
+ @found_layouts.clear if @found_layouts
+ super
+ end
+
+ def cache_layout(details)
+ layout = @found_layouts
+ key = Thread.current[:format_locale_key]
+
+ # Cache nil
+ if layout.key?(key)
+ return layout[key]
+ else
+ layout[key] = yield
+ end
+ end
+
+ # This module is mixed in if layout conditions are provided. This means
+ # that if no layout conditions are used, this method is not used
+ module LayoutConditions
+ # Determines whether the current action has a layout by checking the
+ # action name against the :only and :except conditions set on the
+ # layout.
+ #
+ # ==== Returns
+ # Boolean:: True if the action has a layout, false otherwise.
+ def _action_has_layout?
+ conditions = _layout_conditions
+
+ if only = conditions[:only]
+ only.include?(action_name)
+ elsif except = conditions[:except]
+ !except.include?(action_name)
+ else
+ true
+ end
+ end
end
# Specify the layout to use for this class.
@@ -31,6 +74,8 @@ def inherited(klass)
# :only<#to_s, Array[#to_s]>:: A list of actions to apply this layout to.
# :except<#to_s, Array[#to_s]>:: Apply this layout to all actions but this one
def layout(layout, conditions = {})
+ include LayoutConditions unless conditions.empty?
+
conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} }
self._layout_conditions = conditions
@@ -76,10 +121,12 @@ def _layout(details)
when nil
self.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
def _layout(details)
- if view_paths.exists?("#{_implied_layout_name}", details, "layouts")
- "#{_implied_layout_name}"
- else
- super
+ self.class.cache_layout(details) do
+ if view_paths.exists?("#{_implied_layout_name}", details, "layouts")
+ "#{_implied_layout_name}"
+ else
+ super
+ end
end
end
ruby_eval
@@ -98,6 +145,9 @@ def render_to_body(options = {})
# This is a little bit messy. We need to explicitly handle partial
# layouts here since the core lookup logic is in the view, but
# we need to determine the layout based on the controller
+ #
+ # TODO: An easier way to handle this would probably be to override
+ # render_template
if layout
layout = _layout_for_option(layout, options[:_template].details)
response = layout.render(view_context, options[:locals] || {}) { response }
@@ -136,7 +186,7 @@ def _find_layout(name, details)
view_paths.find(name, details, prefix)
end
- # Returns the default layout for this controller and a given set of details.
+ # Returns the default layout for this controller and a given set of details.
# Optionally raises an exception if the layout could not be found.
#
# ==== Parameters
@@ -162,21 +212,8 @@ def _default_layout(details, require_layout = false)
end
end
- # Determines whether the current action has a layout by checking the
- # action name against the :only and :except conditions set on the
- # layout.
- #
- # ==== Returns
- # Boolean:: True if the action has a layout, false otherwise.
def _action_has_layout?
- conditions = _layout_conditions
- if only = conditions[:only]
- only.include?(action_name)
- elsif except = conditions[:except]
- !except.include?(action_name)
- else
- true
- end
+ true
end
end
end
View
4 actionpack/lib/abstract_controller/logger.rb
@@ -29,7 +29,7 @@ def to_s
# Override process_action in the AbstractController::Base
# to log details about the method.
def process_action(action)
- super
+ retval = super
if logger
log = DelayedLog.new do
@@ -40,6 +40,8 @@ def process_action(action)
logger.info(log)
end
+
+ retval
end
private
View
17 actionpack/lib/abstract_controller/rendering_controller.rb
@@ -111,12 +111,21 @@ def self.body_to_s(body)
def _determine_template(options)
name = (options[:_template_name] || action_name).to_s
- options[:_template] ||= view_paths.find(
- name, { :formats => formats }, options[:_prefix], options[:_partial]
- )
+ options[:_template] ||= with_template_cache(name) do
+ view_paths.find(
+ name, { :formats => formats }, options[:_prefix], options[:_partial]
+ )
+ end
+ end
+
+ def with_template_cache(name)
+ yield
end
module ClassMethods
+ def clear_template_caches!
+ end
+
# Append a path to the list of view paths for this controller.
#
# ==== Parameters
@@ -134,6 +143,7 @@ def append_view_path(path)
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def prepend_view_path(path)
+ clear_template_caches!
self.view_paths.unshift(path)
end
@@ -148,6 +158,7 @@ def view_paths
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
# otherwise, process the parameter into a ViewPathSet.
def view_paths=(paths)
+ clear_template_caches!
self._view_paths = paths.is_a?(ActionView::PathSet) ?
paths : ActionView::Base.process_view_paths(paths)
end
View
6 actionpack/lib/action_controller.rb
@@ -3,6 +3,7 @@ module ActionController
autoload :ConditionalGet, "action_controller/metal/conditional_get"
autoload :HideActions, "action_controller/metal/hide_actions"
autoload :Metal, "action_controller/metal"
+ autoload :Middleware, "action_controller/middleware"
autoload :Layouts, "action_controller/metal/layouts"
autoload :RackConvenience, "action_controller/metal/rack_convenience"
autoload :Rails2Compatibility, "action_controller/metal/compatibility"
@@ -58,9 +59,8 @@ module ActionController
autoload :HTML, 'action_controller/vendor/html-scanner'
autoload :AbstractController, 'abstract_controller'
-autoload :Rack, 'action_dispatch'
-autoload :ActionDispatch, 'action_dispatch'
-autoload :ActionView, 'action_view'
+require 'action_dispatch'
+require 'action_view'
# Common ActiveSupport usage in ActionController
require "active_support/concern"
View
18 actionpack/lib/action_controller/metal.rb
@@ -47,7 +47,7 @@ def controller_path
# and response object available. You might wish to control the
# environment and response manually for performance reasons.
- attr_internal :status, :headers, :content_type
+ attr_internal :status, :headers, :content_type, :app, :response
def initialize(*)
@_headers = {}
@@ -75,7 +75,17 @@ def call(name, env)
# :api: private
def to_a
- [status, headers, response_body]
+ response ? response.to_a : [status, headers, response_body]
+ end
+
+ class ActionEndpoint
+ def initialize(controller, action)
+ @controller, @action = controller, action
+ end
+
+ def call(env)
+ controller = @controller.new.call(@action, env)
+ end
end
# Return a rack endpoint for the given action. Memoize the endpoint, so
@@ -89,9 +99,7 @@ def to_a
# Proc:: A rack application
def self.action(name)
@actions ||= {}
- @actions[name.to_s] ||= proc do |env|
- new.call(name, env)
- end
+ @actions[name.to_s] ||= ActionEndpoint.new(self, name)
end
end
end
View
18 actionpack/lib/action_controller/metal/compatibility.rb
@@ -16,17 +16,12 @@ class ::ActionController::ActionControllerError < StandardError #:nodoc:
cattr_accessor :allow_concurrency
self.allow_concurrency = false
- cattr_accessor :param_parsers
- self.param_parsers = { Mime::MULTIPART_FORM => :multipart_form,
- Mime::URL_ENCODED_FORM => :url_encoded_form,
- Mime::XML => :xml_simple,
- Mime::JSON => :json }
-
cattr_accessor :relative_url_root
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
- cattr_accessor :default_charset
- self.default_charset = "utf-8"
+ class << self
+ delegate :default_charset=, :to => "ActionDispatch::Response"
+ end
# cattr_reader :protected_instance_variables
cattr_accessor :protected_instance_variables
@@ -101,11 +96,10 @@ def render_to_body(options)
options[:template].sub!(/^\//, '')
end
- options[:text] = nil if options[:nothing] == true
+ options[:text] = nil if options.delete(:nothing) == true
+ options[:text] = " " if options.key?(:text) && options[:text].nil?
- body = super
- body = [' '] if body.blank?
- body
+ super || " "
end
def _handle_method_missing
View
14 actionpack/lib/action_controller/metal/hide_actions.rb
@@ -13,7 +13,9 @@ module HideActions
# Overrides AbstractController::Base#action_method? to return false if the
# action name is in the list of hidden actions.
def action_method?(action_name)
- !hidden_actions.include?(action_name) && super
+ self.class.visible_action?(action_name) do
+ !hidden_actions.include?(action_name) && super
+ end
end
module ClassMethods
@@ -25,6 +27,16 @@ def hide_action(*args)
hidden_actions.merge(args.map! {|a| a.to_s })
end
+ def inherited(klass)
+ klass.instance_variable_set("@visible_actions", {})
+ super
+ end
+
+ def visible_action?(action_name)
+ return @visible_actions[action_name] if @visible_actions.key?(action_name)
+ @visible_actions[action_name] = yield
+ end
+
# Overrides AbstractController::Base#action_methods to remove any methods
# that are listed as hidden methods.
def action_methods
View
20 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -115,7 +115,7 @@ def authenticate_or_request_with_http_basic(realm = "Application", &login_proced
end
def authenticate_with_http_basic(&login_procedure)
- HttpAuthentication::Basic.authenticate(self, &login_procedure)
+ HttpAuthentication::Basic.authenticate(request, &login_procedure)
end
def request_http_basic_authentication(realm = "Application")
@@ -123,9 +123,9 @@ def request_http_basic_authentication(realm = "Application")
end
end
- def authenticate(controller, &login_procedure)
- unless authorization(controller.request).blank?
- login_procedure.call(*user_name_and_password(controller.request))
+ def authenticate(request, &login_procedure)
+ unless authorization(request).blank?
+ login_procedure.call(*user_name_and_password(request))
end
end
@@ -150,7 +150,8 @@ def encode_credentials(user_name, password)
def authentication_request(controller, realm)
controller.headers["WWW-Authenticate"] = %(Basic realm="#{realm.gsub(/"/, "")}")
- controller.__send__ :render, :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
+ controller.response_body = "HTTP Basic: Access denied.\n"
+ controller.status = 401
end
end
@@ -164,7 +165,7 @@ def authenticate_or_request_with_http_digest(realm = "Application", &password_pr
# Authenticate with HTTP Digest, returns true or false
def authenticate_with_http_digest(realm = "Application", &password_procedure)
- HttpAuthentication::Digest.authenticate(self, realm, &password_procedure)
+ HttpAuthentication::Digest.authenticate(request, realm, &password_procedure)
end
# Render output including the HTTP Digest authentication header
@@ -174,8 +175,8 @@ def request_http_digest_authentication(realm = "Application", message = nil)
end
# Returns false on a valid response, true otherwise
- def authenticate(controller, realm, &password_procedure)
- authorization(controller.request) && validate_digest_response(controller.request, realm, &password_procedure)
+ def authenticate(request, realm, &password_procedure)
+ authorization(request) && validate_digest_response(request, realm, &password_procedure)
end
def authorization(request)
@@ -243,7 +244,8 @@ def authentication_header(controller, realm)
def authentication_request(controller, realm, message = nil)
message ||= "HTTP Digest: Access denied.\n"
authentication_header(controller, realm)
- controller.__send__ :render, :text => message, :status => :unauthorized
+ controller.response_body = message
+ controller.status = 401
end
# Uses an MD5 digest based on time to generate a value to be used only once.
View
52 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -179,21 +179,8 @@ def clear_respond_to
def respond_to(*mimes, &block)
raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?
- collector = Collector.new
- mimes = collect_mimes_from_class_level if mimes.empty?
- mimes.each { |mime| collector.send(mime) }
- block.call(collector) if block_given?
-
- if format = request.negotiate_mime(collector.order)
- self.formats = [format.to_sym]
-
- if response = collector.response_for(format)
- response.call
- else
- default_render
- end
- else
- head :not_acceptable
+ if response = retrieve_response_from_mimes(mimes, &block)
+ response.call
end
end
@@ -226,10 +213,12 @@ def respond_to(*mimes, &block)
# is quite simple (it just needs to respond to call), you can even give
# a proc to it.
#
- def respond_with(resource, options={}, &block)
- respond_to(&block)
- rescue ActionView::MissingTemplate
- (options.delete(:responder) || responder).call(self, resource, options)
+ def respond_with(*resources, &block)
+ if response = retrieve_response_from_mimes([], &block)
+ options = resources.extract_options!
+ options.merge!(:default_response => response)
+ (options.delete(:responder) || responder).call(self, resources, options)
+ end
end
def responder
@@ -257,11 +246,29 @@ def collect_mimes_from_class_level #:nodoc:
end
end
+ # Collects mimes and return the response for the negotiated format. Returns
+ # nil if :not_acceptable was sent to the client.
+ #
+ def retrieve_response_from_mimes(mimes, &block)
+ collector = Collector.new { default_render }
+ mimes = collect_mimes_from_class_level if mimes.empty?
+ mimes.each { |mime| collector.send(mime) }
+ block.call(collector) if block_given?
+
+ if format = request.negotiate_mime(collector.order)
+ self.formats = [format.to_sym]
+ collector.response_for(format)
+ else
+ head :not_acceptable
+ nil
+ end
+ end
+
class Collector #:nodoc:
attr_accessor :order
- def initialize
- @order, @responses = [], {}
+ def initialize(&block)
+ @order, @responses, @default_response = [], {}, block
end
def any(*args, &block)
@@ -275,13 +282,12 @@ def any(*args, &block)
def custom(mime_type, &block)
mime_type = mime_type.is_a?(Mime::Type) ? mime_type : Mime::Type.lookup(mime_type.to_s)
-
@order << mime_type
@responses[mime_type] ||= block
end
def response_for(mime)
- @responses[mime] || @responses[Mime::ALL]
+ @responses[mime] || @responses[Mime::ALL] || @default_response
end
def self.generate_method_for_mime(mime)
View
8 actionpack/lib/action_controller/metal/rack_convenience.rb
@@ -5,7 +5,7 @@ module RackConvenience
included do
delegate :headers, :status=, :location=, :content_type=,
:status, :location, :content_type, :to => "@_response"
- attr_internal :request, :response
+ attr_internal :request
end
def call(name, env)
@@ -19,12 +19,6 @@ def params
@_params ||= @_request.parameters
end
- # :api: private
- def to_a
- @_response.prepare!
- @_response.to_a
- end
-
def response_body=(body)
response.body = body if response
super
View
3  actionpack/lib/action_controller/metal/redirector.rb
@@ -8,6 +8,9 @@ def initialize(message = nil)
end
module Redirector
+ extend ActiveSupport::Concern
+ include AbstractController::Logger
+
def redirect_to(url, status) #:doc:
raise AbstractController::DoubleRenderError if response_body
logger.info("Redirected to #{url}") if logger && logger.info?
View
48 actionpack/lib/action_controller/metal/rendering_controller.rb
@@ -1,20 +1,56 @@
module ActionController
+ class HashKey
+ @hash_keys = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = {} } }
+
+ def self.get(klass, formats, locale)
+ @hash_keys[klass][formats][locale] ||= new(klass, formats, locale)
+ end
+
+ attr_accessor :hash
+ def initialize(klass, formats, locale)
+ @formats, @locale = formats, locale
+ @hash = [formats, locale].hash
+ end
+
+ alias_method :eql?, :equal?
+
+ def inspect
+ "#<HashKey -- formats: #{@formats} locale: #{@locale}>"
+ end
+ end
+
module RenderingController
extend ActiveSupport::Concern
include AbstractController::RenderingController
+ module ClassMethods
+ def clear_template_caches!
+ ActionView::Partials::PartialRenderer::TEMPLATES.clear
+ template_cache.clear
+ super
+ end
+
+ def template_cache
+ @template_cache ||= Hash.new {|h,k| h[k] = {} }
+ end
+ end
+
def process_action(*)
self.formats = request.formats.map {|x| x.to_sym}
+
+ super
+ end
+
+ def _determine_template(*)
super
end
def render(options)
+ Thread.current[:format_locale_key] = HashKey.get(self.class, formats, I18n.locale)
+
super
- self.content_type ||= begin
- mime = options[:_template].mime_type
- formats.include?(mime && mime.to_sym) || formats.include?(:all) ? mime : Mime::Type.lookup_by_extension(formats.first)
- end.to_s
+ self.content_type ||= options[:_template].mime_type.to_s
response_body
end
@@ -34,6 +70,10 @@ def _prefix
controller_path
end
+ def with_template_cache(name)
+ self.class.template_cache[Thread.current[:format_locale_key]][name] ||= super
+ end
+
def _determine_template(options)
if options.key?(:text)
options[:_template] = ActionView::TextTemplate.new(options[:text], formats.first)
View
43 actionpack/lib/action_controller/metal/responder.rb
@@ -64,7 +64,7 @@ module ActionController #:nodoc:
# @project = Project.find(params[:project_id])
# @task = @project.comments.build(params[:task])
# flash[:notice] = 'Task was successfully created.' if @task.save
- # respond_with([@project, @task])
+ # respond_with(@project, @task)
# end
#
# Giving an array of resources, you ensure that the responder will redirect to
@@ -74,20 +74,21 @@ module ActionController #:nodoc:
# polymorphic urls. If a project has one manager which has many tasks, it
# should be invoked as:
#
- # respond_with([@project, :manager, @task])
+ # respond_with(@project, :manager, @task)
#
# Check polymorphic_url documentation for more examples.
#
class Responder
- attr_reader :controller, :request, :format, :resource, :resource_location, :options
+ attr_reader :controller, :request, :format, :resource, :resources, :options
- def initialize(controller, resource, options={})
+ def initialize(controller, resources, options={})
@controller = controller
@request = controller.request
@format = controller.formats.first
- @resource = resource.is_a?(Array) ? resource.last : resource
- @resource_location = options[:location] || resource
+ @resource = resources.is_a?(Array) ? resources.last : resources
+ @resources = resources
@options = options
+ @default_response = options.delete(:default_response)
end
delegate :head, :render, :redirect_to, :to => :controller
@@ -109,8 +110,10 @@ def self.call(*args)
# template.
#
def to_html
+ default_render
+ rescue ActionView::MissingTemplate
if get?
- render
+ raise
elsif has_errors?
render :action => default_action
else
@@ -118,12 +121,14 @@ def to_html
end
end
- # All others formats try to render the resource given instead. For this
- # purpose a helper called display as a shortcut to render a resource with
- # the current format.
+ # All others formats follow the procedure below. First we try to render a
+ # template, if the template is not available, we verify if the resource
+ # responds to :to_format and display it.
#
def to_format
- return render unless resourceful?
+ default_render
+ rescue ActionView::MissingTemplate
+ raise unless resourceful?
if get?
display resource
@@ -144,6 +149,20 @@ def resourceful?
resource.respond_to?(:"to_#{format}")
end
+ # Returns the resource location by retrieving it from the options or
+ # returning the resources array.
+ #
+ def resource_location
+ options[:location] || resources
+ end
+
+ # If a given response block was given, use it, otherwise call render on
+ # controller.
+ #
+ def default_render
+ @default_response.call
+ end
+
# display is just a shortcut to render a resource with the current format.
#
# display @user, :status => :ok
@@ -162,7 +181,7 @@ def resourceful?
# render :xml => @user, :status => :created
#
def display(resource, given_options={})
- render given_options.merge!(options).merge!(format => resource)
+ controller.render given_options.merge!(options).merge!(format => resource)
end
# Check if the resource has errors or not.
View
3  actionpack/lib/action_controller/metal/streaming.rb
@@ -145,7 +145,6 @@ def send_file(path, options = {}) #:doc:
def send_data(data, options = {}) #:doc:
logger.info "Sending data #{options[:filename]}" if logger
send_file_headers! options.merge(:length => data.bytesize)
- @performed_render = false
render :status => options[:status], :text => data
end
@@ -175,6 +174,8 @@ def send_file_headers!(options)
'Content-Transfer-Encoding' => 'binary'
)
+ response.sending_file = true
+
# Fix a problem with IE 6.0 on opening downloaded files:
# If Cache-Control: no-cache is set (which Rails does by default),
# IE removes the file it just downloaded from its cache immediately
View
10 actionpack/lib/action_controller/metal/url_for.rb
@@ -4,15 +4,6 @@ module UrlFor
include RackConvenience
- def process_action(*)
- initialize_current_url
- super
- end
-
- def initialize_current_url
- @url = UrlRewriter.new(request, params.clone)
- end
-
# Overwrite to implement a number of default options that all url_for-based methods will use. The default options should come in
# the form of a hash, just like the one you would use for url_for directly. Example:
#
@@ -40,6 +31,7 @@ def url_for(options = {})
when String
options
when Hash
+ @url ||= UrlRewriter.new(request, params)
@url.rewrite(rewrite_options(options))
else
polymorphic_url(options)
View
38 actionpack/lib/action_controller/middleware.rb
@@ -0,0 +1,38 @@
+module ActionController
+ class Middleware < Metal
+ class ActionMiddleware
+ def initialize(controller)
+ @controller = controller
+ end
+
+ def call(env)
+ controller = @controller.allocate
+ controller.send(:initialize)
+ controller.app = @app
+ controller._call(env)
+ end
+
+ def app=(app)
+ @app = app
+ end
+ end
+
+ def self.new(app)
+ middleware = ActionMiddleware.new(self)
+ middleware.app = app
+ middleware
+ end
+
+ def _call(env)
+ @_env = env
+ @_request = ActionDispatch::Request.new(env)
+ @_response = ActionDispatch::Response.new
+ @_response.request = @_request
+ process(:index)
+ end
+
+ def index
+ call(env)
+ end
+ end
+end
View
2  actionpack/lib/action_controller/routing/generation/url_rewriter.rb
@@ -172,7 +172,7 @@ def rewrite_url(options)
path = rewrite_path(options)
rewritten_url << ActionController::Base.relative_url_root.to_s unless options[:skip_relative_url_root]
rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
- rewritten_url << "##{options[:anchor]}" if options[:anchor]
+ rewritten_url << "##{CGI.escape(options[:anchor].to_param.to_s)}" if options[:anchor]
rewritten_url
end
View
30 actionpack/lib/action_controller/routing/resources.rb
@@ -320,9 +320,10 @@ def initialize(entity, options)
# notes.resources :attachments
# end
#
- # * <tt>:path_names</tt> - Specify different names for the 'new' and 'edit' actions. For example:
+ # * <tt>:path_names</tt> - Specify different path names for the actions. For example:
# # new_products_path == '/productos/nuevo'
- # map.resources :products, :as => 'productos', :path_names => { :new => 'nuevo', :edit => 'editar' }
+ # # bids_product_path(1) == '/productos/1/licitacoes'
+ # map.resources :products, :as => 'productos', :member => { :bids => :get }, :path_names => { :new => 'nuevo', :bids => 'licitacoes' }
#
# You can also set default action names from an environment, like this:
# config.action_controller.resources_path_names = { :new => 'nuevo', :edit => 'editar' }
@@ -528,16 +529,16 @@ def map_resource(entities, options = {}, &block)
resource = Resource.new(entities, options)
with_options :controller => resource.controller do |map|
- map_collection_actions(map, resource)
- map_default_collection_actions(map, resource)
- map_new_actions(map, resource)
- map_member_actions(map, resource)
-
map_associations(resource, options)
if block_given?
with_options(options.slice(*INHERITABLE_OPTIONS).merge(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix), &block)
end
+
+ map_collection_actions(map, resource)
+ map_default_collection_actions(map, resource)
+ map_new_actions(map, resource)
+ map_member_actions(map, resource)
end
end
@@ -545,16 +546,16 @@ def map_singleton_resource(entities, options = {}, &block)
resource = SingletonResource.new(entities, options)
with_options :controller => resource.controller do |map|
- map_collection_actions(map, resource)
- map_new_actions(map, resource)
- map_member_actions(map, resource)
- map_default_singleton_actions(map, resource)
-
map_associations(resource, options)
if block_given?
with_options(options.slice(*INHERITABLE_OPTIONS).merge(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix), &block)
end
+
+ map_collection_actions(map, resource)
+ map_new_actions(map, resource)
+ map_member_actions(map, resource)
+ map_default_singleton_actions(map, resource)
end
end
@@ -589,7 +590,10 @@ def map_collection_actions(map, resource)
resource.collection_methods.each do |method, actions|
actions.each do |action|
[method].flatten.each do |m|
- map_resource_routes(map, resource, action, "#{resource.path}#{resource.action_separator}#{action}", "#{action}_#{resource.name_prefix}#{resource.plural}", m)
+ action_path = resource.options[:path_names][action] if resource.options[:path_names].is_a?(Hash)
+ action_path ||= action
+
+ map_resource_routes(map, resource, action, "#{resource.path}#{resource.action_separator}#{action_path}", "#{action}_#{resource.name_prefix}#{resource.plural}", m)
end
end
end
View
25 actionpack/lib/action_controller/routing/route_set.rb
@@ -213,7 +213,7 @@ def initialize
self.routes = []
self.named_routes = NamedRouteCollection.new
- clear_recognize_optimized!
+ clear!
end
# Subclasses and plugins may override this method to specify a different
@@ -223,6 +223,7 @@ def builder
end
def draw
+ clear!
yield Mapper.new(self)
install_helpers
end
@@ -230,8 +231,10 @@ def draw
def clear!
routes.clear
named_routes.clear
+
@combined_regexp = nil
@routes_by_controller = nil
+
# This will force routing/recognition_optimization.rb
# to refresh optimisations.
clear_recognize_optimized!
@@ -262,7 +265,6 @@ def configuration_file
def load!
Routing.use_controllers!(nil) # Clear the controller cache so we may discover new ones
- clear!
load_routes!
end
@@ -286,10 +288,12 @@ def load_routes!
configuration_files.each { |config| load(config) }
@routes_last_modified = routes_changed_at
else
- add_route ":controller/:action/:id"
+ draw do |map|
+ map.connect ":controller/:action/:id"
+ end
end
end
-
+
def routes_changed_at
routes_changed_at = nil
@@ -407,9 +411,11 @@ def generate(options, recall = {}, method=:generate)
# don't use the recalled keys when determining which routes to check
routes = routes_by_controller[controller][action][options.reject {|k,v| !v}.keys.sort_by { |x| x.object_id }]
- routes.each do |route|
+ routes.each_with_index do |route, index|
results = route.__send__(method, options, merged, expire_on)
- return results if results && (!results.is_a?(Array) || results.first)
+ if results && (!results.is_a?(Array) || results.first)
+ return results
+ end
end
end
@@ -460,16 +466,13 @@ def routes_for(options, merged, expire_on)
merged = options if expire_on[:controller]
action = merged[:action] || 'index'
- routes_by_controller[controller][action][merged.keys]
+ routes_by_controller[controller][action][merged.keys][1]
end
def routes_for_controller_and_action_and_keys(controller, action, keys)
- selected = routes.select do |route|
+ routes.select do |route|
route.matches_controller_and_action? controller, action
end
- selected.sort_by do |route|
- (keys - route.significant_keys).length
- end
end
# Subclasses and plugins may override this method to extract further attributes
View
3  actionpack/lib/action_controller/testing/integration.rb
@@ -267,7 +267,8 @@ def process(method, path, parameters = nil, rack_environment = nil)
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
"HTTP_ACCEPT" => accept
}
- env = Rack::MockRequest.env_for(path, opts)
+
+ env = ActionDispatch::TestRequest.env_for(path, opts)
(rack_environment || {}).each do |key, value|
env[key] = value
View
10 actionpack/lib/action_controller/testing/process.rb
@@ -52,7 +52,7 @@ def recycle!
class TestResponse < ActionDispatch::TestResponse
def recycle!
@status = 200
- @header = Rack::Utils::HeaderHash.new
+ @header = {}
@writer = lambda { |x| @body << x }
@block = nil
@length = 0
@@ -84,7 +84,7 @@ def initialize(session = {})
#
# Pass a true third parameter to ensure the uploaded file is opened in binary mode (only required for Windows):
# post :change_avatar, :avatar => ActionController::TestUploadedFile.new(ActionController::TestCase.fixture_path + '/files/spongebob.png', 'image/png', :binary)
- TestUploadedFile = Rack::Utils::Multipart::UploadedFile
+ TestUploadedFile = ActionDispatch::TestRequest::Multipart::UploadedFile
module TestProcess
def self.included(base)
@@ -148,7 +148,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil)
@request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
- @request.env['HTTP_ACCEPT'] = [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
+ @request.env['HTTP_ACCEPT'] ||= [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ')
returning __send__(request_method, action, parameters, session, flash) do
@request.env.delete 'HTTP_X_REQUESTED_WITH'
@request.env.delete 'HTTP_ACCEPT'
@@ -249,6 +249,7 @@ def with_routing
temporary_routes = ActionController::Routing::RouteSet.new
ActionController::Routing.module_eval { const_set :Routes, temporary_routes }
+ ActionController::Dispatcher.router = temporary_routes
yield temporary_routes
ensure
@@ -256,6 +257,7 @@ def with_routing
ActionController::Routing.module_eval { remove_const :Routes }
end
ActionController::Routing.const_set(:Routes, real_routes) if real_routes
+ ActionController::Dispatcher.router = ActionController::Routing::Routes
end
end
-end
+end
View
1  actionpack/lib/action_controller/testing/test_case.rb
@@ -179,7 +179,6 @@ def setup_controller_request_and_response
if @controller
@controller.request = @request
@controller.params = {}
- @controller.send(:initialize_current_url)
end
end
View
10 actionpack/lib/action_dispatch.rb
@@ -25,15 +25,11 @@
$:.unshift activesupport_path if File.directory?(activesupport_path)
require 'active_support'
-begin
- gem 'rack', '~> 1.1.pre'
-rescue Gem::LoadError, ArgumentError
- $:.unshift "#{File.dirname(__FILE__)}/action_dispatch/vendor/rack-1.1.pre"
-end
-
require 'rack'
-$:.unshift "#{File.dirname(__FILE__)}/action_dispatch/vendor/rack-test"
+module Rack
+ autoload :Test, 'rack/test'
+end
module ActionDispatch
autoload :Request, 'action_dispatch/http/request'
View
56 actionpack/lib/action_dispatch/http/request.rb
@@ -106,16 +106,10 @@ def accepts
@env["action_dispatch.request.accepts"] ||= begin
header = @env['HTTP_ACCEPT'].to_s.strip
- fallback = xhr? ? Mime::JS : Mime::HTML
-
if header.empty?
- [content_type, fallback, Mime::ALL].compact
+ [content_type]
else
- ret = Mime::Type.parse(header)
- if ret.last == Mime::ALL
- ret.insert(-2, fallback)
- end
- ret
+ Mime::Type.parse(header)
end
end
end
@@ -163,30 +157,20 @@ def fresh?(response)
# GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first depending on the value of <tt>ActionController::Base.use_accept_header</tt>
#
def format(view_path = [])
- @env["action_dispatch.request.format"] ||=
- if parameters[:format]
- Mime[parameters[:format]]
- elsif ActionController::Base.use_accept_header && !(accepts == ONLY_ALL)
- accepts.first
- elsif xhr? then Mime::JS
- else Mime::HTML
- end
+ formats.first
end
- # Expand raw_formats by converting Mime::ALL to the Mime::SET.
- #
def formats
- if ActionController::Base.use_accept_header
- raw_formats.tap do |ret|
- if ret == ONLY_ALL
- ret.replace Mime::SET
- elsif all = ret.index(Mime::ALL)
- ret.delete_at(all) && ret.insert(all, *Mime::SET)
- end
+ accept = @env['HTTP_ACCEPT']
+
+ @env["action_dispatch.request.formats"] ||=
+ if parameters[:format]
+ [Mime[parameters[:format]]]
+ elsif xhr? || (accept && !accept.include?(?,))
+ accepts
+ else
+ [Mime::HTML]
end
- else
- raw_formats + Mime::SET
- end
end
# Sets the \format by string extension, which can be used to force custom formats
@@ -202,7 +186,7 @@ def formats
# end
def format=(extension)
parameters[:format] = extension.to_s
- @env["action_dispatch.request.format"] = Mime::Type.lookup_by_extension(parameters[:format])
+ @env["action_dispatch.request.formats"] = [Mime::Type.lookup_by_extension(parameters[:format])]
end
# Returns a symbolized version of the <tt>:format</tt> parameter of the request.
@@ -487,7 +471,7 @@ def flash
# matches the order array.
#
def negotiate_mime(order)
- raw_formats.each do |priority|
+ formats.each do |priority|
if priority == Mime::ALL
return order.first
elsif order.include?(priority)
@@ -500,18 +484,6 @@ def negotiate_mime(order)
private
- def raw_formats
- if ActionController::Base.use_accept_header
- if param = parameters[:format]
- Array.wrap(Mime[param])
- else
- accepts.dup
- end
- else
- [format]
- end
- end
-
def named_host?(host)
!(host.nil? || /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host))
end
View
145 actionpack/lib/action_dispatch/http/response.rb
@@ -32,18 +32,35 @@ module ActionDispatch # :nodoc:
# end
# end
class Response < Rack::Response
- attr_accessor :request
+ attr_accessor :request, :blank
attr_reader :cache_control
- attr_writer :header
+ attr_writer :header, :sending_file
alias_method :headers=, :header=
- delegate :default_charset, :to => 'ActionController::Base'
-
def initialize
- super
+ @status = 200
+ @header = {}
@cache_control = {}
- @header = Rack::Utils::HeaderHash.new
+
+ @writer = lambda { |x| @body << x }
+ @block = nil
+ @length = 0
+
+ @body, @cookie = [], []
+ @sending_file = false
+
+ yield self if block_given?
+ end
+
+ def cache_control
+ @cache_control ||= {}
+ end
+
+ def write(str)
+ s = str.to_s
+ @writer.call s
+ str
end
def status=(status)
@@ -71,7 +88,10 @@ def body
str
end
+ EMPTY = " "
+
def body=(body)
+ @blank = true if body == EMPTY
@body = body.respond_to?(:to_str) ? [body] : body
end
@@ -113,43 +133,44 @@ def last_modified=(utc_time)
end
def etag
- headers['ETag']
+ @etag
end
def etag?
- headers.include?('ETag')
+ @etag
end
def etag=(etag)
- if etag.blank?
- headers.delete('ETag')
- else
- headers['ETag'] = %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key(etag))}")
- end
+ key = ActiveSupport::Cache.expand_cache_key(etag)
+ @etag = %("#{Digest::MD5.hexdigest(key)}")
end
- def sending_file?
- headers["Content-Transfer-Encoding"] == "binary"
- end
+ CONTENT_TYPE = "Content-Type"
+
+ cattr_accessor(:default_charset) { "utf-8" }
def assign_default_content_type_and_charset!
- return if !headers["Content-Type"].blank?
+ return if headers[CONTENT_TYPE].present?
@content_type ||= Mime::HTML
- @charset ||= default_charset
+ @charset ||= self.class.default_charset
type = @content_type.to_s.dup
- type << "; charset=#{@charset}" unless sending_file?
+ type << "; charset=#{@charset}" unless @sending_file
- headers["Content-Type"] = type
+ headers[CONTENT_TYPE] = type
end
- def prepare!
+ def to_a
assign_default_content_type_and_charset!
handle_conditional_get!
- self["Set-Cookie"] ||= ""
+ self["Set-Cookie"] = @cookie.join("\n")
+ self["ETag"] = @etag if @etag
+ super
end
+ alias prepare! to_a
+
def each(&callback)
if @body.respond_to?(:call)
@writer = lambda { |x| callback.call(x) }
@@ -168,23 +189,12 @@ def write(str)
str
end
- def set_cookie(key, value)
- if value.has_key?(:http_only)
- ActiveSupport::Deprecation.warn(
- "The :http_only option in ActionController::Response#set_cookie " +
- "has been renamed. Please use :httponly instead.", caller)
- value[:httponly] ||= value.delete(:http_only)
- end
-
- super(key, value)
- end
-
# Returns the response cookies, converted to a Hash of (name => value) pairs
#
# assert_equal 'AuthorOfNewPage', r.cookies['author']
def cookies
cookies = {}
- if header = headers['Set-Cookie']
+ if header = @cookie
header = header.split("\n") if header.respond_to?(:to_str)
header.each do |cookie|
if pair = cookie.split(';').first
@@ -196,12 +206,43 @@ def cookies
cookies
end
+ def set_cookie(key, value)