Permalink
Browse files

Merge commit 'mainstream/master'

Conflicts:
	railties/guides/files/stylesheets/main.css
	railties/guides/rails_guides/generator.rb
	railties/guides/source/index.erb.textile
  • Loading branch information...
2 parents b6fb79c + 4458edc commit 1ab84247ca4b80afbd82afe7539b3449636344c4 @lifo lifo committed Mar 10, 2009
Showing with 2,757 additions and 1,284 deletions.
  1. +1 −1 actionmailer/CHANGELOG
  2. +1 −1 actionmailer/Rakefile
  3. +2 −1 actionmailer/lib/action_mailer.rb
  4. +4 −1 actionmailer/lib/action_mailer/part.rb
  5. +1 −1 actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb
  6. +1 −1 actionmailer/lib/action_mailer/version.rb
  7. +2 −1 actionmailer/test/mail_service_test.rb
  8. +4 −4 actionmailer/test/test_helper_test.rb
  9. +7 −1 actionpack/CHANGELOG
  10. +1 −1 actionpack/Rakefile
  11. +43 −11 actionpack/lib/action_controller/base.rb
  12. +0 −7 actionpack/lib/action_controller/dispatcher.rb
  13. +16 −9 actionpack/lib/action_controller/layout.rb
  14. +1 −1 actionpack/lib/action_controller/request.rb
  15. +8 −3 actionpack/lib/action_controller/resources.rb
  16. +1 −1 actionpack/lib/action_controller/routing.rb
  17. +2 −1 actionpack/lib/action_controller/routing/builder.rb
  18. +0 −1 actionpack/lib/action_controller/routing/recognition_optimisation.rb
  19. +11 −3 actionpack/lib/action_controller/routing/segments.rb
  20. +1 −1 actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
  21. +1 −1 actionpack/lib/action_pack/version.rb
  22. +3 −3 actionpack/lib/action_view/base.rb
  23. +2 −2 actionpack/lib/action_view/helpers/active_record_helper.rb
  24. +83 −49 actionpack/lib/action_view/helpers/form_helper.rb
  25. +2 −2 actionpack/lib/action_view/helpers/form_tag_helper.rb
  26. +3 −1 actionpack/lib/action_view/helpers/number_helper.rb
  27. +1 −1 actionpack/lib/action_view/helpers/prototype_helper.rb
  28. +3 −3 actionpack/lib/action_view/paths.rb
  29. +15 −8 actionpack/lib/action_view/template.rb
  30. +21 −0 actionpack/test/activerecord/active_record_store_test.rb
  31. +33 −28 actionpack/test/controller/assert_select_test.rb
  32. +8 −0 actionpack/test/controller/fake_models.rb
  33. +1 −1 actionpack/test/controller/html-scanner/document_test.rb
  34. +11 −1 actionpack/test/controller/layout_test.rb
  35. +1 −1 actionpack/test/controller/mime_responds_test.rb
  36. +2 −2 actionpack/test/controller/redirect_test.rb
  37. +118 −11 actionpack/test/controller/render_test.rb
  38. +9 −9 actionpack/test/controller/request_forgery_protection_test.rb
  39. +3 −3 actionpack/test/controller/request_test.rb
  40. +55 −11 actionpack/test/controller/resources_test.rb
  41. +83 −29 actionpack/test/controller/routing_test.rb
  42. +3 −3 actionpack/test/controller/selector_test.rb
  43. +1 −1 actionpack/test/controller/send_file_test.rb
  44. +1 −1 actionpack/test/controller/url_rewriter_test.rb
  45. +1 −0 actionpack/test/fixtures/layouts/default_html.html.erb
  46. +2 −0 actionpack/test/fixtures/layouts/xhr.html.erb
  47. +1 −0 actionpack/test/fixtures/quiz/questions/_question.html.erb
  48. +1 −0 actionpack/test/fixtures/test/malformed/malformed.en.html.erb~
  49. +1 −0 actionpack/test/fixtures/test/malformed/malformed.erb~
  50. +1 −0 actionpack/test/fixtures/test/malformed/malformed.html.erb~
  51. +34 −0 actionpack/test/template/active_record_helper_test.rb
  52. +41 −0 actionpack/test/template/form_helper_test.rb
  53. +9 −2 actionpack/test/template/form_tag_helper_test.rb
  54. +0 −5 actionpack/test/template/javascript_helper_test.rb
  55. +1 −0 actionpack/test/template/number_helper_test.rb
  56. +14 −0 actionpack/test/template/render_test.rb
  57. +1 −1 actionpack/test/template/url_helper_test.rb
  58. +1 −1 activemodel/test/state_machine/event_test.rb
  59. +1 −1 activerecord/CHANGELOG
  60. +1 −1 activerecord/Rakefile
  61. +15 −123 activerecord/lib/active_record/associations.rb
  62. +2 −2 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  63. +2 −2 activerecord/lib/active_record/associations/has_many_association.rb
  64. +5 −5 activerecord/lib/active_record/associations/has_many_through_association.rb
  65. +11 −2 activerecord/lib/active_record/associations/has_one_association.rb
  66. +182 −58 activerecord/lib/active_record/autosave_association.rb
  67. +5 −5 activerecord/lib/active_record/base.rb
  68. +18 −8 activerecord/lib/active_record/calculations.rb
  69. +16 −0 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  70. +1 −1 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  71. +7 −2 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  72. +33 −0 activerecord/lib/active_record/locking/optimistic.rb
  73. +20 −5 activerecord/lib/active_record/named_scope.rb
  74. +1 −1 activerecord/lib/active_record/reflection.rb
  75. +7 −3 activerecord/lib/active_record/session_store.rb
  76. +13 −0 activerecord/lib/active_record/test_case.rb
  77. +9 −4 activerecord/lib/active_record/validations.rb
  78. +1 −1 activerecord/lib/active_record/version.rb
  79. +19 −131 activerecord/test/cases/associations/belongs_to_associations_test.rb
  80. +4 −4 activerecord/test/cases/associations/eager_test.rb
  81. +9 −1 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  82. +17 −142 activerecord/test/cases/associations/has_many_associations_test.rb
  83. +10 −1 activerecord/test/cases/associations/has_many_through_associations_test.rb
  84. +23 −92 activerecord/test/cases/associations/has_one_associations_test.rb
  85. +2 −2 activerecord/test/cases/associations/has_one_through_associations_test.rb
  86. +1 −1 activerecord/test/cases/attribute_methods_test.rb
  87. +466 −8 activerecord/test/cases/autosave_association_test.rb
  88. +21 −23 activerecord/test/cases/base_test.rb
  89. +23 −2 activerecord/test/cases/calculations_test.rb
  90. +2 −2 activerecord/test/cases/callbacks_test.rb
  91. +25 −0 activerecord/test/cases/connection_pool_test.rb
  92. +1 −1 activerecord/test/cases/dirty_test.rb
  93. +47 −32 activerecord/test/cases/finder_test.rb
  94. +2 −2 activerecord/test/cases/fixtures_test.rb
  95. +2 −2 activerecord/test/cases/inheritance_test.rb
  96. +23 −5 activerecord/test/cases/locking_test.rb
  97. +1 −1 activerecord/test/cases/method_scoping_test.rb
  98. +20 −20 activerecord/test/cases/migration_test.rb
  99. +13 −0 activerecord/test/cases/named_scope_test.rb
  100. +4 −3 activerecord/test/cases/reflection_test.rb
  101. +2 −2 activerecord/test/cases/transactions_test.rb
  102. +27 −21 activerecord/test/cases/validations_test.rb
  103. +4 −0 activerecord/test/fixtures/toys.yml
  104. +2 −0 activerecord/test/models/company.rb
  105. +3 −0 activerecord/test/models/event.rb
  106. +2 −1 activerecord/test/models/owner.rb
  107. +2 −1 activerecord/test/models/pet.rb
  108. +6 −0 activerecord/test/models/post.rb
  109. +6 −0 activerecord/test/models/reply.rb
  110. +8 −0 activerecord/test/models/topic.rb
  111. +4 −0 activerecord/test/models/toy.rb
  112. +9 −0 activerecord/test/schema/schema.rb
  113. +5 −0 activeresource/CHANGELOG
  114. +1 −1 activeresource/Rakefile
  115. +1 −1 activeresource/lib/active_resource/version.rb
  116. +1 −0 activeresource/test/abstract_unit.rb
  117. +4 −4 activeresource/test/authorization_test.rb
  118. +10 −10 activeresource/test/base_test.rb
  119. +7 −0 activesupport/CHANGELOG
  120. +2 −3 activesupport/lib/active_support/core_ext/array/conversions.rb
  121. +2 −2 activesupport/lib/active_support/core_ext/string/inflections.rb
  122. +1 −1 activesupport/lib/active_support/duration.rb
  123. +4 −0 activesupport/lib/active_support/memoizable.rb
  124. +14 −2 activesupport/lib/active_support/multibyte/chars.rb
  125. +2 −2 activesupport/lib/active_support/ordered_hash.rb
  126. +1 −1 activesupport/lib/active_support/test_case.rb
  127. +2 −2 activesupport/lib/active_support/vendor.rb
  128. +0 −3 activesupport/lib/active_support/vendor/i18n-0.1.1/.gitignore
  129. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/MIT-LICENSE
  130. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/README.textile
  131. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/Rakefile
  132. +2 −2 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/i18n.gemspec
  133. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/lib/i18n.rb
  134. +1 −9 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/lib/i18n/backend/simple.rb
  135. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/lib/i18n/exceptions.rb
  136. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/all.rb
  137. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/i18n_exceptions_test.rb
  138. +2 −2 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/i18n_test.rb
  139. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/locale/en.rb
  140. 0 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/locale/en.yml
  141. +56 −12 activesupport/lib/active_support/vendor/{i18n-0.1.1 → i18n-0.1.3}/test/simple_backend_test.rb
  142. +1 −1 activesupport/lib/active_support/version.rb
  143. +12 −107 activesupport/lib/active_support/xml_mini.rb
  144. +131 −0 activesupport/lib/active_support/xml_mini/libxml.rb
  145. +108 −0 activesupport/lib/active_support/xml_mini/rexml.rb
  146. +3 −3 activesupport/test/core_ext/class_test.rb
  147. +3 −2 activesupport/test/core_ext/hash_ext_test.rb
  148. +2 −2 activesupport/test/core_ext/load_error_test.rb
  149. +2 −2 activesupport/test/core_ext/module/synchronization_test.rb
  150. +5 −5 activesupport/test/core_ext/module_test.rb
  151. +2 −2 activesupport/test/core_ext/object_and_class_ext_test.rb
  152. +18 −0 activesupport/test/core_ext/string_ext_test.rb
  153. +1 −1 activesupport/test/core_ext/time_with_zone_test.rb
  154. +11 −11 activesupport/test/dependencies_test.rb
  155. +4 −4 activesupport/test/inflector_test.rb
  156. +16 −0 activesupport/test/inflector_test_cases.rb
  157. +1 −1 activesupport/test/json/decoding_test.rb
  158. +1 −1 activesupport/test/json/encoding_test.rb
  159. +22 −1 activesupport/test/memoizable_test.rb
  160. +1 −1 activesupport/test/message_encryptor_test.rb
  161. +1 −1 activesupport/test/message_verifier_test.rb
  162. +26 −22 activesupport/test/multibyte_chars_test.rb
  163. +12 −2 activesupport/test/ordered_hash_test.rb
  164. +1 −1 activesupport/test/string_inquirer_test.rb
  165. +1 −1 activesupport/test/time_zone_test.rb
  166. +7 −0 railties/CHANGELOG
  167. +13 −9 railties/Rakefile
  168. +2 −0 railties/guides/source/2_3_release_notes.textile
  169. +1 −1 railties/guides/source/testing.textile
  170. +2 −2 railties/lib/commands/plugin.rb
  171. +1 −0 railties/lib/console_app.rb
  172. +23 −1 railties/lib/initializer.rb
  173. +19 −4 railties/lib/rails/backtrace_cleaner.rb
  174. +7 −4 railties/lib/rails/gem_dependency.rb
  175. +6 −2 railties/lib/rails/plugin.rb
  176. +5 −2 railties/lib/rails/plugin/loader.rb
  177. +21 −6 railties/lib/rails/rack/metal.rb
  178. +1 −1 railties/lib/rails/version.rb
  179. +6 −2 railties/lib/rails_generator/commands.rb
  180. +25 −5 railties/lib/rails_generator/generators/applications/app/template_runner.rb
  181. +3 −4 railties/lib/tasks/gems.rake
  182. +1 −1 railties/lib/tasks/testing.rake
  183. +2 −0 railties/test/abstract_unit.rb
  184. +49 −16 railties/test/backtrace_cleaner_test.rb
  185. +22 −20 railties/test/console_app_test.rb
  186. +5 −0 railties/test/fixtures/metal/multiplemetals/app/metal/metal_a.rb
  187. +5 −0 railties/test/fixtures/metal/multiplemetals/app/metal/metal_b.rb
  188. +5 −0 railties/test/fixtures/metal/singlemetal/app/metal/foo_metal.rb
  189. +7 −0 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_a.rb
  190. +7 −0 railties/test/fixtures/metal/subfolders/app/metal/Folder/metal_b.rb
  191. +10 −0 railties/test/fixtures/plugins/engines/engine/app/metal/engine_metal.rb
  192. +1 −1 railties/test/fixtures/plugins/engines/engine/init.rb
  193. +1 −1 railties/test/gem_dependency_test.rb
  194. +11 −0 railties/test/generators/rails_template_runner_test.rb
  195. +73 −10 railties/test/initializer_test.rb
  196. +66 −0 railties/test/metal_test.rb
  197. +2 −2 railties/test/plugin_loader_test.rb
  198. +1 −1 railties/test/plugin_locator_test.rb
  199. +6 −6 railties/test/plugin_test.rb
