Permalink
Browse files

Merge branch 'master' of github.com:rails/rails into count_behavior

  • Loading branch information...
jmileham committed Mar 24, 2011
2 parents d5994ee + 5214e73 commit b44a0ec153c84384e9b97a069e81f28bc5c2a4bf
Showing with 3,155 additions and 1,009 deletions.
  1. +3 −0 Gemfile
  2. +1 −0 Rakefile
  3. +6 −5 actionmailer/README.rdoc
  4. +1 −1 actionmailer/lib/action_mailer/base.rb
  5. +10 −3 actionmailer/lib/action_mailer/mail_helper.rb
  6. +4 −1 actionmailer/lib/rails/generators/mailer/USAGE
  7. +2 −2 actionmailer/test/base_test.rb
  8. +13 −0 actionmailer/test/mail_helper_test.rb
  9. +6 −0 actionpack/CHANGELOG
  10. +1 −1 actionpack/README.rdoc
  11. +1 −1 actionpack/lib/abstract_controller/callbacks.rb
  12. +4 −4 actionpack/lib/abstract_controller/view_paths.rb
  13. +1 −1 actionpack/lib/action_controller/caching/actions.rb
  14. +1 −1 actionpack/lib/action_controller/metal/instrumentation.rb
  15. +10 −1 actionpack/lib/action_controller/test_case.rb
  16. +17 −4 actionpack/lib/action_dispatch/http/filter_parameters.rb
  17. +1 −1 actionpack/lib/action_dispatch/http/url.rb
  18. +20 −21 actionpack/lib/action_dispatch/routing/mapper.rb
  19. +16 −10 actionpack/lib/action_dispatch/routing/route.rb
  20. +3 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  21. +1 −1 actionpack/lib/action_dispatch/testing/test_process.rb
  22. +6 −1 actionpack/lib/action_dispatch/testing/test_request.rb
  23. +2 −2 actionpack/lib/action_view/helpers/date_helper.rb
  24. +26 −5 actionpack/lib/action_view/helpers/form_helper.rb
  25. +1 −1 actionpack/lib/action_view/helpers/form_tag_helper.rb
  26. +4 −4 actionpack/lib/action_view/helpers/number_helper.rb
  27. +1 −2 actionpack/lib/action_view/helpers/prototype_helper.rb
  28. +1 −1 actionpack/lib/action_view/helpers/translation_helper.rb
  29. +1 −1 actionpack/lib/action_view/locale/en.yml
  30. +1 −1 actionpack/lib/action_view/template/handlers/erb.rb
  31. +87 −20 actionpack/lib/action_view/template/resolver.rb
  32. +1 −0 actionpack/lib/action_view/test_case.rb
  33. +6 −6 actionpack/lib/action_view/testing/resolvers.rb
  34. +58 −0 actionpack/test/action_dispatch/routing/mapper_test.rb
  35. +27 −0 actionpack/test/controller/filters_test.rb
  36. +1 −1 actionpack/test/controller/routing_test.rb
  37. +8 −0 actionpack/test/controller/url_for_test.rb
  38. +65 −0 actionpack/test/dispatch/cookies_test.rb
  39. +38 −0 actionpack/test/dispatch/request_test.rb
  40. +32 −0 actionpack/test/dispatch/routing_test.rb
  41. +2 −2 actionpack/test/dispatch/test_request_test.rb
  42. +1 −0 actionpack/test/fixtures/custom_pattern/another.html.erb
  43. +1 −0 actionpack/test/fixtures/custom_pattern/html/another.erb
  44. +1 −0 actionpack/test/fixtures/custom_pattern/html/path.erb
  45. +1 −0 actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb
  46. +1 −0 actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb
  47. +135 −0 actionpack/test/template/form_helper_test.rb
  48. +19 −0 actionpack/test/template/form_options_helper_test.rb
  49. +4 −2 actionpack/test/template/number_helper_test.rb
  50. +2 −2 actionpack/test/template/render_test.rb
  51. +31 −0 actionpack/test/template/resolver_patterns_test.rb
  52. +1 −1 activemodel/README.rdoc
  53. +8 −5 activemodel/lib/active_model/attribute_methods.rb
  54. +0 −2 activemodel/lib/active_model/conversion.rb
  55. +2 −2 activemodel/lib/active_model/lint.rb
  56. +1 −3 activemodel/lib/active_model/mass_assignment_security.rb
  57. +1 −1 activemodel/lib/active_model/observing.rb
  58. +3 −3 activemodel/lib/active_model/validations.rb
  59. +2 −1 activemodel/lib/active_model/validations/length.rb
  60. +2 −2 activemodel/lib/active_model/validations/with.rb
  61. +14 −17 activemodel/lib/active_model/validator.rb
  62. +56 −3 activemodel/test/cases/attribute_methods_test.rb
  63. +11 −0 activemodel/test/cases/validations/length_validation_test.rb
  64. +1 −1 activemodel/test/cases/validations/numericality_validation_test.rb
  65. +9 −0 activerecord/CHANGELOG
  66. +1 −1 activerecord/README.rdoc
  67. +61 −17 activerecord/lib/active_record/associations.rb
  68. +85 −0 activerecord/lib/active_record/associations/alias_tracker.rb
  69. +10 −42 activerecord/lib/active_record/associations/association.rb
  70. +120 −0 activerecord/lib/active_record/associations/association_scope.rb
  71. +12 −12 activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
  72. +0 −13 activerecord/lib/active_record/associations/collection_association.rb
  73. +0 −22 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  74. +0 −2 activerecord/lib/active_record/associations/has_many_association.rb
  75. +6 −0 activerecord/lib/active_record/associations/has_many_through_association.rb
  76. +0 −6 activerecord/lib/active_record/associations/has_one_association.rb
  77. +2 −0 activerecord/lib/active_record/associations/has_one_through_association.rb
  78. +8 −24 activerecord/lib/active_record/associations/join_dependency.rb
  79. +66 −201 activerecord/lib/active_record/associations/join_dependency/join_association.rb
  80. +56 −0 activerecord/lib/active_record/associations/join_helper.rb
  81. +4 −2 activerecord/lib/active_record/associations/preloader/has_and_belongs_to_many.rb
  82. +3 −2 activerecord/lib/active_record/associations/preloader/through_association.rb
  83. +1 −1 activerecord/lib/active_record/associations/singular_association.rb
  84. +16 −94 activerecord/lib/active_record/associations/through_association.rb
  85. +8 −1 activerecord/lib/active_record/attribute_methods/read.rb
  86. +5 −4 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  87. +7 −1 activerecord/lib/active_record/attribute_methods/write.rb
  88. +1 −1 activerecord/lib/active_record/autosave_association.rb
  89. +6 −6 activerecord/lib/active_record/base.rb
  90. +1 −1 activerecord/lib/active_record/callbacks.rb
  91. +10 −0 activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
  92. +4 −1 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  93. +2 −3 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  94. +16 −2 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  95. +4 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  96. +8 −0 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  97. +4 −0 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  98. +1 −1 activerecord/lib/active_record/locking/optimistic.rb
  99. +3 −3 activerecord/lib/active_record/locking/pessimistic.rb
  100. +1 −9 activerecord/lib/active_record/persistence.rb
  101. +101 −17 activerecord/lib/active_record/reflection.rb
  102. +30 −5 activerecord/lib/active_record/relation.rb
  103. +10 −0 activerecord/lib/active_record/relation/finder_methods.rb
  104. +2 −2 activerecord/lib/active_record/relation/predicate_builder.rb
  105. +1 −1 activerecord/lib/active_record/relation/query_methods.rb
  106. +6 −0 activerecord/lib/active_record/relation/spawn_methods.rb
  107. +11 −4 activerecord/lib/active_record/validations/uniqueness.rb
  108. +36 −0 activerecord/test/cases/adapters/mysql/schema_test.rb
  109. +19 −0 activerecord/test/cases/adapters/sqlite/sqlite_adapter_test.rb
  110. +15 −15 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  111. +22 −6 activerecord/test/cases/associations/eager_test.rb
  112. +3 −3 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  113. +25 −5 activerecord/test/cases/associations/has_many_through_associations_test.rb
  114. +23 −1 activerecord/test/cases/associations/has_one_through_associations_test.rb
  115. +3 −10 activerecord/test/cases/associations/join_model_test.rb
  116. +546 −0 activerecord/test/cases/associations/nested_through_associations_test.rb
  117. +11 −15 activerecord/test/cases/attribute_methods_test.rb
  118. +14 −2 activerecord/test/cases/base_test.rb
  119. +1 −1 activerecord/test/cases/batches_test.rb
  120. +28 −2 activerecord/test/cases/finder_test.rb
  121. +34 −0 activerecord/test/cases/habtm_destroy_order_test.rb
  122. +11 −11 activerecord/test/cases/identity_map_test.rb
  123. +6 −2 activerecord/test/cases/json_serialization_test.rb
  124. +2 −2 activerecord/test/cases/migration_test.rb
  125. +5 −0 activerecord/test/cases/pooled_connections_test.rb
  126. +54 −3 activerecord/test/cases/reflection_test.rb
  127. +1 −1 activerecord/test/cases/relation_scoping_test.rb
  128. +69 −20 activerecord/test/cases/relations_test.rb
  129. +6 −0 activerecord/test/fixtures/authors.yml
  130. +2 −0 activerecord/test/fixtures/books.yml
  131. +5 −0 activerecord/test/fixtures/categories.yml
  132. +8 −0 activerecord/test/fixtures/categories_posts.yml
  133. +6 −0 activerecord/test/fixtures/categorizations.yml
  134. +3 −1 activerecord/test/fixtures/clubs.yml
  135. +6 −0 activerecord/test/fixtures/essays.yml
  136. +8 −0 activerecord/test/fixtures/member_details.yml
  137. +3 −0 activerecord/test/fixtures/members.yml
  138. +7 −0 activerecord/test/fixtures/memberships.yml
  139. +1 −0 activerecord/test/fixtures/owners.yml
  140. +28 −0 activerecord/test/fixtures/posts.yml
  141. +14 −0 activerecord/test/fixtures/ratings.yml
  142. +50 −0 activerecord/test/fixtures/taggings.yml
  143. +5 −1 activerecord/test/fixtures/tags.yml
  144. +1 −1 activerecord/test/fixtures/tasks.yml
  145. +38 −4 activerecord/test/models/author.rb
  146. +2 −0 activerecord/test/models/book.rb
  147. +2 −0 activerecord/test/models/categorization.rb
  148. +2 −0 activerecord/test/models/category.rb
  149. +1 −0 activerecord/test/models/club.rb
  150. +1 −0 activerecord/test/models/comment.rb
  151. +2 −0 activerecord/test/models/essay.rb
  152. +2 −0 activerecord/test/models/job.rb
  153. +11 −0 activerecord/test/models/member.rb
  154. +2 −0 activerecord/test/models/member_detail.rb
  155. +7 −1 activerecord/test/models/organization.rb
  156. +3 −0 activerecord/test/models/person.rb
  157. +10 −1 activerecord/test/models/post.rb
  158. +4 −0 activerecord/test/models/rating.rb
  159. +2 −0 activerecord/test/models/reference.rb
  160. +2 −0 activerecord/test/models/tagging.rb
  161. +16 −0 activerecord/test/schema/schema.rb
  162. +2 −2 activeresource/lib/active_resource/base.rb
  163. +1 −1 activeresource/test/cases/base_test.rb
  164. +1 −1 activeresource/test/cases/validations_test.rb
  165. +1 −1 activeresource/test/connection_test.rb
  166. +1 −1 activeresource/test/fixtures/address.rb
  167. +1 −1 activesupport/README.rdoc
  168. +1 −1 activesupport/bin/generate_tables
  169. +1 −1 activesupport/lib/active_support/backtrace_cleaner.rb
  170. +1 −0 activesupport/lib/active_support/buffered_logger.rb
  171. +11 −14 activesupport/lib/active_support/cache.rb
  172. +10 −3 activesupport/lib/active_support/callbacks.rb
  173. +6 −6 activesupport/lib/active_support/configurable.rb
  174. +2 −2 activesupport/lib/active_support/core_ext/array/random_access.rb
  175. +25 −8 activesupport/lib/active_support/core_ext/date_time/calculations.rb
  176. +1 −1 activesupport/lib/active_support/core_ext/enumerable.rb
  177. +1 −1 activesupport/lib/active_support/core_ext/float/rounding.rb
  178. +7 −13 activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
  179. +2 −0 activesupport/lib/active_support/core_ext/module/deprecation.rb
  180. +1 −1 activesupport/lib/active_support/core_ext/object/blank.rb
  181. +13 −6 activesupport/lib/active_support/core_ext/object/to_param.rb
  182. +1 −1 activesupport/lib/active_support/core_ext/object/try.rb
  183. +3 −3 activesupport/lib/active_support/core_ext/string/filters.rb
  184. +1 −1 activesupport/lib/active_support/core_ext/string/multibyte.rb
  185. +1 −1 activesupport/lib/active_support/core_ext/string/output_safety.rb
  186. +2 −11 activesupport/lib/active_support/core_ext/time/calculations.rb
  187. +1 −1 activesupport/lib/active_support/dependencies.rb
  188. +2 −2 activesupport/lib/active_support/hash_with_indifferent_access.rb
  189. +1 −1 activesupport/lib/active_support/i18n_railtie.rb
  190. +7 −5 activesupport/lib/active_support/json/backends/yaml.rb
  191. +1 −1 activesupport/lib/active_support/log_subscriber.rb
  192. +2 −2 activesupport/lib/active_support/log_subscriber/test_helper.rb
  193. +1 −1 activesupport/lib/active_support/message_encryptor.rb
  194. +1 −1 activesupport/lib/active_support/message_verifier.rb
  195. +1 −1 activesupport/lib/active_support/multibyte/unicode.rb
  196. +2 −2 activesupport/lib/active_support/ordered_options.rb
  197. +2 −2 activesupport/lib/active_support/testing/pending.rb
  198. +1 −1 activesupport/lib/active_support/time_with_zone.rb
  199. +1 −1 activesupport/lib/active_support/whiny_nil.rb
  200. +3 −3 activesupport/test/caching_test.rb
  201. +30 −0 activesupport/test/callback_inheritance_test.rb
  202. +34 −0 activesupport/test/callbacks_test.rb
  203. +4 −9 activesupport/test/core_ext/date_ext_test.rb
  204. +13 −3 activesupport/test/core_ext/time_ext_test.rb
  205. +4 −4 activesupport/test/json/decoding_test.rb
  206. +2 −0 activesupport/test/whiny_nil_test.rb
  207. +44 −4 ci/ci_build.rb
  208. +2 −2 ci/ci_setup_notes.txt
  209. +2 −1 railties/README.rdoc
  210. +2 −2 railties/guides/source/3_0_release_notes.textile
  211. +22 −13 railties/guides/source/action_controller_overview.textile
  212. +1 −1 railties/guides/source/action_view_overview.textile
  213. +17 −1 railties/guides/source/active_record_querying.textile
  214. +20 −3 railties/guides/source/active_record_validations_callbacks.textile
  215. +4 −2 railties/guides/source/active_support_core_extensions.textile
  216. +1 −1 railties/guides/source/caching_with_rails.textile
  217. +5 −5 railties/guides/source/contribute.textile
  218. +26 −4 railties/guides/source/contributing_to_ruby_on_rails.textile
  219. +1 −1 railties/guides/source/credits.html.erb
  220. +7 −7 railties/guides/source/debugging_rails_applications.textile
  221. +5 −5 railties/guides/source/form_helpers.textile
  222. +3 −3 railties/guides/source/generators.textile
  223. +2 −2 railties/guides/source/getting_started.textile
  224. +14 −14 railties/guides/source/i18n.textile
  225. +1 −1 railties/guides/source/index.html.erb
  226. +0 −3 railties/guides/source/layout.html.erb
  227. +1 −1 railties/guides/source/migrations.textile
  228. +2 −2 railties/guides/source/performance_testing.textile
  229. +7 −6 railties/guides/source/plugins.textile
  230. +1 −1 railties/guides/source/routing.textile
  231. +1 −1 railties/guides/source/security.textile
  232. +4 −2 railties/guides/source/testing.textile
  233. +6 −6 railties/lib/rails/engine.rb
  234. +4 −3 railties/lib/rails/generators/actions.rb
  235. +1 −1 railties/lib/rails/generators/rails/app/templates/config/locales/en.yml
  236. +1 −1 railties/lib/rails/generators/rails/app/templates/config/routes.rb
  237. +3 −1 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
  238. +1 −1 railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb
  239. +1 −1 railties/lib/rails/generators/resource_helpers.rb
  240. +1 −1 railties/lib/rails/generators/test_unit/model/templates/fixtures.yml
  241. +1 −1 railties/lib/rails/rack/logger.rb
  242. +9 −1 railties/lib/rails/railtie/configuration.rb
  243. +25 −0 railties/test/generators/actions_test.rb
  244. +6 −6 railties/test/generators/plugin_new_generator_test.rb
  245. +13 −14 railties/test/generators/shared_generator_tests.rb
