Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
2 parents 03cb74b + af13057 commit 4c4fd1a60ff1c060e76e9ee540074756510f53ea @fxn fxn committed Apr 6, 2010
Showing with 907 additions and 510 deletions.
  1. +1 −2 Gemfile
  2. +1 −1 RAILS_VERSION
  3. +6 −3 actionpack/CHANGELOG
  4. +8 −9 actionpack/lib/abstract_controller/rendering.rb
  5. +46 −44 actionpack/lib/action_controller/base.rb
  6. +11 −5 actionpack/lib/action_controller/deprecated/base.rb
  7. +1 −2 actionpack/lib/action_controller/metal/cookies.rb
  8. +12 −5 actionpack/lib/action_controller/metal/http_authentication.rb
  9. +0 −1 actionpack/lib/action_controller/railtie.rb
  10. +18 −18 actionpack/lib/action_dispatch/middleware/cookies.rb
  11. +1 −1 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  12. +22 −8 actionpack/lib/action_dispatch/testing/integration.rb
  13. +2 −0 actionpack/lib/action_dispatch/testing/test_request.rb
  14. +67 −4 actionpack/lib/action_view/helpers/form_helper.rb
  15. +63 −0 actionpack/lib/action_view/helpers/form_tag_helper.rb
  16. +43 −34 actionpack/test/abstract/abstract_controller_test.rb
  17. +0 −4 actionpack/test/abstract_unit.rb
  18. +1 −2 actionpack/test/controller/cookie_test.rb
  19. +2 −3 actionpack/test/controller/http_digest_authentication_test.rb
  20. +45 −0 actionpack/test/controller/integration_test.rb
  21. +1 −1 actionpack/test/template/erb/form_for_test.rb
  22. +347 −206 actionpack/test/template/form_helper_test.rb
  23. +30 −0 actionpack/test/template/form_tag_helper_test.rb
  24. +3 −0 activerecord/lib/active_record/associations/association_collection.rb
  25. +1 −1 activerecord/lib/active_record/base.rb
  26. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  27. +1 −1 activerecord/lib/active_record/migration.rb
  28. +1 −1 activerecord/lib/active_record/named_scope.rb
  29. +9 −0 activerecord/test/cases/named_scope_test.rb
  30. +9 −0 activeresource/lib/active_resource/base.rb
  31. +19 −6 activeresource/test/cases/base_test.rb
  32. +1 −1 activesupport/lib/active_support/callbacks.rb
  33. +1 −1 activesupport/lib/active_support/core_ext/class/attribute.rb
  34. +1 −1 activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
  35. +1 −0 activesupport/lib/active_support/core_ext/kernel.rb
  36. +3 −3 activesupport/lib/active_support/core_ext/{object → kernel}/singleton_class.rb
  37. +0 −1 activesupport/lib/active_support/core_ext/object.rb
  38. +1 −1 activesupport/lib/active_support/core_ext/string/output_safety.rb
  39. +1 −1 activesupport/lib/active_support/inflections.rb
  40. +1 −1 activesupport/lib/active_support/inflector/inflections.rb
  41. +1 −1 activesupport/lib/active_support/memoizable.rb
  42. +11 −0 activesupport/test/core_ext/kernel_test.rb
  43. +0 −5 activesupport/test/core_ext/object_and_class_ext_test.rb
  44. +2 −0 activesupport/test/inflector_test_cases.rb
  45. +5 −2 railties/CHANGELOG
  46. +9 −2 railties/lib/rails/application.rb
  47. +3 −2 railties/lib/rails/application/configuration.rb
  48. +4 −0 railties/lib/rails/application/finisher.rb
  49. +1 −1 railties/lib/rails/backtrace_cleaner.rb
  50. +12 −0 railties/lib/rails/configuration.rb
  51. +6 −10 railties/lib/rails/engine.rb
  52. +1 −2 railties/lib/rails/engine/configuration.rb
  53. +1 −8 railties/lib/rails/generators.rb
  54. +0 −7 railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
  55. +0 −17 railties/lib/rails/generators/erb/scaffold/templates/layout.html.erb
  56. +1 −1 railties/lib/rails/generators/rails/app/app_generator.rb
  57. +1 −0 railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb
  58. 0 railties/lib/rails/generators/rails/app/templates/app/views/layouts/.empty_directory
  59. +17 −0 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
  60. +1 −1 ...s/rails/app/templates/config/initializers/{cookie_verification_secret.rb.tt → secret_token.rb.tt}
  61. +1 −3 railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt
  62. 0 railties/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory
  63. 0 ...ors/rails/{stylesheets/templates/scaffold.css → app/templates/public/stylesheets/application.css}
  64. +0 −1 railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
  65. +0 −5 railties/lib/rails/generators/rails/stylesheets/USAGE
  66. +0 −9 railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb
  67. +17 −5 railties/lib/rails/paths.rb
  68. +1 −1 railties/lib/rails/plugin.rb
  69. +3 −25 railties/lib/rails/railtie.rb
  70. +16 −0 railties/test/application/configuration_test.rb
  71. +1 −1 railties/test/application/middleware_stack_defaults_test.rb
  72. +1 −0 railties/test/application/paths_test.rb
  73. +1 −1 railties/test/application/url_generation_test.rb
  74. +7 −0 railties/test/generators/app_generator_test.rb
  75. +0 −1 railties/test/generators/scaffold_controller_generator_test.rb
  76. +0 −8 railties/test/generators/scaffold_generator_test.rb
  77. +0 −17 railties/test/generators/stylesheets_generator_test.rb
  78. +1 −1 railties/test/isolation/abstract_unit.rb