View
@@ -1,4 +1,4 @@
-*Edge*
+*2.3.1 [RC2] (March 5, 2009)*
* Fixed that ActionMailer should send correctly formatted Return-Path in MAIL FROM for SMTP #1842 [Matt Jones]
View
@@ -55,7 +55,7 @@ spec = Gem::Specification.new do |s|
s.rubyforge_project = "actionmailer"
s.homepage = "http://www.rubyonrails.org"
- s.add_dependency('actionpack', '= 2.3.0' + PKG_BUILD)
+ s.add_dependency('actionpack', '= 2.3.1' + PKG_BUILD)
s.has_rdoc = true
s.requirements << 'none'
@@ -58,4 +58,5 @@ module Net
end
autoload :MailHelper, 'action_mailer/mail_helper'
-autoload :TMail, 'action_mailer/vendor/tmail'
+
+require 'action_mailer/vendor/tmail'
@@ -88,7 +88,10 @@ def to_mail(defaults)
part.parts << prt
end
- part.set_content_type(real_content_type, nil, ctype_attrs) if real_content_type =~ /multipart/
+ if real_content_type =~ /multipart/
+ ctype_attrs.delete 'charset'
+ part.set_content_type(real_content_type, nil, ctype_attrs)
+ end
end
headers.each { |k,v| part[k] = v }
@@ -1150,7 +1150,7 @@ def test_format_style
assert_equal(Text::Format::JUSTIFY, @format_o.format_style)
assert_match(/^of freedom, and that government of the people, by the people, for the$/,
@format_o.format(GETTYSBURG).split("\n")[-3])
- assert_raises(ArgumentError) { @format_o.format_style = 33 }
+ assert_raise(ArgumentError) { @format_o.format_style = 33 }
end
def test_tag_paragraph
@@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
- TINY = 0
+ TINY = 1
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -330,6 +330,7 @@ def test_nested_parts
assert_equal "multipart/mixed", created.content_type
assert_equal "multipart/alternative", created.parts.first.content_type
assert_equal "bar", created.parts.first.header['foo'].to_s
+ assert_nil created.parts.first.charset
assert_equal "text/plain", created.parts.first.parts.first.content_type
assert_equal "text/html", created.parts.first.parts[1].content_type
assert_equal "application/octet-stream", created.parts[1].content_type
@@ -1068,7 +1069,7 @@ def test_should_not_respond_to_method_where_deliver_is_not_a_suffix
end
def test_should_still_raise_exception_with_expected_message_when_calling_an_undefined_method
- error = assert_raises NoMethodError do
+ error = assert_raise NoMethodError do
RespondToMailer.not_a_method
end
@@ -26,7 +26,7 @@ def test_mailer_class_is_correctly_inferred
end
def test_determine_default_mailer_raises_correct_error
- assert_raises(ActionMailer::NonInferrableMailerError) do
+ assert_raise(ActionMailer::NonInferrableMailerError) do
self.class.determine_default_mailer("NotAMailerTest")
end
end
@@ -84,7 +84,7 @@ def test_assert_no_emails
end
def test_assert_emails_too_few_sent
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 2 do
TestHelperMailer.deliver_test
end
@@ -94,7 +94,7 @@ def test_assert_emails_too_few_sent
end
def test_assert_emails_too_many_sent
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 1 do
TestHelperMailer.deliver_test
TestHelperMailer.deliver_test
@@ -105,7 +105,7 @@ def test_assert_emails_too_many_sent
end
def test_assert_no_emails_failure
- error = assert_raises ActiveSupport::TestCase::Assertion do
+ error = assert_raise ActiveSupport::TestCase::Assertion do
assert_no_emails do
TestHelperMailer.deliver_test
end
View
@@ -1,4 +1,10 @@
-*Edge*
+*2.3.1 [RC2] (March 5, 2009)*
+
+* Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #<Post:0x23150b8>") [DHH]
+
+* Added ability to pass in :public => true to fresh_when, stale?, and expires_in to make the request proxy cachable #2095 [Gregg Pollack]
+
+* Fixed that passing a custom form builder would be forwarded to nested fields_for calls #2023 [Eloy Duran/Nate Wiger]
* Added partial scoping to TranslationHelper#translate, so if you call translate(".foo") from the people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo") [DHH]
View
@@ -80,7 +80,7 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.requirements << 'none'
- s.add_dependency('activesupport', '= 2.3.0' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.3.1' + PKG_BUILD)
s.add_dependency('rack', '>= 0.9.0')
s.require_path = 'lib'
@@ -22,7 +22,7 @@ class MethodNotAllowed < ActionControllerError #:nodoc:
attr_reader :allowed_methods
def initialize(*allowed_methods)
- super("Only #{allowed_methods.to_sentence} requests are allowed.")
+ super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
@allowed_methods = allowed_methods
end
@@ -908,12 +908,14 @@ def render(options = nil, extra_options = {}, &block) #:doc:
end
options = extra_options
+ elsif !options.is_a?(Hash)
+ extra_options[:partial] = options
+ options = extra_options
end
layout = pick_layout(options)
response.layout = layout.path_without_format_and_extension if layout
logger.info("Rendering template within #{layout.path_without_format_and_extension}") if logger && layout
- layout = layout.path_without_format_and_extension if layout
if content_type = options[:content_type]
response.content_type = content_type.to_s
@@ -1101,7 +1103,6 @@ def redirect_to(options = {}, response_status = {}) #:doc:
end
response.redirected_to = options
- logger.info("Redirected to #{options}") if logger && logger.info?
case options
# The scheme name consist of a letter followed by any combination of
@@ -1124,6 +1125,7 @@ def redirect_to(options = {}, response_status = {}) #:doc:
def redirect_to_full_url(url, status)
raise DoubleRenderError if performed?
+ logger.info("Redirected to #{url}") if logger && logger.info?
response.redirect(url, interpret_status(status))
@performed_redirect = true
end
@@ -1133,6 +1135,11 @@ def redirect_to_full_url(url, status)
# request is considered stale and should be generated from scratch. Otherwise,
# it's fresh and we don't need to generate anything and a reply of "304 Not Modified" is sent.
#
+ # Parameters:
+ # * <tt>:etag</tt>
+ # * <tt>:last_modified</tt>
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ #
# Example:
#
# def show
@@ -1153,20 +1160,34 @@ def stale?(options)
# Sets the etag, last_modified, or both on the response and renders a
# "304 Not Modified" response if the request is already fresh.
#
+ # Parameters:
+ # * <tt>:etag</tt>
+ # * <tt>:last_modified</tt>
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ #
# Example:
#
# def show
# @article = Article.find(params[:id])
- # fresh_when(:etag => @article, :last_modified => @article.created_at.utc)
+ # fresh_when(:etag => @article, :last_modified => @article.created_at.utc, :public => true)
# end
#
# This will render the show template if the request isn't sending a matching etag or
# If-Modified-Since header and just a "304 Not Modified" response if there's a match.
+ #
def fresh_when(options)
- options.assert_valid_keys(:etag, :last_modified)
+ options.assert_valid_keys(:etag, :last_modified, :public)
response.etag = options[:etag] if options[:etag]
response.last_modified = options[:last_modified] if options[:last_modified]
+
+ if options[:public]
+ cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
+ cache_control.delete("private")
+ cache_control.delete("no-cache")
+ cache_control << "public"
+ response.headers["Cache-Control"] = cache_control.join(', ')
+ end
if request.fresh?(response)
head :not_modified
@@ -1178,15 +1199,26 @@ def fresh_when(options)
#
# Examples:
# expires_in 20.minutes
- # expires_in 3.hours, :private => false
- # expires in 3.hours, 'max-stale' => 5.hours, :private => nil, :public => true
+ # expires_in 3.hours, :public => true
+ # expires in 3.hours, 'max-stale' => 5.hours, :public => true
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
def expires_in(seconds, options = {}) #:doc:
- cache_options = { 'max-age' => seconds, 'private' => true }.symbolize_keys.merge!(options.symbolize_keys)
- cache_options.delete_if { |k,v| v.nil? or v == false }
- cache_control = cache_options.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
+ cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
+
+ cache_control << "max-age=#{seconds}"
+ cache_control.delete("no-cache")
+ if options[:public]
+ cache_control.delete("private")
+ cache_control << "public"
+ else
+ cache_control << "private"
+ end
+
+ # This allows for additional headers to be passed through like 'max-stale' => 5.hours
+ cache_control += options.symbolize_keys.reject{|k,v| k == :public || k == :private }.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
+
response.headers["Cache-Control"] = cache_control.join(', ')
end
@@ -1298,7 +1330,7 @@ def perform_action
rescue ActionView::MissingTemplate => e
# Was the implicit template missing, or was it another template?
if e.path == default_template_name
- raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence}", caller
+ raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence(:locale => :en)}", caller
else
raise e
end
@@ -13,7 +13,6 @@ def define_dispatcher_callbacks(cache_classes)
end
if defined?(ActiveRecord)
- after_dispatch :checkin_connections
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
end
@@ -115,11 +114,5 @@ def _call(env)
def flush_logger
Base.logger.flush
end
-
- def checkin_connections
- # Don't return connection (and peform implicit rollback) if this request is a part of integration test
- return if @env.key?("rack.test")
- ActiveRecord::Base.clear_active_connections!
- end
end
end
@@ -198,7 +198,7 @@ def normalize_conditions(conditions)
# is called and the return value is used. Likewise if the layout was specified as an inline method (through a proc or method
# object). If the layout was defined without a directory, layouts is assumed. So <tt>layout "weblog/standard"</tt> will return
# weblog/standard, but <tt>layout "standard"</tt> will return layouts/standard.
- def active_layout(passed_layout = nil)
+ def active_layout(passed_layout = nil, options = {})
layout = passed_layout || default_layout
return layout if layout.respond_to?(:render)
@@ -207,21 +207,23 @@ def active_layout(passed_layout = nil)
when Proc then layout.call(self)
else layout
end
-
- find_layout(active_layout, @template.template_format) if active_layout
+
+ find_layout(active_layout, default_template_format, options[:html_fallback]) if active_layout
end
private
def default_layout #:nodoc:
- layout = self.class.read_inheritable_attribute(:layout) unless default_template_format == :js
+ layout = self.class.read_inheritable_attribute(:layout)
return layout unless self.class.read_inheritable_attribute(:auto_layout)
find_layout(layout, default_template_format)
rescue ActionView::MissingTemplate
nil
end
- def find_layout(layout, *formats) #:nodoc:
- view_paths.find_template(layout.to_s =~ /layouts\// ? layout : "layouts/#{layout}", *formats)
+ def find_layout(layout, format, html_fallback=false) #:nodoc:
+ view_paths.find_template(layout.to_s =~ /layouts\// ? layout : "layouts/#{layout}", format, html_fallback)
+ rescue ActionView::MissingTemplate
+ raise if Mime::Type.lookup_by_extension(format.to_s).html?
end
def pick_layout(options)
@@ -232,7 +234,7 @@ def pick_layout(options)
when NilClass, TrueClass
active_layout if action_has_layout? && candidate_for_layout?(:template => default_template_name)
else
- active_layout(layout)
+ active_layout(layout, :html_fallback => true)
end
else
active_layout if action_has_layout? && candidate_for_layout?(options)
@@ -258,7 +260,12 @@ def candidate_for_layout?(options)
template = options[:template] || default_template(options[:action])
if options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing, :update).compact.empty?
begin
- !self.view_paths.find_template(template, default_template_format).exempt_from_layout?
+ template_object = self.view_paths.find_template(template, default_template_format)
+ # this restores the behavior from 2.2.2, where response.template.template_format was reset
+ # to :html for :js requests with a matching html template.
+ # see v2.2.2, ActionView::Base, lines 328-330
+ @real_format = :html if response.template.template_format == :js && template_object.format == "html"
+ !template_object.exempt_from_layout?
rescue ActionView::MissingTemplate
true
end
@@ -268,7 +275,7 @@ def candidate_for_layout?(options)
end
def default_template_format
- response.template.template_format
+ @real_format || response.template.template_format
end
end
end
@@ -32,7 +32,7 @@ def key?(key)
# <tt>:get</tt>. If the request \method is not listed in the HTTP_METHODS
# constant above, an UnknownHttpMethod exception is raised.
def request_method
- @request_method ||= HTTP_METHOD_LOOKUP[super] || raise(UnknownHttpMethod, "#{super}, accepted HTTP methods are #{HTTP_METHODS.to_sentence}")
+ @request_method ||= HTTP_METHOD_LOOKUP[super] || raise(UnknownHttpMethod, "#{super}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
end
# Returns the HTTP request \method used for action processing as a
@@ -91,7 +91,7 @@ def new_path
end
def shallow_path_prefix
- @shallow_path_prefix ||= "#{path_prefix unless @options[:shallow]}"
+ @shallow_path_prefix ||= @options[:shallow] ? @options[:namespace].try(:sub, /\/$/, '') : path_prefix
end
def member_path
@@ -103,7 +103,7 @@ def nesting_path_prefix
end
def shallow_name_prefix
- @shallow_name_prefix ||= "#{name_prefix unless @options[:shallow]}"
+ @shallow_name_prefix ||= @options[:shallow] ? @options[:namespace].try(:gsub, /\//, '_') : name_prefix
end
def nesting_name_prefix
@@ -670,7 +670,12 @@ def action_options_for(action, resource, method = nil)
when "show", "edit"; default_options.merge(add_conditions_for(resource.conditions, method || :get)).merge(resource.requirements(require_id))
when "update"; default_options.merge(add_conditions_for(resource.conditions, method || :put)).merge(resource.requirements(require_id))
when "destroy"; default_options.merge(add_conditions_for(resource.conditions, method || :delete)).merge(resource.requirements(require_id))
- else default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
+ else
+ if method.nil? || resource.member_methods.nil? || resource.member_methods[method.to_sym].nil?
+ default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
+ else
+ resource.member_methods[method.to_sym].include?(action) ? default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements(require_id)) : default_options.merge(add_conditions_for(resource.conditions, method)).merge(resource.requirements)
+ end
end
end
end
@@ -267,7 +267,7 @@ module ActionController
module Routing
SEPARATORS = %w( / . ? )
- HTTP_METHODS = [:get, :head, :post, :put, :delete]
+ HTTP_METHODS = [:get, :head, :post, :put, :delete, :options]
ALLOWED_REQUIREMENTS_FOR_OPTIMISATION = [:controller, :action].to_set
Oops, something went wrong.

0 comments on commit 1ab8424

Please sign in to comment.