Permalink
Browse files

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

  • Loading branch information...
mikel committed Nov 24, 2009
2 parents 3a72923 + e62e6d4 commit 5f2395041d1578433fa825ed5c6f26a201f2203d
Showing with 1,910 additions and 2,695 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 .gitmodules
  3. +28 −18 Gemfile
  4. +2 −2 Rakefile
  5. +8 −6 actionmailer/Rakefile
  6. +4 −2 actionmailer/lib/action_mailer/base.rb
  7. +3 −1 actionmailer/test/abstract_unit.rb
  8. +1 −1 actionmailer/test/mail_service_test.rb
  9. +4 −2 actionpack/actionpack.gemspec
  10. +1 −1 actionpack/lib/abstract_controller/layouts.rb
  11. +6 −0 actionpack/lib/abstract_controller/rendering_controller.rb
  12. +1 −0 actionpack/lib/action_controller/caching.rb
  13. +5 −0 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  14. +27 −17 actionpack/lib/action_controller/metal/responder.rb
  15. +0 −2 actionpack/lib/action_controller/metal/streaming.rb
  16. +2 −2 actionpack/lib/action_controller/translation.rb
  17. +3 −3 actionpack/lib/action_dispatch/http/request.rb
  18. +4 −2 actionpack/lib/action_dispatch/middleware/stack.rb
  19. +39 −78 actionpack/lib/action_dispatch/routing.rb
  20. +1 −2 actionpack/lib/action_dispatch/routing/deprecated_mapper.rb
  21. +22 −10 actionpack/lib/action_dispatch/routing/mapper.rb
  22. +15 −56 actionpack/lib/action_dispatch/routing/route_set.rb
  23. +16 −3 actionpack/lib/action_dispatch/testing/assertions.rb
  24. +1 −0 actionpack/lib/action_view/erb/util.rb
  25. +11 −2 actionpack/lib/action_view/helpers/form_helper.rb
  26. +1 −1 actionpack/lib/action_view/helpers/translation_helper.rb
  27. +1 −0 actionpack/lib/action_view/test_case.rb
  28. +1 −1 actionpack/test/abstract/layouts_test.rb
  29. +3 −19 actionpack/test/abstract_unit.rb
  30. +0 −1 actionpack/test/controller/filters_test.rb
  31. +21 −1 actionpack/test/controller/mime_responds_test.rb
  32. +1 −1 actionpack/test/controller/new_base/render_action_test.rb
  33. +19 −1 actionpack/test/controller/request_forgery_protection_test.rb
  34. +68 −40 actionpack/test/controller/routing_test.rb
  35. +4 −0 actionpack/test/dispatch/request_test.rb
  36. +52 −0 actionpack/test/dispatch/routing_test.rb
  37. +1 −1 actionpack/test/dispatch/test_request_test.rb
  38. +55 −11 actionpack/test/template/form_helper_test.rb
  39. +9 −4 actionpack/test/template/test_case_test.rb
  40. +19 −26 actionpack/test/template/url_helper_test.rb
  41. +15 −12 activemodel/Rakefile
  42. +2 −0 activemodel/lib/active_model/translation.rb
  43. +3 −1 activemodel/test/cases/helper.rb
  44. +7 −5 activerecord/Rakefile
  45. +1 −1 activerecord/activerecord.gemspec
  46. +12 −8 activerecord/lib/active_record/association_preload.rb
  47. +23 −10 activerecord/lib/active_record/associations.rb
  48. +10 −4 activerecord/lib/active_record/associations/association_proxy.rb
  49. +1 −13 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  50. +3 −4 activerecord/lib/active_record/attribute_methods.rb
  51. +0 −2 activerecord/lib/active_record/attribute_methods/dirty.rb
  52. +0 −1 activerecord/lib/active_record/base.rb
  53. +0 −34 activerecord/lib/active_record/locking/optimistic.rb
  54. +2 −0 activerecord/lib/active_record/nested_attributes.rb
  55. +2 −2 activerecord/lib/active_record/notifications.rb
  56. +4 −6 activerecord/lib/active_record/relation.rb
  57. +0 −2 activerecord/lib/active_record/validations.rb
  58. +2 −14 activerecord/test/cases/associations/habtm_join_table_test.rb
  59. +12 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  60. +22 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  61. +2 −2 activerecord/test/cases/copy_table_test_sqlite.rb
  62. +3 −1 activerecord/test/cases/helper.rb
  63. +8 −23 activerecord/test/cases/locking_test.rb
  64. +1 −1 activerecord/test/cases/pooled_connections_test.rb
  65. +2 −2 activerecord/test/cases/reflection_test.rb
  66. +1 −1 activerecord/test/cases/relations_test.rb
  67. +1 −2 activerecord/test/fixtures/edges.yml
  68. +2 −0 activerecord/test/models/company.rb
  69. +1 −1 activerecord/test/models/pirate.rb
  70. +1 −1 activerecord/test/models/ship.rb
  71. +1 −1 activerecord/test/schema/schema.rb
  72. +8 −7 activeresource/Rakefile
  73. +23 −16 activeresource/lib/active_resource/base.rb
  74. +5 −4 activeresource/lib/active_resource/connection.rb
  75. +3 −1 activeresource/test/abstract_unit.rb
  76. +0 −1 activeresource/test/cases/base/load_test.rb
  77. +2 −1 activesupport/lib/active_support/cache.rb
  78. +5 −0 activesupport/lib/active_support/cache/mem_cache_store.rb
  79. +3 −4 activesupport/lib/active_support/core_ext/array/wrap.rb
  80. +0 −7 activesupport/lib/active_support/core_ext/date.rb
  81. +0 −3 activesupport/lib/active_support/core_ext/date/conversions.rb
  82. +0 −5 activesupport/lib/active_support/core_ext/date_time.rb
  83. +0 −9 activesupport/lib/active_support/core_ext/enumerable.rb
  84. +2 −1 activesupport/lib/active_support/core_ext/hash/conversions.rb
  85. +1 −1 activesupport/lib/active_support/core_ext/integer.rb
  86. +0 −16 activesupport/lib/active_support/core_ext/integer/even_odd.rb
  87. +6 −0 activesupport/lib/active_support/core_ext/integer/multiple.rb
  88. +1 −0 activesupport/lib/active_support/core_ext/kernel/debugger.rb
  89. +2 −2 activesupport/lib/active_support/core_ext/logger.rb
  90. +3 −1 activesupport/lib/active_support/core_ext/name_error.rb
  91. +0 −27 activesupport/lib/active_support/core_ext/object/extending.rb
  92. +0 −7 activesupport/lib/active_support/core_ext/object/instance_variables.rb
  93. +0 −1 activesupport/lib/active_support/core_ext/object/misc.rb
  94. +0 −16 activesupport/lib/active_support/core_ext/object/tap.rb
  95. +0 −1 activesupport/lib/active_support/core_ext/string.rb
  96. +2 −0 activesupport/lib/active_support/core_ext/string/access.rb
  97. +0 −5 activesupport/lib/active_support/core_ext/string/bytesize.rb
  98. +1 −2 activesupport/lib/active_support/core_ext/string/interpolation.rb
  99. +0 −13 activesupport/lib/active_support/core_ext/string/iterators.rb
  100. +0 −14 activesupport/lib/active_support/core_ext/string/starts_ends_with.rb
  101. +0 −1 activesupport/lib/active_support/core_ext/symbol.rb
  102. +0 −14 activesupport/lib/active_support/core_ext/symbol/to_proc.rb
  103. +0 −10 activesupport/lib/active_support/core_ext/time.rb
  104. +1 −1 activesupport/lib/active_support/dependencies.rb
  105. +3 −2 activesupport/lib/active_support/deprecated_callbacks.rb
  106. +4 −407 activesupport/lib/active_support/inflector.rb
  107. +211 −0 activesupport/lib/active_support/inflector/inflections.rb
  108. +139 −0 activesupport/lib/active_support/inflector/methods.rb
  109. +61 −0 activesupport/lib/active_support/inflector/transliterate.rb
  110. +12 −9 activesupport/lib/active_support/json/backends/jsongem.rb
  111. +1 −1 activesupport/lib/active_support/json/encoding.rb
  112. +0 −2 activesupport/lib/active_support/message_verifier.rb
  113. +3 −2 activesupport/lib/active_support/multibyte/chars.rb
  114. +62 −40 activesupport/lib/active_support/notifications.rb
  115. +1 −1 activesupport/lib/active_support/rescuable.rb
  116. +0 −6 activesupport/lib/active_support/ruby/shim.rb
  117. +15 −0 activesupport/lib/active_support/testing/isolation.rb
  118. +2 −2 activesupport/lib/active_support/testing/setup_and_teardown.rb
  119. +23 −3 activesupport/lib/active_support/time.rb
  120. +1 −7 activesupport/lib/active_support/time_with_zone.rb
  121. +1 −3 activesupport/lib/active_support/values/time_zone.rb
  122. +1 −1 activesupport/lib/active_support/vendor.rb
  123. +8 −2 activesupport/lib/active_support/whiny_nil.rb
  124. +5 −12 activesupport/test/abstract_unit.rb
  125. +3 −1 activesupport/test/caching_test.rb
  126. +20 −0 activesupport/test/core_ext/array_ext_test.rb
  127. +1 −1 activesupport/test/core_ext/date_ext_test.rb
  128. +1 −1 activesupport/test/core_ext/date_time_ext_test.rb
  129. +0 −12 activesupport/test/core_ext/enumerable_test.rb
  130. +0 −16 activesupport/test/core_ext/integer_ext_test.rb
  131. +11 −15 activesupport/test/core_ext/name_error_test.rb
  132. +0 −7 activesupport/test/core_ext/object_and_class_ext_test.rb
  133. +0 −9 activesupport/test/core_ext/object_ext_test.rb
  134. +1 −1 activesupport/test/core_ext/range_ext_test.rb
  135. +2 −27 activesupport/test/core_ext/string_ext_test.rb
  136. +0 −9 activesupport/test/core_ext/symbol_test.rb
  137. +0 −1 activesupport/test/dependencies_test.rb
  138. +2 −2 activesupport/test/i18n_test.rb
  139. +1 −0 activesupport/test/json/decoding_test.rb
  140. +1 −0 activesupport/test/message_encryptor_test.rb
  141. +2 −0 activesupport/test/message_verifier_test.rb
  142. +5 −5 activesupport/test/multibyte_chars_test.rb
  143. +1 −0 activesupport/test/multibyte_utils_test.rb
  144. +30 −10 activesupport/test/notifications_test.rb
  145. +13 −1 activesupport/test/whiny_nil_test.rb
  146. +1 −0 arel
  147. +36 −28 ci/ci_build.rb
  148. +1 −24 ci/geminstaller.yml
  149. +1 −0 rack-mount
  150. +2 −0 railties/CHANGELOG
  151. +15 −17 railties/Rakefile
  152. +12 −0 railties/lib/rails.rb
  153. +18 −37 railties/lib/rails/application.rb
  154. +46 −39 railties/lib/rails/commands/console.rb
  155. +3 −0 railties/lib/rails/commands/destroy.rb
  156. +3 −0 railties/lib/rails/commands/generate.rb
  157. +61 −59 railties/lib/rails/commands/server.rb
  158. +4 −31 railties/lib/rails/configuration.rb
  159. +12 −24 railties/lib/rails/generators.rb
  160. +29 −27 railties/lib/rails/generators/base.rb
  161. +4 −2 railties/lib/rails/generators/rails/app/app_generator.rb
  162. +0 −1 railties/lib/rails/generators/rails/app/templates/script/{about.tt → about}
  163. +1 −1 railties/lib/rails/generators/rails/app/templates/script/{console.tt → console}
  164. +0 −1 railties/lib/rails/generators/rails/app/templates/script/{dbconsole.tt → dbconsole}
  165. +0 −3 railties/lib/rails/generators/rails/app/templates/script/{destroy.tt → destroy}
  166. +0 −3 railties/lib/rails/generators/rails/app/templates/script/{generate.tt → generate}
  167. +0 −1 railties/lib/rails/generators/rails/app/templates/script/performance/{benchmarker.tt → benchmarker}
  168. +0 −1 railties/lib/rails/generators/rails/app/templates/script/performance/{profiler.tt → profiler}
  169. +0 −1 railties/lib/rails/generators/rails/app/templates/script/{plugin.tt → plugin}
  170. +0 −1 railties/lib/rails/generators/rails/app/templates/script/{runner.tt → runner}
  171. +1 −1 railties/lib/rails/generators/rails/app/templates/script/{server.tt → server}
  172. +1 −1 railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb
  173. +1 −1 railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
  174. +2 −1 railties/lib/rails/initializable.rb
  175. +2 −12 railties/lib/rails/initializer.rb
  176. +5 −1 railties/lib/rails/paths.rb
  177. +45 −164 railties/lib/rails/plugin.rb
  178. +0 −200 railties/lib/rails/plugin/loader.rb
  179. +0 −100 railties/lib/rails/plugin/locator.rb
  180. +2 −0 railties/lib/rails/rack/debugger.rb
  181. +1 −1 railties/lib/rails/rack/static.rb
  182. +6 −1 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/CHANGELOG.rdoc
  183. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/LICENSE
  184. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/README.rdoc
  185. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/Thorfile
  186. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor.rb
  187. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions.rb
  188. +1 −0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions/create_file.rb
  189. +9 −5 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions/directory.rb
  190. +1 −0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions/empty_directory.rb
  191. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions/file_manipulation.rb
  192. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/actions/inject_into_file.rb
  193. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/base.rb
  194. 0 ...es/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/core_ext/hash_with_indifferent_access.rb
  195. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/core_ext/ordered_hash.rb
  196. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/error.rb
  197. +1 −1 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/group.rb
  198. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/invocation.rb
  199. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/parser.rb
  200. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/parser/argument.rb
  201. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/parser/arguments.rb
  202. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/parser/option.rb
  203. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/parser/options.rb
  204. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/rake_compat.rb
  205. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/runner.rb
  206. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/shell.rb
  207. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/shell/basic.rb
  208. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/shell/color.rb
  209. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/task.rb
  210. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/util.rb
  211. 0 railties/lib/rails/vendor/{thor-0.11.8 → thor-0.12.0}/lib/thor/version.rb
  212. +3 −1 railties/test/application/notifications_test.rb
  213. +0 −117 railties/test/application/plugins_test.rb
  214. +2 −2 railties/test/backtrace_cleaner_test.rb
  215. 0 railties/test/fixtures/vendor/plugins/mspec/lib/{generators → rails_generators}/mspec_generator.rb
  216. +8 −4 railties/test/generators_test.rb
  217. +6 −2 railties/test/initializable_test.rb
  218. +21 −21 railties/test/initializer/initialize_i18n_test.rb
  219. +34 −2 railties/test/isolation/abstract_unit.rb
  220. +0 −176 railties/test/plugin_loader_test.rb
  221. +0 −73 railties/test/plugin_locator_test.rb
  222. +0 −174 railties/test/plugin_test.rb
  223. +0 −29 railties/test/plugin_test_helper.rb
  224. +183 −7 railties/test/plugins/vendored_test.rb
  225. +0 −5 railties/test/rails_info_controller_test.rb
  226. +1 −12 railties/test/rails_info_test.rb