View
@@ -1,8 +1,7 @@
-path File.dirname(__FILE__)
source 'http://rubygems.org'
gem "arel", :git => "git://github.com/rails/arel.git"
-gem "rails", "3.0.0.beta2"
+gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
gem "mocha", ">= 0.9.8"
View
@@ -1 +1 @@
-3.0.0.beta2
+3.0.0.beta3
View
@@ -1,17 +1,20 @@
*Rails 3.0.0 [Edge] (pending)*
+* Added all the new HTML5 form types as individual form tag methods (search, url, number, etc) #3646 [Stephen Celis]
+
* Changed the object used in routing constraints to be an instance of
- ActionDispatch::Request rather than Rack::Request
+ ActionDispatch::Request rather than Rack::Request [YK]
* Changed ActionDispatch::Request#method to return a String, to be compatible
with Rack::Request. Added ActionDispatch::Request#method_symbol to
- return a symbol form of the request method.
+ return a symbol form of the request method. [YK]
* Changed ActionDispatch::Request#method to return the original
method and #request_method to return the overridden method in the
case of methodoverride being used (this means that #method returns
"HEAD" and #request_method returns "GET" in HEAD requests). This
- is for compatibility with Rack::Request
+ is for compatibility with Rack::Request [YK]
+
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
@@ -89,9 +89,16 @@ def view_context
# Normalize arguments, options and then delegates render_to_body and
# sticks the result in self.response_body.
def render(*args, &block)
+ self.response_body = render_to_string(*args, &block)
+ end
+
+ # Raw rendering of a template to a string. Just convert the results of
+ # render_to_body into a String.
+ # :api: plugin
+ def render_to_string(*args, &block)
options = _normalize_args(*args, &block)
_normalize_options(options)
- self.response_body = render_to_body(options)
+ render_to_body(options)
end
# Raw rendering of a template to a Rack-compatible body.
@@ -101,14 +108,6 @@ def render_to_body(options = {})
_render_template(options)
end
- # Raw rendering of a template to a string. Just convert the results of
- # render_to_body into a String.
- # :api: plugin
- def render_to_string(options={})
- _normalize_options(options)
- render_to_body(options)
- end
-
# Find and renders a template based on the options given.
# :api: private
def _render_template(options) #:nodoc:
@@ -2,48 +2,59 @@ module ActionController
class Base < Metal
abstract!
- include AbstractController::Layouts
- include AbstractController::Translation
+ def self.without_modules(*modules)
+ modules = modules.map do |m|
+ m.is_a?(Symbol) ? ActionController.const_get(m) : m
+ end
- include ActionController::Helpers
-
- include ActionController::HideActions
- include ActionController::UrlFor
- include ActionController::Redirecting
- include ActionController::Rendering
- include ActionController::Renderers::All
- include ActionController::ConditionalGet
- include ActionController::RackDelegation
+ MODULES - modules
+ end
- # Legacy modules
- include SessionManagement
- include ActionController::Caching
- include ActionController::MimeResponds
- include ActionController::PolymorphicRoutes
+ MODULES = [
+ AbstractController::Layouts,
+ AbstractController::Translation,
- # Rails 2.x compatibility
- include ActionController::Compatibility
- include ActionController::ImplicitRender
+ Helpers,
+ HideActions,
+ UrlFor,
+ Redirecting,
+ Rendering,
+ Renderers::All,
+ ConditionalGet,
+ RackDelegation,
+ SessionManagement,
+ Caching,
+ MimeResponds,
+ PolymorphicRoutes,
+ ImplicitRender,
+
+ Cookies,
+ Flash,
+ Verification,
+ RequestForgeryProtection,
+ Streaming,
+ RecordIdentifier,
+ HttpAuthentication::Basic::ControllerMethods,
+ HttpAuthentication::Digest::ControllerMethods,
+
+ # Add instrumentations hooks at the bottom, to ensure they instrument
+ # all the methods properly.
+ Instrumentation,
- include ActionController::Cookies
- include ActionController::Flash
- include ActionController::Verification
- include ActionController::RequestForgeryProtection
- include ActionController::Streaming
- include ActionController::RecordIdentifier
- include ActionController::HttpAuthentication::Basic::ControllerMethods
- include ActionController::HttpAuthentication::Digest::ControllerMethods
+ # Before callbacks should also be executed the earliest as possible, so
+ # also include them at the bottom.
+ AbstractController::Callbacks,
- # Add instrumentations hooks at the bottom, to ensure they instrument
- # all the methods properly.
- include ActionController::Instrumentation
+ # The same with rescue, append it at the end to wrap as much as possible.
+ Rescue
+ ]
- # Before callbacks should also be executed the earliest as possible, so
- # also include them at the bottom.
- include AbstractController::Callbacks
+ MODULES.each do |mod|
+ include mod
+ end
- # The same with rescue, append it at the end to wrap as much as possible.
- include ActionController::Rescue
+ # Rails 2.x compatibility
+ include ActionController::Compatibility
def self.inherited(klass)
::ActionController::Base.subclasses << klass.to_s
@@ -55,15 +66,6 @@ def self.subclasses
@subclasses ||= []
end
- # This method has been moved to ActionDispatch::Request.filter_parameters
- def self.filter_parameter_logging(*args, &block)
- ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
- filter = Rails.application.config.filter_parameters
- filter.concat(args)
- filter << block if block
- filter
- end
-
ActiveSupport.run_load_hooks(:action_controller, self)
end
end
@@ -6,6 +6,15 @@ def deprecated_config_accessor(option, message = nil)
deprecated_config_writer(option, message)
end
+ # This method has been moved to ActionDispatch::Request.filter_parameters
+ def filter_parameter_logging(*args, &block)
+ ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
+ filter = Rails.application.config.filter_parameters
+ filter.concat(args)
+ filter << block if block
+ filter
+ end
+
def deprecated_config_reader(option, message = nil)
message ||= "Reading #{option} directly from ActionController::Base is deprecated. " \
"Please read it from config.#{option}"
@@ -68,14 +77,11 @@ def ip_spoofing_check
def cookie_verifier_secret=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret= is deprecated. " <<
- "Please configure it on your application with config.cookie_secret=", caller
- ActionController::Base.config.secret = value
+ "Please configure it on your application with config.secret_token=", caller
end
def cookie_verifier_secret
- ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated. " <<
- "Please use ActionController::Base.config.secret instead.", caller
- ActionController::Base.config.secret
+ ActiveSupport::Deprecation.warn "ActionController::Base.cookie_verifier_secret is deprecated.", caller
end
def trusted_proxies=(value)
@@ -10,8 +10,7 @@ module Cookies
private
def cookies
- raise "You must set config.cookie_secret in your app's config" if config.secret.blank?
- request.cookie_jar(:signing_secret => config.secret)
+ request.cookie_jar
end
end
end
@@ -159,7 +159,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(config.secret, request, realm, &password_procedure)
+ HttpAuthentication::Digest.authenticate(request, realm, &password_procedure)
end
# Render output including the HTTP Digest authentication header
@@ -169,14 +169,15 @@ def request_http_digest_authentication(realm = "Application", message = nil)
end
# Returns false on a valid response, true otherwise
- def authenticate(secret_key, request, realm, &password_procedure)
- request.authorization && validate_digest_response(secret_key, request, realm, &password_procedure)
+ def authenticate(request, realm, &password_procedure)
+ request.authorization && validate_digest_response(request, realm, &password_procedure)
end
# Returns false unless the request credentials response value matches the expected value.
# First try the password as a ha1 digest password. If this fails, then try it as a plain
# text password.
- def validate_digest_response(secret_key, request, realm, &password_procedure)
+ def validate_digest_response(request, realm, &password_procedure)
+ secret_key = secret_token(request)
credentials = decode_credentials_header(request)
valid_nonce = validate_nonce(secret_key, request, credentials[:nonce])
@@ -225,7 +226,7 @@ def decode_credentials(header)
end
def authentication_header(controller, realm)
- secret_key = controller.config.secret
+ secret_key = secret_token(controller.request)
nonce = self.nonce(secret_key)
opaque = opaque(secret_key)
controller.headers["WWW-Authenticate"] = %(Digest realm="#{realm}", qop="auth", algorithm=MD5, nonce="#{nonce}", opaque="#{opaque}")
@@ -238,6 +239,12 @@ def authentication_request(controller, realm, message = nil)
controller.status = 401
end
+ def secret_token(request)
+ secret = request.env["action_dispatch.secret_token"]
+ raise "You must set config.secret_token in your app's config" if secret.blank?
+ secret
+ end
+
# Uses an MD5 digest based on time to generate a value to be used only once.
#
# A server-specified data string which should be uniquely generated each time a 401 response is made.
@@ -51,7 +51,6 @@ class Railtie < Rails::Railtie
ac.assets_dir = paths.public.to_a.first
ac.javascripts_dir = paths.public.javascripts.to_a.first
ac.stylesheets_dir = paths.public.stylesheets.to_a.first
- ac.secret = app.config.cookie_secret
ActiveSupport.on_load(:action_controller) do
self.config.merge!(ac)
@@ -1,7 +1,9 @@
+require "active_support/core_ext/object/blank"
+
module ActionDispatch
class Request
- def cookie_jar(config = {})
- env['action_dispatch.cookies'] ||= Cookies::CookieJar.build(self, config)
+ def cookie_jar
+ env['action_dispatch.cookies'] ||= Cookies::CookieJar.build(self)
end
end
@@ -51,17 +53,17 @@ def cookie_jar(config = {})
# only HTTP. Defaults to +false+.
class Cookies
class CookieJar < Hash #:nodoc:
- def self.build(request, config = {})
- new(config).tap do |hash|
+ def self.build(request)
+ secret = request.env["action_dispatch.secret_token"]
+ new(secret).tap do |hash|
hash.update(request.cookies)
end
end
- def initialize(config = {})
- @config = config
+ def initialize(secret=nil)
+ @secret = secret
@set_cookies = {}
@delete_cookies = {}
-
super()
end
@@ -112,15 +114,15 @@ def delete(key, options = {})
# cookies.permanent.signed[:remember_me] = current_user.id
# # => Set-Cookie: discount=BAhU--848956038e692d7046deab32b7131856ab20e14e; path=/; expires=Sun, 16-Dec-2029 03:24:16 GMT
def permanent
- @permanent ||= PermanentCookieJar.new(self, @config)
+ @permanent ||= PermanentCookieJar.new(self, @secret)
end
# Returns a jar that'll automatically generate a signed representation of cookie value and verify it when reading from
# the cookie again. This is useful for creating cookies with values that the user is not supposed to change. If a signed
# cookie was tampered with by the user (or a 3rd party), an ActiveSupport::MessageVerifier::InvalidSignature exception will
# be raised.
#
- # This jar requires that you set a suitable secret for the verification on your app's config.cookie_secret.
+ # This jar requires that you set a suitable secret for the verification on your app's config.secret_token.
#
# Example:
#
@@ -129,7 +131,7 @@ def permanent
#
# cookies.signed[:discount] # => 45
def signed
- @signed ||= SignedCookieJar.new(self, @config)
+ @signed ||= SignedCookieJar.new(self, @secret)
end
def write(response)
@@ -139,9 +141,8 @@ def write(response)
end
class PermanentCookieJar < CookieJar #:nodoc:
- def initialize(parent_jar, config = {})
- @parent_jar = parent_jar
- @config = config
+ def initialize(parent_jar, secret)
+ @parent_jar, @secret = parent_jar, secret
end
def []=(key, options)
@@ -156,7 +157,7 @@ def []=(key, options)
end
def signed
- @signed ||= SignedCookieJar.new(self, @config)
+ @signed ||= SignedCookieJar.new(self, @secret)
end
def method_missing(method, *arguments, &block)
@@ -165,11 +166,10 @@ def method_missing(method, *arguments, &block)
end
class SignedCookieJar < CookieJar #:nodoc:
- def initialize(parent_jar, config = {})
- raise 'Missing cookie signing secret' if config[:signing_secret].blank?
+ def initialize(parent_jar, secret)
+ raise "You must set config.secret_token in your app's config" if secret.blank?
@parent_jar = parent_jar
- @config = config
- @verifier = ActiveSupport::MessageVerifier.new(config[:signing_secret])
+ @verifier = ActiveSupport::MessageVerifier.new(secret)
end
def [](name)
@@ -192,7 +192,7 @@ def ensure_secret_secure(secret)
if secret.blank?
raise ArgumentError, "A secret is required to generate an " +
"integrity hash for cookie session data. Use " +
- "config.cookie_secret = \"some secret phrase of at " +
+ "config.secret_token = \"some secret phrase of at " +
"least #{SECRET_MIN_LENGTH} characters\"" +
"in config/application.rb"
end
Oops, something went wrong.

0 comments on commit 4c4fd1a

Please sign in to comment.