Permalink
Browse files

Merge branch 'master' into docrails_master

  • Loading branch information...
wycats committed Apr 10, 2010
2 parents ee8e9d5 + 381f877 commit 87f7093ee3306f417e1136d947eba200d40ff8e7
Showing with 1,312 additions and 1,892 deletions.
  1. +1 −1 actionmailer/lib/action_mailer/version.rb
  2. +18 −1 actionpack/CHANGELOG
  3. +0 −1 actionpack/lib/action_controller.rb
  4. +0 −1 actionpack/lib/action_controller/base.rb
  5. +2 −2 actionpack/lib/action_controller/caching/pages.rb
  6. +19 −9 actionpack/lib/action_controller/deprecated/base.rb
  7. +0 −2 actionpack/lib/action_controller/metal/compatibility.rb
  8. +2 −1 actionpack/lib/action_controller/metal/responder.rb
  9. +0 −130 actionpack/lib/action_controller/metal/verification.rb
  10. +1 −1 actionpack/lib/action_controller/polymorphic_routes.rb
  11. +6 −0 actionpack/lib/action_controller/railtie.rb
  12. +2 −0 actionpack/lib/action_controller/test_case.rb
  13. +8 −9 actionpack/lib/action_dispatch/middleware/params_parser.rb
  14. +1 −1 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
  15. +10 −9 actionpack/lib/action_dispatch/routing/mapper.rb
  16. +1 −1 actionpack/lib/action_pack/version.rb
  17. +20 −265 actionpack/lib/action_view/helpers/active_model_helper.rb
  18. +45 −8 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  19. +2 −10 actionpack/lib/action_view/helpers/form_helper.rb
  20. +0 −2 actionpack/lib/action_view/helpers/form_options_helper.rb
  21. +12 −12 actionpack/lib/action_view/helpers/form_tag_helper.rb
  22. +5 −5 actionpack/lib/action_view/helpers/url_helper.rb
  23. +0 −8 actionpack/lib/action_view/locale/en.yml
  24. +2 −2 actionpack/lib/action_view/lookup_context.rb
  25. +1 −1 actionpack/lib/action_view/render/layouts.rb
  26. +22 −0 actionpack/test/controller/localized_templates_test.rb
  27. +6 −0 actionpack/test/controller/test_test.rb
  28. +0 −270 actionpack/test/controller/verification_test.rb
  29. +28 −0 actionpack/test/dispatch/routing_test.rb
  30. +9 −0 actionpack/test/dispatch/show_exceptions_test.rb
  31. +1 −0 actionpack/test/fixtures/localized/hello_world.de.html
  32. +1 −0 actionpack/test/fixtures/localized/hello_world.en.html
  33. +1 −0 actionpack/test/fixtures/test/_utf8_partial.html.erb
  34. +2 −0 actionpack/test/fixtures/test/_utf8_partial_magic.html.erb
  35. +1 −1 actionpack/test/fixtures/test/utf8.html.erb
  36. +1 −1 actionpack/test/fixtures/test/utf8_magic.html.erb
  37. +5 −0 actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb
  38. +0 −42 actionpack/test/template/active_model_helper_i18n_test.rb
  39. +12 −284 actionpack/test/template/active_model_helper_test.rb
  40. +12 −0 actionpack/test/template/asset_tag_helper_test.rb
  41. +2 −39 actionpack/test/template/form_helper_test.rb
  42. +47 −25 actionpack/test/template/render_test.rb
  43. +10 −10 actionpack/test/template/url_helper_test.rb
  44. +2 −2 activemodel/lib/active_model/attribute_methods.rb
  45. +3 −3 activemodel/lib/active_model/callbacks.rb
  46. +5 −0 activemodel/lib/active_model/errors.rb
  47. +1 −1 activemodel/lib/active_model/version.rb
  48. +6 −0 activemodel/test/cases/validations_test.rb
  49. +1 −0 activerecord/Rakefile
  50. +10 −3 activerecord/lib/active_record/associations/association_collection.rb
  51. +6 −0 activerecord/lib/active_record/attribute_methods/dirty.rb
  52. +4 −4 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  53. +36 −40 activerecord/lib/active_record/base.rb
  54. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  55. +0 −21 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  56. +3 −7 activerecord/lib/active_record/railties/databases.rake
  57. +1 −1 activerecord/lib/active_record/version.rb
  58. +0 −7 activerecord/test/cases/active_schema_test_postgresql.rb
  59. +0 −6 activerecord/test/cases/adapter_test.rb
  60. +4 −4 activerecord/test/cases/associations/belongs_to_associations_test.rb
  61. +95 −0 activerecord/test/cases/dirty_test.rb
  62. +39 −25 activerecord/test/cases/migration_test.rb
  63. +10 −0 activerecord/test/cases/named_scope_test.rb
  64. +11 −1 activerecord/test/cases/xml_serialization_test.rb
  65. +2 −2 activeresource/lib/active_resource/base.rb
  66. +2 −2 activeresource/lib/active_resource/http_mock.rb
  67. +1 −1 activeresource/lib/active_resource/version.rb
  68. +5 −0 activesupport/CHANGELOG
  69. +7 −1 activesupport/lib/active_support/backtrace_cleaner.rb
  70. +3 −3 activesupport/lib/active_support/cache/mem_cache_store.rb
  71. +1 −1 activesupport/lib/active_support/cache/strategy/local_cache.rb
  72. +1 −1 activesupport/lib/active_support/callbacks.rb
  73. +1 −1 activesupport/lib/active_support/core_ext/array/conversions.rb
  74. +1 −1 activesupport/lib/active_support/core_ext/module/aliasing.rb
  75. +1 −1 activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
  76. +1 −1 activesupport/lib/active_support/core_ext/module/delegation.rb
  77. +1 −1 activesupport/lib/active_support/core_ext/module/synchronization.rb
  78. +67 −18 activesupport/lib/active_support/multibyte/chars.rb
  79. +24 −30 activesupport/lib/active_support/ordered_hash.rb
  80. +1 −1 activesupport/lib/active_support/version.rb
  81. +6 −1 activesupport/test/clean_backtrace_test.rb
  82. +47 −26 activesupport/test/multibyte_chars_test.rb
  83. +0 −2 railties/CHANGELOG
  84. +1 −1 railties/guides/assets/stylesheets/main.css
  85. +391 −434 railties/guides/source/routing.textile
  86. +7 −2 railties/lib/rails.rb
  87. +16 −8 railties/lib/rails/application/configuration.rb
  88. +1 −1 railties/lib/rails/engine/configuration.rb
  89. +2 −0 railties/lib/rails/generators.rb
  90. +10 −1 railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
  91. +2 −0 railties/lib/rails/generators/erb/scaffold/templates/show.html.erb
  92. +2 −2 railties/lib/rails/generators/rails/app/app_generator.rb
  93. +0 −17 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb
  94. +14 −0 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt
  95. +4 −1 railties/lib/rails/generators/rails/app/templates/config/application.rb
  96. +41 −32 railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js
  97. 0 railties/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory
  98. +2 −0 railties/lib/rails/generators/rails/app/templates/test/{test_helper.rb → test_helper.rb.tt}
  99. +1 −0 railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
  100. +5 −0 railties/lib/rails/generators/rails/stylesheets/USAGE
  101. +9 −0 railties/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb
  102. +3 −8 ...ors/rails/{app/templates/public/stylesheets/application.css → stylesheets/templates/scaffold.css}
  103. +11 −7 railties/lib/rails/test_unit/testing.rake
  104. +1 −1 railties/lib/rails/version.rb
  105. +21 −0 railties/test/application/configuration_test.rb
  106. +2 −2 railties/test/generators/app_generator_test.rb
  107. +1 −0 railties/test/generators/scaffold_controller_generator_test.rb
  108. +8 −0 railties/test/generators/scaffold_generator_test.rb
  109. +17 −0 railties/test/generators/stylesheets_generator_test.rb
  110. +11 −0 railties/test/railties/railtie_test.rb
  111. +1 −1 version.rb