View
@@ -36,6 +36,9 @@ platforms :mri_19 do
end
platforms :ruby do
+ if ENV["RB_FSEVENT"]
+ gem 'rb-fsevent'
+ end
gem 'json'
gem 'yajl-ruby'
gem "nokogiri", ">= 1.4.4"
View
@@ -85,6 +85,7 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('actionmailer/README.rdoc')
rdoc.rdoc_files.include('actionmailer/CHANGELOG')
rdoc.rdoc_files.include('actionmailer/lib/action_mailer/base.rb')
+ rdoc.rdoc_files.include('actionmailer/lib/action_mailer/mail_helper.rb')
rdoc.rdoc_files.exclude('actionmailer/lib/action_mailer/vendor/*')
rdoc.rdoc_files.include('activesupport/README.rdoc')
View
@@ -74,10 +74,10 @@ Or you can just chain the methods together like:
== Receiving emails
-To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
-tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes an
+email object as its single parameter. The Action Mailer framework has a corresponding class method,
which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
-into the tmail object and calls the receive instance method.
+into the email object and calls the receive instance method.
Example:
@@ -104,7 +104,7 @@ trivial case like this:
rails runner 'Mailman.receive(STDIN.read)'
However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
-instance of Rails should be run within a daemon if it is going to be utilized to process more than just
+instance of Rails should be run within a daemon, if it is going to be utilized to process more than just
a limited number of email.
== Configuration
@@ -128,7 +128,7 @@ The latest version of Action Mailer can be installed with Rubygems:
Source code can be downloaded as part of the Rails project on GitHub
-* http://github.com/rails/rails/tree/master/actionmailer/
+* https://github.com/rails/rails/tree/master/actionmailer/
== License
@@ -145,3 +145,4 @@ API documentation is at
Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
+
@@ -291,7 +291,7 @@ module ActionMailer #:nodoc:
# * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the
# authentication type here.
# This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
- # send password BASE64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
+ # send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
# information and a cryptographic Message Digest 5 algorithm to hash important information)
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server
# and starts to use it.
@@ -4,7 +4,7 @@ module MailHelper
# each line, and wrapped at 72 columns.
def block_format(text)
formatted = text.split(/\n\r\n/).collect { |paragraph|
- simple_format(paragraph)
+ format_paragraph(paragraph)
}.join("\n")
# Make list points stand on their own line
@@ -29,8 +29,15 @@ def attachments
@_message.attachments
end
- private
- def simple_format(text, len = 72, indent = 2)
+ # Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
+ #
+ # === Examples
+ #
+ # my_text = "Here is a sample text with more than 40 characters"
+ #
+ # format_paragraph(my_text, 25, 4)
+ # # => " Here is a sample text with\n more than 40 characters"
+ def format_paragraph(text, len = 72, indent = 2)
sentences = [[]]
text.split.each do |word|
@@ -1,15 +1,18 @@
Description:
+============
Stubs out a new mailer and its views. Pass the mailer name, either
CamelCased or under_scored, and an optional list of emails as arguments.
This generates a mailer class in app/mailers and invokes your template
engine and test framework generators.
Example:
- `rails generate mailer Notifications signup forgot_password invoice`
+========
+ rails generate mailer Notifications signup forgot_password invoice
creates a Notifications mailer class, views, test, and fixtures:
Mailer: app/mailers/notifications.rb
Views: app/views/notifications/signup.erb [...]
Test: test/functional/notifications_test.rb
Fixtures: test/fixtures/notifications/signup [...]
+
@@ -153,8 +153,8 @@ def teardown
assert_equal(2, email.parts.length)
assert_equal("multipart/related", email.mime_type)
assert_equal("multipart/alternative", email.parts[0].mime_type)
- assert_equal("text/plain", email.parts[0].parts[0].mime_type)
- assert_equal("text/html", email.parts[0].parts[1].mime_type)
+ assert_equal("text/plain", email.parts[0].parts[0].mime_type)
+ assert_equal("text/html", email.parts[0].parts[1].mime_type)
assert_equal("logo.png", email.parts[1].filename)
end
@@ -14,6 +14,14 @@ def use_mail_helper
end
end
+ def use_format_paragraph
+ @text = "But soft! What light through yonder window breaks?"
+
+ mail_with_defaults do |format|
+ format.html { render(:inline => "<%= format_paragraph @text, 15, 1 %>") }
+ end
+ end
+
def use_mailer
mail_with_defaults do |format|
format.html { render(:inline => "<%= mailer.message.subject %>") }
@@ -50,5 +58,10 @@ def test_use_message
mail = HelperMailer.use_message
assert_match "using helpers", mail.body.encoded
end
+
+ def test_use_format_paragraph
+ mail = HelperMailer.use_format_paragraph
+ assert_match " But soft! What\r\n light through\r\n yonder window\r\n breaks?", mail.body.encoded
+ end
end
View
@@ -1,5 +1,11 @@
*Rails 3.1.0 (unreleased)*
+* Sensitive query string parameters (specified in config.filter_parameters) will now be filtered out from the request paths in the log file. [Prem Sichanugrist, fxn]
+
+* URL parameters which return false for to_param now appear in the query string (previously they were removed) [Andrew White]
+
+* URL parameters which return nil for to_param are now removed from the query string [Andrew White]
+
* ActionDispatch::MiddlewareStack now uses composition over inheritance. It is
no longer an array which means there may be methods missing that were not
tested.
View
@@ -323,7 +323,7 @@ The latest version of Action Pack can be installed with Rubygems:
Source code can be downloaded as part of the Rails project on GitHub
-* http://github.com/rails/rails/tree/master/actionpack/
+* https://github.com/rails/rails/tree/master/actionpack/
== License
@@ -14,7 +14,7 @@ module Callbacks
# Override AbstractController::Base's process_action to run the
# process_action callbacks around the normal behavior.
def process_action(method_name, *args)
- run_callbacks(:process_action, method_name) do
+ run_callbacks(:process_action, action_name) do
super
end
end
@@ -36,7 +36,7 @@ module ClassMethods
# ==== Parameters
# * <tt>path</tt> - If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
- # (see ActionView::ViewPathSet for more information)
+ # (see ActionView::PathSet for more information)
def append_view_path(path)
self.view_paths = view_paths.dup + Array(path)
end
@@ -46,7 +46,7 @@ def append_view_path(path)
# ==== Parameters
# * <tt>path</tt> - If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
- # (see ActionView::ViewPathSet for more information)
+ # (see ActionView::PathSet for more information)
def prepend_view_path(path)
self.view_paths = Array(path) + view_paths.dup
end
@@ -59,8 +59,8 @@ def view_paths
# Set the view paths.
#
# ==== Parameters
- # * <tt>paths</tt> - If a ViewPathSet is provided, use that;
- # otherwise, process the parameter into a ViewPathSet.
+ # * <tt>paths</tt> - If a PathSet is provided, use that;
+ # otherwise, process the parameter into a PathSet.
def view_paths=(paths)
self._view_paths = ActionView::Base.process_view_paths(paths)
self._view_paths.freeze
@@ -80,7 +80,7 @@ module Caching
# header the Content-Type of the cached response could be wrong because
# no information about the MIME type is stored in the cache key. So, if
# you first ask for MIME type M in the Accept header, a cache entry is
- # created, and then perform a second resquest to the same resource asking
+ # created, and then perform a second request to the same resource asking
# for a different MIME type, you'd get the content cached for M.
#
# The <tt>:format</tt> parameter is taken into account though. The safest
@@ -78,7 +78,7 @@ def cleanup_view_runtime #:nodoc:
yield
end
- # Everytime after an action is processed, this method is invoked
+ # Every time after an action is processed, this method is invoked
# with the payload, so you can add more information.
# :api: plugin
def append_info_to_payload(payload) #:nodoc:
@@ -172,6 +172,10 @@ def assign_parameters(routes, controller_path, action, parameters = {})
end
def recycle!
+ write_cookies!
+ @env.delete('HTTP_COOKIE') if @cookies.blank?
+ @env.delete('action_dispatch.cookies')
+ @cookies = nil
@formats = nil
@env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
@env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
@@ -301,7 +305,11 @@ def exists?
# and cookies, though. For sessions, you just do:
#
# @request.session[:key] = "value"
- # @request.cookies["key"] = "value"
+ # @request.cookies[:key] = "value"
+ #
+ # To clear the cookies for a test just clear the request's cookies hash:
+ #
+ # @request.cookies.clear
#
# == \Testing named routes
#
@@ -416,6 +424,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
@controller.process_with_new_base_test(@request, @response)
@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
@request.session.delete('flash') if @request.session['flash'].blank?
+ @request.cookies.merge!(@response.cookies)
@response
end
@@ -5,10 +5,10 @@
module ActionDispatch
module Http
# Allows you to specify sensitive parameters which will be replaced from
- # the request log by looking in all subhashes of the param hash for keys
- # to filter. If a block is given, each key and value of the parameter
- # hash and all subhashes is passed to it, the value or key can be replaced
- # using String#replace or similar method.
+ # the request log by looking in the query string of the request and all
+ # subhashes of the params hash to filter. If a block is given, each key and
+ # value of the params hash and all subhashes is passed to it, the value
+ # or key can be replaced using String#replace or similar method.
#
# Examples:
#
@@ -38,6 +38,11 @@ def filtered_env
@filtered_env ||= env_filter.filter(@env)
end
+ # Reconstructed a path with all sensitive GET parameters replaced.
+ def filtered_path
+ @filtered_path ||= query_string.empty? ? path : "#{path}?#{filtered_query_string}"
+ end
+
protected
def parameter_filter
@@ -52,6 +57,14 @@ def parameter_filter_for(filters)
@@parameter_filter_for[filters] ||= ParameterFilter.new(filters)
end
+ KV_RE = '[^&;=]+'
+ PAIR_RE = %r{(#{KV_RE})=(#{KV_RE})}
+ def filtered_query_string
+ query_string.gsub(PAIR_RE) do |_|
+ parameter_filter.filter([[$1, $2]]).first.join("=")
+ end
+ end
+
end
end
end
@@ -41,7 +41,7 @@ def url_for(options = {})
path = options.delete(:path) || ''
params = options[:params] || {}
- params.reject! {|k,v| !v }
+ params.reject! {|k,v| v.to_param.nil? }
rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
rewritten_url << "?#{params.to_query}" unless params.empty?
Oops, something went wrong.

0 comments on commit b44a0ec

Please sign in to comment.