Permalink
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
2 parents acd0456 + cb21db1 commit f6124c2b09aed7b5951d0ac83438459c49757a36 @lifo lifo committed Aug 3, 2008
Showing with 743 additions and 600 deletions.
  1. 0 actionmailer/README
  2. 0 actionmailer/Rakefile
  3. 0 actionmailer/lib/action_mailer.rb
  4. +15 −4 actionmailer/lib/action_mailer/base.rb
  5. 0 actionmailer/test/mail_service_test.rb
  6. +2 −0 actionpack/CHANGELOG
  7. 0 actionpack/lib/action_controller.rb
  8. +22 −22 actionpack/lib/action_controller/assertions/routing_assertions.rb
  9. +16 −10 actionpack/lib/action_controller/assertions/selector_assertions.rb
  10. +15 −2 actionpack/lib/action_controller/base.rb
  11. +7 −11 actionpack/lib/action_controller/dispatcher.rb
  12. +1 −1 actionpack/lib/action_controller/integration.rb
  13. 0 actionpack/lib/action_controller/request.rb
  14. 0 actionpack/lib/action_controller/request_profiler.rb
  15. 0 actionpack/lib/action_controller/response.rb
  16. +28 −30 actionpack/lib/action_controller/routing.rb
  17. +6 −23 actionpack/lib/action_controller/routing/builder.rb
  18. +12 −11 actionpack/lib/action_controller/routing/optimisations.rb
  19. +17 −23 actionpack/lib/action_controller/routing/recognition_optimisation.rb
  20. +162 −147 actionpack/lib/action_controller/routing/route.rb
  21. +4 −3 actionpack/lib/action_controller/routing/route_set.rb
  22. +0 −1 actionpack/lib/action_controller/routing/routing_ext.rb
  23. +20 −14 actionpack/lib/action_controller/routing/segments.rb
  24. +7 −7 actionpack/lib/action_controller/session/drb_server.rb
  25. 0 actionpack/lib/action_view/helpers/date_helper.rb
  26. +1 −1 actionpack/lib/action_view/helpers/form_tag_helper.rb
  27. +124 −62 actionpack/lib/action_view/helpers/number_helper.rb
  28. +7 −7 actionpack/lib/action_view/helpers/prototype_helper.rb
  29. +1 −1 actionpack/lib/action_view/helpers/text_helper.rb
  30. +28 −7 actionpack/lib/action_view/locale/en-US.rb
  31. +2 −0 actionpack/lib/action_view/paths.rb
  32. 0 actionpack/test/controller/cgi_test.rb
  33. 0 actionpack/test/controller/redirect_test.rb
  34. +56 −96 actionpack/test/controller/routing_test.rb
  35. 0 actionpack/test/controller/session/cookie_store_test.rb
  36. +12 −13 actionpack/test/controller/test_test.rb
  37. 0 actionpack/test/template/date_helper_test.rb
  38. +6 −0 actionpack/test/template/form_tag_helper_test.rb
  39. +41 −5 actionpack/test/template/number_helper_i18n_test.rb
  40. +26 −22 actionpack/test/template/number_helper_test.rb
  41. +12 −6 actionpack/test/template/prototype_helper_test.rb
  42. 0 activemodel/Rakefile
  43. 0 activerecord/README
  44. 0 activerecord/Rakefile
  45. 0 activerecord/lib/active_record.rb
  46. 0 activerecord/lib/active_record/associations.rb
  47. 0 activerecord/lib/active_record/associations/belongs_to_association.rb
  48. 0 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  49. 0 activerecord/lib/active_record/associations/has_one_association.rb
  50. +9 −1 activerecord/lib/active_record/base.rb
  51. 0 activerecord/lib/active_record/callbacks.rb
  52. +4 −0 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  53. 0 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  54. +4 −0 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  55. +2 −2 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  56. 0 activerecord/lib/active_record/fixtures.rb
  57. +20 −26 activerecord/lib/active_record/validations.rb
  58. 0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  59. +1 −1 activerecord/test/cases/associations/has_many_associations_test.rb
  60. +6 −3 activerecord/test/cases/associations/has_many_through_associations_test.rb
  61. 0 activerecord/test/cases/associations/has_one_associations_test.rb
  62. 0 activerecord/test/cases/associations_test.rb
  63. 0 activerecord/test/cases/attribute_methods_test.rb
  64. +8 −0 activerecord/test/cases/base_test.rb
  65. 0 activerecord/test/cases/deprecated_finder_test.rb
  66. 0 activerecord/test/cases/fixtures_test.rb
  67. 0 activerecord/test/cases/inheritance_test.rb
  68. 0 activerecord/test/cases/lifecycle_test.rb
  69. 0 activerecord/test/cases/readonly_test.rb
  70. 0 activerecord/test/cases/unconnected_test.rb
  71. 0 activerecord/test/cases/validations_test.rb
  72. 0 activerecord/test/models/company.rb
  73. 0 activerecord/test/models/reply.rb
  74. 0 activerecord/test/models/topic.rb
  75. +1 −1 activesupport/lib/active_support/basic_object.rb
  76. +9 −13 activesupport/lib/active_support/buffered_logger.rb
  77. +5 −5 activesupport/lib/active_support/core_ext/array/grouping.rb
  78. +3 −4 activesupport/lib/active_support/memoizable.rb
  79. 0 activesupport/lib/active_support/multibyte/generators/generate_tables.rb
  80. +2 −2 activesupport/lib/active_support/testing/performance.rb
  81. +2 −0 railties/CHANGELOG
  82. 0 railties/bin/about
  83. 0 railties/bin/console
  84. 0 railties/bin/destroy
  85. 0 railties/bin/generate
  86. 0 railties/bin/performance/benchmarker
  87. 0 railties/bin/performance/profiler
  88. 0 railties/bin/performance/request
  89. 0 railties/bin/plugin
  90. 0 railties/bin/process/inspector
  91. 0 railties/bin/process/reaper
  92. 0 railties/bin/process/spawner
  93. 0 railties/bin/runner
  94. 0 railties/bin/server
  95. 0 railties/configs/apache.conf
  96. +1 −1 railties/dispatches/dispatch.fcgi
  97. +2 −2 railties/dispatches/dispatch.rb
  98. +2 −2 railties/dispatches/gateway.cgi
  99. +2 −0 railties/lib/commands/dbconsole.rb
  100. +2 −2 railties/lib/commands/ncgi/listener
  101. +2 −2 railties/lib/commands/ncgi/tracker
  102. +6 −4 railties/lib/initializer.rb
  103. 0 railties/lib/rails_generator/generators/components/plugin/templates/Rakefile