@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
- BUILD = "beta2"
+ BUILD = "beta3"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
View
@@ -1,4 +1,21 @@
-*Rails 3.0.0 [Edge] (pending)*
+*Rails 3.0.0 [beta 3] (pending)*
+
+* Removed verify method in controllers. [JV]
+ It's now available as a plugin at http://github.com/rails/verification
+
+* Removed input, form, error_messages_for and error_message_on from views. [JV]
+ It's now available as a plugin at http://github.com/rails/dynamic_form
+
+* Routes can be scoped by controller module. [Jeremy Kemper]
+
+ # /session => Auth::SessionsController
+ scope :module => 'auth' do
+ resource :session
+ end
+
+* Added #favicon_link_tag, it uses #image_path so in particular the favicon gets an asset ID [fxn]
+
+* Fixed that default locale templates should be used if the current locale template is missing [DHH]
* Added all the new HTML5 form types as individual form tag methods (search, url, number, etc) #3646 [Stephen Celis]
@@ -33,7 +33,6 @@ module ActionController
autoload :Streaming
autoload :Testing
autoload :UrlFor
- autoload :Verification
end
autoload :Dispatcher, 'action_controller/deprecated/dispatcher'
@@ -30,7 +30,6 @@ def self.without_modules(*modules)
Cookies,
Flash,
- Verification,
RequestForgeryProtection,
Streaming,
RecordIdentifier,
@@ -38,22 +38,22 @@ module Pages
extend ActiveSupport::Concern
included do
- @@page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
##
# :singleton-method:
# The cache directory should be the document root for the web server and is set using <tt>Base.page_cache_directory = "/document/root"</tt>.
# For Rails, this directory has already been set to Rails.public_path (which is usually set to <tt>RAILS_ROOT + "/public"</tt>). Changing
# this setting can be useful to avoid naming conflicts with files in <tt>public/</tt>, but doing so will likely require configuring your
# web server to look in the new location for cached files.
+ @@page_cache_directory = ''
cattr_accessor :page_cache_directory
- @@page_cache_extension = '.html'
##
# :singleton-method:
# Most Rails requests do not have an extension, such as <tt>/weblog/new</tt>. In these cases, the page caching mechanism will add one in
# order to make it easy for the cached files to be picked up properly by the web server. By default, this cache extension is <tt>.html</tt>.
# If you want something else, like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension. In cases where a request already has an
# extension, such as <tt>.xml</tt> or <tt>.rss</tt>, page caching will not add an extension. This allows it to work well with RESTful apps.
+ @@page_cache_extension = '.html'
cattr_accessor :page_cache_extension
end
@@ -6,15 +6,6 @@ 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}"
@@ -136,6 +127,25 @@ def use_accept_header=(val)
end
end
+ module DeprecatedBehavior
+ # 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
+
+ # This was moved to a plugin
+ def verify(*args)
+ ActiveSupport::Deprecation.warn "verify was removed from Rails and is now available as a plugin. " <<
+ "Please install it with `rails plugin install git://github.com/rails/verification.git`.", caller
+ end
+ end
+
+ extend DeprecatedBehavior
+
deprecated_config_writer :session_store
deprecated_config_writer :session_options
deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it"
@@ -32,8 +32,6 @@ class << self
def rescue_action(env)
raise env["action_dispatch.rescue.exception"]
end
-
- self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
end
# For old tests
@@ -135,7 +135,6 @@ def to_html
def to_format
default_render
rescue ActionView::MissingTemplate => e
- raise unless resourceful?
api_behavior(e)
end
@@ -154,6 +153,8 @@ def navigation_behavior(error)
# This is the common behavior for "API" requests, like :xml and :json.
def api_behavior(error)
+ raise error unless resourceful?
+
if get?
display resource
elsif has_errors?
@@ -1,130 +0,0 @@
-module ActionController #:nodoc:
- module Verification #:nodoc:
- extend ActiveSupport::Concern
-
- include AbstractController::Callbacks, Flash, Rendering
-
- # This module provides a class-level method for specifying that certain
- # actions are guarded against being called without certain prerequisites
- # being met. This is essentially a special kind of before_filter.
- #
- # An action may be guarded against being invoked without certain request
- # parameters being set, or without certain session values existing.
- #
- # When a verification is violated, values may be inserted into the flash, and
- # a specified redirection is triggered. If no specific action is configured,
- # verification failures will by default result in a 400 Bad Request response.
- #
- # Usage:
- #
- # class GlobalController < ActionController::Base
- # # Prevent the #update_settings action from being invoked unless
- # # the 'admin_privileges' request parameter exists. The
- # # settings action will be redirected to in current controller
- # # if verification fails.
- # verify :params => "admin_privileges", :only => :update_post,
- # :redirect_to => { :action => "settings" }
- #
- # # Disallow a post from being updated if there was no information
- # # submitted with the post, and if there is no active post in the
- # # session, and if there is no "note" key in the flash. The route
- # # named category_url will be redirected to if verification fails.
- #
- # verify :params => "post", :session => "post", "flash" => "note",
- # :only => :update_post,
- # :add_flash => { "alert" => "Failed to create your message" },
- # :redirect_to => :category_url
- #
- # Note that these prerequisites are not business rules. They do not examine
- # the content of the session or the parameters. That level of validation should
- # be encapsulated by your domain model or helper methods in the controller.
- module ClassMethods
- # Verify the given actions so that if certain prerequisites are not met,
- # the user is redirected to a different action. The +options+ parameter
- # is a hash consisting of the following key/value pairs:
- #
- # <tt>:params</tt>::
- # a single key or an array of keys that must be in the <tt>params</tt>
- # hash in order for the action(s) to be safely called.
- # <tt>:session</tt>::
- # a single key or an array of keys that must be in the <tt>session</tt>
- # in order for the action(s) to be safely called.
- # <tt>:flash</tt>::
- # a single key or an array of keys that must be in the flash in order
- # for the action(s) to be safely called.
- # <tt>:method</tt>::
- # a single key or an array of keys--any one of which must match the
- # current request method in order for the action(s) to be safely called.
- # (The key should be a symbol: <tt>:get</tt> or <tt>:post</tt>, for
- # example.)
- # <tt>:xhr</tt>::
- # true/false option to ensure that the request is coming from an Ajax
- # call or not.
- # <tt>:add_flash</tt>::
- # a hash of name/value pairs that should be merged into the session's
- # flash if the prerequisites cannot be satisfied.
- # <tt>:add_headers</tt>::
- # a hash of name/value pairs that should be merged into the response's
- # headers hash if the prerequisites cannot be satisfied.
- # <tt>:redirect_to</tt>::
- # the redirection parameters to be used when redirecting if the
- # prerequisites cannot be satisfied. You can redirect either to named
- # route or to the action in some controller.
- # <tt>:render</tt>::
- # the render parameters to be used when the prerequisites cannot be satisfied.
- # <tt>:only</tt>::
- # only apply this verification to the actions specified in the associated
- # array (may also be a single value).
- # <tt>:except</tt>::
- # do not apply this verification to the actions specified in the associated
- # array (may also be a single value).
- def verify(options={})
- before_filter :only => options[:only], :except => options[:except] do
- verify_action options
- end
- end
- end
-
- private
-
- def verify_action(options) #:nodoc:
- if prereqs_invalid?(options)
- flash.update(options[:add_flash]) if options[:add_flash]
- response.headers.merge!(options[:add_headers]) if options[:add_headers]
- apply_remaining_actions(options) unless performed?
- end
- end
-
- def prereqs_invalid?(options) # :nodoc:
- verify_presence_of_keys_in_hash_flash_or_params(options) ||
- verify_method(options) ||
- verify_request_xhr_status(options)
- end
-
- def verify_presence_of_keys_in_hash_flash_or_params(options) # :nodoc:
- [*options[:params] ].find { |v| v && params[v.to_sym].nil? } ||
- [*options[:session]].find { |v| session[v].nil? } ||
- [*options[:flash] ].find { |v| flash[v].nil? }
- end
-
- def verify_method(options) # :nodoc:
- [*options[:method]].all? { |v| request.method_symbol != v.to_sym } if options[:method]
- end
-
- def verify_request_xhr_status(options) # :nodoc:
- request.xhr? != options[:xhr] unless options[:xhr].nil?
- end
-
- def apply_redirect_to(redirect_to_option) # :nodoc:
- (redirect_to_option.is_a?(Symbol) && redirect_to_option != :back) ? self.__send__(redirect_to_option) : redirect_to_option
- end
-
- def apply_remaining_actions(options) # :nodoc:
- case
- when options[:render] ; render(options[:render])
- when options[:redirect_to] ; redirect_to(apply_redirect_to(options[:redirect_to]))
- else head(:bad_request)
- end
- end
- end
-end
@@ -120,7 +120,7 @@ def polymorphic_path(record_or_hash_or_array, options = {})
end
%w(edit new).each do |action|
- module_eval <<-EOT, __FILE__, __LINE__
+ module_eval <<-EOT, __FILE__, __LINE__ + 1
def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
polymorphic_url( # polymorphic_url(
record_or_hash, # record_or_hash,
@@ -44,6 +44,12 @@ class Railtie < Rails::Railtie
ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
end
+ initializer "action_controller.page_cache_directory" do
+ ActiveSupport.on_load(:action_controller) do
+ self.page_cache_directory = Rails.public_path
+ end
+ end
+
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
ac = app.config.action_controller
@@ -284,6 +284,8 @@ class TestCase < ActiveSupport::TestCase
include ActionDispatch::TestProcess
include ActionController::TemplateAssertions
+ attr_reader :response, :request
+
# Executes a request simulating GET HTTP method and set/volley the response
def get(action, parameters = nil, session = nil, flash = nil)
process(action, parameters, session, flash, "GET")
@@ -36,17 +36,16 @@ def parse_formatted_parameters(env)
when Proc
strategy.call(request.raw_post)
when :xml_simple, :xml_node
- request.body.size == 0 ? {} : Hash.from_xml(request.raw_post).with_indifferent_access
+ data = Hash.from_xml(request.body) || {}
+ request.body.rewind if request.body.respond_to?(:rewind)
+ data.with_indifferent_access
when :yaml
YAML.load(request.raw_post)
when :json
- if request.body.size == 0
- {}
- else
- data = ActiveSupport::JSON.decode(request.raw_post)
- data = {:_json => data} unless data.is_a?(Hash)
- data.with_indifferent_access
- end
+ data = ActiveSupport::JSON.decode(request.body)
+ request.body.rewind if request.body.respond_to?(:rewind)
+ data = {:_json => data} unless data.is_a?(Hash)
+ data.with_indifferent_access
else
false
end
@@ -76,4 +75,4 @@ def logger
defined?(Rails.logger) ? Rails.logger : Logger.new($stderr)
end
end
-end
+end
@@ -6,7 +6,7 @@
<% end %>
<%
- clean_params = @request.parameters.clone
+ clean_params = @request.filtered_parameters.clone
clean_params.delete("action")
clean_params.delete("controller")
Oops, something went wrong.

0 comments on commit 87f7093

Please sign in to comment.