View
@@ -27,6 +27,7 @@ railties/guides/output
*.rbc
*.swp
*.swo
+*.tmproj
bin
vendor/gems/
railties/tmp
View
@@ -0,0 +1,6 @@
+[submodule "arel"]
+ path = arel
+ url = git://github.com/rails/arel.git
+[submodule "rack-mount"]
+ path = rack-mount
+ url = git://github.com/rails/rack-mount.git
View
46 Gemfile
@@ -1,22 +1,32 @@
-clear_sources
-source 'http://gemcutter.org'
+gem "rake", ">= 0.8.7"
+gem "mocha", ">= 0.9.8"
gem "rails", "3.0.pre", :vendored_at => "railties"
-%w(
- activesupport
- activemodel
- actionpack
- actionmailer
- activerecord
- activeresource
-).each do |lib|
+%w(activesupport activemodel actionpack actionmailer activerecord activeresource).each do |lib|
gem lib, '3.0.pre', :vendored_at => lib
end
-gem "rack", "1.0.1"
-gem "rack-mount", :git => "git://github.com/rails/rack-mount.git"
-gem "rack-test", "~> 0.5.0"
-gem "erubis", "~> 2.6.0"
-gem "arel", "0.1.3", :git => "git://github.com/rails/arel.git"
-gem "mocha"
-gem "sqlite3-ruby"
-gem "RedCloth"
+
+# AR
+gem "arel", "0.2.pre", :git => "git://github.com/rails/arel.git"
+gem "sqlite3-ruby", ">= 1.2.5"
+gem "pg", ">= 0.8.0"
+gem "mysql", ">= 2.8.1"
+
+# AP
+gem "rack", "1.0.1", :git => "git://github.com/rails/rack.git"
+gem "RedCloth", ">= 4.2.2"
+
+if ENV['CI']
+ disable_system_gems
+
+ gem "nokogiri", ">= 1.4.0"
+ gem "memcache-client", ">= 1.7.6"
+
+ # fcgi gem doesn't compile on 1.9
+ # avoid minitest strangeness on 1.9
+ if RUBY_VERSION < '1.9.0'
+ gem "fcgi", ">= 0.8.7"
+ else
+ gem "test-unit", ">= 2.0.5"
+ end
+end
View
@@ -10,9 +10,9 @@ Dir["#{File.dirname(__FILE__)}/*/lib/*/version.rb"].each do |version_path|
end
desc 'Run all tests by default'
-task :default => :test
+task :default => %w(test test:isolated)
-%w(test isolated_test rdoc pgem package release gem gemspec).each do |task_name|
+%w(test test:isolated rdoc pgem package release gem gemspec).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
errors = []
View
@@ -24,14 +24,16 @@ Rake::TestTask.new { |t|
t.libs << "test"
t.pattern = 'test/*_test.rb'
t.verbose = true
- t.warning = false
+ t.warning = true
}
-task :isolated_test do
- ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
- Dir.glob("test/*_test.rb").all? do |file|
- system(ruby, '-Ilib:test', file)
- end or raise "Failures"
+namespace :test do
+ task :isolated do
+ ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
+ Dir.glob("test/*_test.rb").all? do |file|
+ system(ruby, '-Ilib:test', file)
+ end or raise "Failures"
+ end
end
# Generate the RDoc documentation
@@ -480,6 +480,8 @@ def matches_dynamic_method?(method_name) #:nodoc:
# remain uninitialized (useful when you only need to invoke the "receive"
# method, for instance).
def initialize(method_name=nil, *parameters) #:nodoc:
+ @_response_body = nil
+ super()
create!(method_name, *parameters) if method_name
end
@@ -493,8 +495,8 @@ def create!(method_name, *parameters) #:nodoc:
create_parts
# Set the subject if not set yet
- @subject ||= I18n.t(method_name, :scope => [:actionmailer, :subjects, mailer_name],
- :default => method_name.humanize)
+ @subject ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, method_name],
+ :default => method_name.humanize)
# build the mail object itself
@mail = create_mail
@@ -4,9 +4,11 @@
rescue LoadError
$:.unshift("#{root}/activesupport/lib")
$:.unshift("#{root}/actionpack/lib")
- $:.unshift("#{root}/actionmailer/lib")
end
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
+
require 'rubygems'
require 'test/unit'
@@ -415,7 +415,7 @@ def test_subject_with_i18n
assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) }
assert_equal "Subject with i18n", ActionMailer::Base.deliveries.first.subject.decoded
- I18n.backend.store_translations('en', :actionmailer => {:subjects => {:test_mailer => {:subject_with_i18n => "New Subject!"}}})
+ I18n.backend.store_translations('en', :actionmailer => {:test_mailer => {:subject_with_i18n => {:subject => "New Subject!"}}})
assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) }
assert_equal "New Subject!", ActionMailer::Base.deliveries.last.subject.decoded
end
@@ -16,8 +16,10 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', '= 3.0.pre')
s.add_dependency('activemodel', '= 3.0.pre')
- s.add_dependency('rack', '~> 1.0.0')
- s.add_dependency('rack-test', '~> 0.5.0')
+ s.add_dependency('rack', '~> 1.0.1')
+ s.add_dependency('rack-test', '~> 0.5.0')
+ s.add_dependency('rack-mount', '~> 0.2.2')
+ s.add_dependency('erubis', '~> 2.6.5')
s.require_path = 'lib'
s.autorequire = 'action_controller'
@@ -100,7 +100,7 @@ def _implied_layout_name
# name, return that string. Otherwise, use the superclass'
# layout (which might also be implied)
def _write_layout_method
- case @_layout
+ case defined?(@_layout) ? @_layout : nil
when String
self.class_eval %{def _layout(details) #{@_layout.inspect} end}
when Symbol
@@ -12,6 +12,12 @@ module RenderingController
self._view_paths ||= ActionView::PathSet.new
end
+ # Initialize controller with nil formats.
+ def initialize(*) #:nodoc:
+ @_formats = nil
+ super
+ end
+
# An instance of a view class. The default view class is ActionView::Base
#
# The view class must have the following methods:
@@ -26,6 +26,7 @@ module ActionController #:nodoc:
# config.action_controller.cache_store = :file_store, "/path/to/cache/directory"
# config.action_controller.cache_store = :drb_store, "druby://localhost:9192"
# config.action_controller.cache_store = :mem_cache_store, "localhost"
+ # config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new("localhost:11211")
# config.action_controller.cache_store = MyOwnStore.new("parameter")
module Caching
extend ActiveSupport::Concern
@@ -101,6 +101,11 @@ def form_authenticity_token
session[:_csrf_token] ||= ActiveSupport::SecureRandom.base64(32)
end
+ # The form's authenticity parameter. Override to provide your own.
+ def form_authenticity_param
+ params[request_forgery_protection_token]
+ end
+
def protect_against_forgery?
allow_forgery_protection
end
@@ -14,12 +14,11 @@ module ActionController #:nodoc:
#
# When a request comes, for example with format :xml, three steps happen:
#
- # 1) respond_with searches for a template at people/index.xml;
+ # 1) responder searches for a template at people/index.xml;
#
- # 2) if the template is not available, it will create a responder, passing
- # the controller and the resource and invoke :to_xml on it;
+ # 2) if the template is not available, it will invoke :to_xml in the given resource;
#
- # 3) if the responder does not respond_to :to_xml, call to_format on it.
+ # 3) if the responder does not respond_to :to_xml, call :to_format on it.
#
# === Builtin HTTP verb semantics
#
@@ -88,14 +87,16 @@ def initialize(controller, resources, options={})
@resource = resources.is_a?(Array) ? resources.last : resources
@resources = resources
@options = options
+ @action = options.delete(:action)
@default_response = options.delete(:default_response)
end
delegate :head, :render, :redirect_to, :to => :controller
delegate :get?, :post?, :put?, :delete?, :to => :request
- # Undefine :to_json since it's defined on Object
+ # Undefine :to_json and :to_yaml since it's defined on Object
undef_method(:to_json) if method_defined?(:to_json)
+ undef_method(:to_yaml) if method_defined?(:to_yaml)
# Initializes a new responder an invoke the proper format. If the format is
# not defined, call to_format.
@@ -111,14 +112,8 @@ def self.call(*args)
#
def to_html
default_render
- rescue ActionView::MissingTemplate
- if get?
- raise
- elsif has_errors?
- render :action => default_action
- else
- redirect_to resource_location
- end
+ rescue ActionView::MissingTemplate => e
+ navigation_behavior(e)
end
# All others formats follow the procedure below. First we try to render a
@@ -127,9 +122,26 @@ def to_html
#
def to_format
default_render
- rescue ActionView::MissingTemplate
+ rescue ActionView::MissingTemplate => e
raise unless resourceful?
+ api_behavior(e)
+ end
+ protected
+
+ # This is the common behavior for "navigation" requests, like :html, :iphone and so forth.
+ def navigation_behavior(error)
+ if get?
+ raise error
+ elsif has_errors?
+ render :action => default_action
+ else
+ redirect_to resource_location
+ end
+ end
+
+ # This is the common behavior for "API" requests, like :xml and :json.
+ def api_behavior(error)
if get?
display resource
elsif has_errors?
@@ -141,8 +153,6 @@ def to_format
end
end
- protected
-
# Checks whether the resource responds to the current format or not.
#
def resourceful?
@@ -194,7 +204,7 @@ def has_errors?
# the verb is post.
#
def default_action
- request.post? ? :new : :edit
+ @action || (request.post? ? :new : :edit)
end
end
end
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/string/bytesize'
-
module ActionController #:nodoc:
# Methods for sending arbitrary data and for streaming files to the browser,
# instead of rendering.
@@ -1,12 +1,12 @@
module ActionController
module Translation
def translate(*args)
- I18n.translate *args
+ I18n.translate(*args)
end
alias :t :translate
def localize(*args)
- I18n.localize *args
+ I18n.localize(*args)
end
alias :l :localize
end
@@ -5,7 +5,7 @@
require 'active_support/memoizable'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/hash/indifferent_access'
-require 'active_support/core_ext/object/tap'
+require 'active_support/core_ext/string/access'
module ActionDispatch
class Request < Rack::Request
@@ -166,7 +166,7 @@ def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
- [Mime[parameters[:format]]]
+ Array.wrap(Mime[parameters[:format]])
elsif xhr? || (accept && !accept.include?(?,))
accepts
else
@@ -489,7 +489,7 @@ module UploadedFile
def self.extended(object)
object.class_eval do
attr_accessor :original_path, :content_type
- alias_method :local_path, :path
+ alias_method :local_path, :path if method_defined?(:path)
end
end
@@ -1,3 +1,5 @@
+require "active_support/inflector/methods"
+
module ActionDispatch
class MiddlewareStack < Array
class Middleware
@@ -32,7 +34,7 @@ def klass
elsif @klass.respond_to?(:call)
@klass.call
else
- @klass.to_s.constantize
+ ActiveSupport::Inflector.constantize(@klass.to_s)
end
end
@@ -53,7 +55,7 @@ def ==(middleware)
when Class
klass == middleware
else
- klass == middleware.to_s.constantize
+ klass == ActiveSupport::Inflector.constantize(middleware.to_s)
end
end
Oops, something went wrong.

0 comments on commit 5f23950

Please sign in to comment.