View
0 actionmailer/README 100755 → 100644
No changes.
View
0 actionmailer/Rakefile 100755 → 100644
No changes.
View
0 actionmailer/lib/action_mailer.rb 100755 → 100644
No changes.
@@ -250,7 +250,7 @@ class Base
private_class_method :new #:nodoc:
- class_inheritable_accessor :template_root
+ class_inheritable_accessor :view_paths
cattr_accessor :logger
cattr_accessor :template_extensions
@@ -425,9 +425,12 @@ def register_template_extension(extension)
template_extensions << extension
end
+ def template_root
+ self.view_paths && self.view_paths.first
+ end
+
def template_root=(root)
- root = ActionView::PathSet::Path.new(root) if root.is_a?(String)
- write_inheritable_attribute(:template_root, root)
+ self.view_paths = ActionView::Base.process_view_paths(root)
end
end
@@ -541,12 +544,20 @@ def render(opts)
initialize_template_class(body).render(opts)
end
+ def template_root
+ self.class.template_root
+ end
+
+ def template_root=(root)
+ self.class.template_root = root
+ end
+
def template_path
"#{template_root}/#{mailer_name}"
end
def initialize_template_class(assigns)
- ActionView::Base.new(template_root, assigns, self)
+ ActionView::Base.new(view_paths, assigns, self)
end
def sort_parts(parts, order = [])
View
No changes.
View
@@ -1,5 +1,7 @@
*Edge*
+* Added back ActionController::Base.allow_concurrency flag [Josh Peek]
+
* AbstractRequest.relative_url_root is no longer automatically configured by a HTTP header. It can now be set in your configuration environment with config.action_controller.relative_url_root [Josh Peek]
* Update Prototype to 1.6.0.2 #599 [Patrick Joyce]
View
No changes.
@@ -2,7 +2,7 @@ module ActionController
module Assertions
# Suite of assertions to test routes generated by Rails and the handling of requests made to them.
module RoutingAssertions
- # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
+ # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
# match +path+. Basically, it asserts that Rails recognizes the route given by +expected_options+.
#
# Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
@@ -14,16 +14,16 @@ module RoutingAssertions
#
# You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
# to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
- # extras argument, appending the query string on the path directly will not work. For example:
+ # extras argument, appending the query string on the path directly will not work. For example:
#
# # assert that a path of '/items/list/1?view=print' returns the correct options
- # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
+ # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
#
- # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
+ # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
#
# ==== Examples
# # Check the default route (i.e., the index action)
- # assert_recognizes({:controller => 'items', :action => 'index'}, 'items')
+ # assert_recognizes({:controller => 'items', :action => 'index'}, 'items')
#
# # Test a specific action
# assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list')
@@ -44,16 +44,16 @@ def assert_recognizes(expected_options, path, extras={}, message=nil)
request_method = nil
end
- clean_backtrace do
- ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
+ clean_backtrace do
+ ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
request = recognized_request_for(path, request_method)
-
+
expected_options = expected_options.clone
extras.each_key { |key| expected_options.delete key } unless extras.nil?
-
+
expected_options.stringify_keys!
routing_diff = expected_options.diff(request.path_parameters)
- msg = build_message(message, "The recognized options <?> did not match <?>, difference: <?>",
+ msg = build_message(message, "The recognized options <?> did not match <?>, difference: <?>",
request.path_parameters, expected_options, expected_options.diff(request.path_parameters))
assert_block(msg) { request.path_parameters == expected_options }
end
@@ -64,7 +64,7 @@ def assert_recognizes(expected_options, path, extras={}, message=nil)
# a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
#
# The +defaults+ parameter is unused.
- #
+ #
# ==== Examples
# # Asserts that the default action is generated for a route with no action
# assert_generates("/items", :controller => "items", :action => "index")
@@ -73,34 +73,34 @@ def assert_recognizes(expected_options, path, extras={}, message=nil)
# assert_generates("/items/list", :controller => "items", :action => "list")
#
# # Tests the generation of a route with a parameter
- # assert_generates("/items/list/1", { :controller => "items", :action => "list", :id => "1" })
+ # assert_generates("/items/list/1", { :controller => "items", :action => "list", :id => "1" })
#
# # Asserts that the generated route gives us our custom route
# assert_generates "changesets/12", { :controller => 'scm', :action => 'show_diff', :revision => "12" }
def assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
- clean_backtrace do
+ clean_backtrace do
expected_path = "/#{expected_path}" unless expected_path[0] == ?/
# Load routes.rb if it hasn't been loaded.
- ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
-
+ ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
+
generated_path, extra_keys = ActionController::Routing::Routes.generate_extras(options, defaults)
found_extras = options.reject {|k, v| ! extra_keys.include? k}
msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
assert_block(msg) { found_extras == extras }
-
- msg = build_message(message, "The generated path <?> did not match <?>", generated_path,
+
+ msg = build_message(message, "The generated path <?> did not match <?>", generated_path,
expected_path)
assert_block(msg) { expected_path == generated_path }
end
end
- # Asserts that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
+ # Asserts that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
# <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines +assert_recognizes+
# and +assert_generates+ into one step.
#
# The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
- # +message+ parameter allows you to specify a custom error message to display upon failure.
+ # +message+ parameter allows you to specify a custom error message to display upon failure.
#
# ==== Examples
# # Assert a basic route: a controller with the default action (index)
@@ -119,12 +119,12 @@ def assert_generates(expected_path, options, defaults={}, extras = {}, message=n
# assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" })
def assert_routing(path, options, defaults={}, extras={}, message=nil)
assert_recognizes(options, path, extras, message)
-
- controller, default_controller = options[:controller], defaults[:controller]
+
+ controller, default_controller = options[:controller], defaults[:controller]
if controller && controller.include?(?/) && default_controller && default_controller.include?(?/)
options[:controller] = "/#{controller}"
end
-
+
assert_generates(path.is_a?(Hash) ? path[:path] : path, options, defaults, extras, message)
end
@@ -407,6 +407,7 @@ def assert_select_rjs(*args, &block)
if rjs_type == :insert
arg = args.shift
+ position = arg
insertion = "insert_#{arg}".to_sym
raise ArgumentError, "Unknown RJS insertion type #{arg}" unless RJS_STATEMENTS[insertion]
statement = "(#{RJS_STATEMENTS[insertion]})"
@@ -418,6 +419,7 @@ def assert_select_rjs(*args, &block)
else
statement = "#{RJS_STATEMENTS[:any]}"
end
+ position ||= Regexp.new(RJS_INSERTIONS.join('|'))
# Next argument we're looking for is the element identifier. If missing, we pick
# any element.
@@ -434,9 +436,14 @@ def assert_select_rjs(*args, &block)
Regexp.new("\\$\\(\"#{id}\"\\)#{statement}\\(#{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
when :remove, :show, :hide, :toggle
Regexp.new("#{statement}\\(\"#{id}\"\\)")
- else
- Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
- end
+ when :replace, :replace_html
+ Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)")
+ when :insert, :insert_html
+ Regexp.new("Element.insert\\(\\\"#{id}\\\", \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);")
+ else
+ Regexp.union(Regexp.new("#{statement}\\(\"#{id}\", #{RJS_PATTERN_HTML}\\)"),
+ Regexp.new("Element.insert\\(\\\"#{id}\\\", \\{ #{position}: #{RJS_PATTERN_HTML} \\}\\);"))
+ end
# Duplicate the body since the next step involves destroying it.
matches = nil
@@ -445,7 +452,7 @@ def assert_select_rjs(*args, &block)
matches = @response.body.match(pattern)
else
@response.body.gsub(pattern) do |match|
- html = unescape_rjs($2)
+ html = unescape_rjs(match)
matches ||= []
matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? }
""
@@ -585,17 +592,16 @@ def assert_select_email(&block)
:hide => /Element\.hide/,
:toggle => /Element\.toggle/
}
+ RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
+ RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
RJS_INSERTIONS = [:top, :bottom, :before, :after]
RJS_INSERTIONS.each do |insertion|
- RJS_STATEMENTS["insert_#{insertion}".to_sym] = Regexp.new(Regexp.quote("new Insertion.#{insertion.to_s.camelize}"))
+ RJS_STATEMENTS["insert_#{insertion}".to_sym] = /Element.insert\(\"([^\"]*)\", \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/
end
- RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
RJS_STATEMENTS[:insert_html] = Regexp.new(RJS_INSERTIONS.collect do |insertion|
- Regexp.quote("new Insertion.#{insertion.to_s.camelize}")
+ /Element.insert\(\"([^\"]*)\", \{ #{insertion.to_s.downcase}: #{RJS_PATTERN_HTML} \}\);/
end.join('|'))
- RJS_PATTERN_HTML = /"((\\"|[^"])*)"/
- RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)",
- Regexp::MULTILINE)
+ RJS_PATTERN_EVERYTHING = Regexp.new("#{RJS_STATEMENTS[:any]}\\(\"([^\"]*)\", #{RJS_PATTERN_HTML}\\)", Regexp::MULTILINE)
RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
end
View
@@ -283,6 +283,14 @@ class Base
@@debug_routes = true
cattr_accessor :debug_routes
+ # Indicates whether to allow concurrent action processing. Your
+ # controller actions and any other code they call must also behave well
+ # when called from concurrent threads. Turned off by default.
+ @@allow_concurrency = false
+ cattr_accessor :allow_concurrency
+
+ @@guard = Monitor.new
+
# Modern REST web services often need to submit complex data to the web application.
# The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the
# <tt>params</tt> hash. These handlers are invoked for POST and PUT requests.
@@ -537,7 +545,12 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc:
forget_variables_added_to_assigns
log_processing
- send(method, *arguments)
+
+ if @@allow_concurrency
+ send(method, *arguments)
+ else
+ @@guard.synchronize { send(method, *arguments) }
+ end
assign_default_content_type_and_charset
response.prepare! unless component_request?
@@ -1195,7 +1208,7 @@ def perform_action
elsif template_exists? && template_public?
default_render
else
- raise UnknownAction, "No action responded to #{action_name}", caller
+ raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.to_a.sort.to_sentence}", caller
end
end
@@ -2,8 +2,6 @@ module ActionController
# Dispatches requests to the appropriate controller and takes care of
# reloading the app after each request when Dependencies.load? is true.
class Dispatcher
- @@guard = Mutex.new
-
class << self
def define_dispatcher_callbacks(cache_classes)
unless cache_classes
@@ -101,15 +99,13 @@ def initialize(output = $stdout, request = nil, response = nil)
end
def dispatch
- @@guard.synchronize do
- begin
- run_callbacks :before_dispatch
- handle_request
- rescue Exception => exception
- failsafe_rescue exception
- ensure
- run_callbacks :after_dispatch, :enumerator => :reverse_each
- end
+ begin
+ run_callbacks :before_dispatch
+ handle_request
+ rescue Exception => exception
+ failsafe_rescue exception
+ ensure
+ run_callbacks :after_dispatch, :enumerator => :reverse_each
end
end
@@ -507,7 +507,7 @@ def copy_session_variables! #:nodoc:
# Delegate unhandled messages to the current session instance.
def method_missing(sym, *args, &block)
reset! unless @integration_session
- returning @integration_session.send!(sym, *args, &block) do
+ returning @integration_session.__send__(sym, *args, &block) do
copy_session_variables!
end
end
View
No changes.
No changes.
View
No changes.
Oops, something went wrong.

0 comments on commit f6124c2

Please sign in to comment.