Permalink
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
2 parents d0a2b84 + c19c0e7 commit 6d1be5f1eb83fb693ffd00e1967c1b3ca1c9ece3 @lifo lifo committed Sep 10, 2008
Showing with 640 additions and 333 deletions.
  1. +1 −1 actionmailer/lib/action_mailer/base.rb
  2. +10 −0 actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~
  3. +6 −0 actionpack/CHANGELOG
  4. +8 −6 actionpack/Rakefile
  5. +2 −0 actionpack/lib/action_controller.rb
  6. +6 −2 actionpack/lib/action_controller/base.rb
  7. +2 −1 actionpack/lib/action_controller/benchmarking.rb
  8. +22 −0 actionpack/lib/action_controller/routing/recognition_optimisation.rb
  9. +2 −2 actionpack/lib/action_controller/routing/route_set.rb
  10. +13 −0 actionpack/lib/action_controller/translation.rb
  11. +6 −4 actionpack/lib/action_view/base.rb
  12. +17 −10 actionpack/lib/action_view/helpers/form_tag_helper.rb
  13. +8 −11 actionpack/lib/action_view/renderable.rb
  14. +10 −8 actionpack/lib/action_view/renderable_partial.rb
  15. +30 −0 actionpack/test/controller/routing_test.rb
  16. +26 −0 actionpack/test/controller/translation_test.rb
  17. +9 −2 actionpack/test/template/form_tag_helper_test.rb
  18. +4 −18 activerecord/CHANGELOG
  19. +108 −36 activerecord/lib/active_record/aggregations.rb
  20. +31 −33 activerecord/lib/active_record/associations.rb
  21. +4 −8 activerecord/lib/active_record/associations/association_collection.rb
  22. +2 −2 activerecord/lib/active_record/associations/belongs_to_association.rb
  23. +5 −4 activerecord/lib/active_record/associations/has_many_through_association.rb
  24. +12 −4 activerecord/lib/active_record/associations/has_one_association.rb
  25. +19 −4 activerecord/lib/active_record/base.rb
  26. +1 −1 activerecord/lib/active_record/calculations.rb
  27. +4 −0 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  28. +4 −0 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  29. +2 −1 activerecord/lib/active_record/dynamic_finder_match.rb
  30. +35 −0 activerecord/lib/active_record/reflection.rb
  31. +35 −0 activerecord/test/cases/aggregations_test.rb
  32. +0 −108 activerecord/test/cases/associations_test.rb
  33. +15 −4 activerecord/test/cases/base_test.rb
  34. +36 −4 activerecord/test/cases/finder_test.rb
  35. +10 −1 activerecord/test/fixtures/customers.yml
  36. +2 −1 activerecord/test/models/author.rb
  37. +19 −1 activerecord/test/models/customer.rb
  38. +0 −6 activerecord/test/models/post.rb
  39. +2 −0 activesupport/CHANGELOG
  40. +1 −1 activesupport/lib/active_support/cache/file_store.rb
  41. +1 −1 activesupport/lib/active_support/callbacks.rb
  42. +18 −22 activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb
  43. +2 −2 activesupport/lib/active_support/core_ext/enumerable.rb
  44. +1 −1 activesupport/lib/active_support/core_ext/hash/conversions.rb
  45. +6 −3 activesupport/lib/active_support/core_ext/module/synchronization.rb
  46. +2 −1 activesupport/lib/active_support/core_ext/rexml.rb
  47. +19 −0 activesupport/lib/active_support/core_ext/string/inflections.rb
  48. +19 −0 activesupport/lib/active_support/inflector.rb
  49. +1 −1 activesupport/lib/active_support/memoizable.rb
  50. +6 −0 activesupport/test/inflector_test.rb
  51. +5 −0 activesupport/test/inflector_test_cases.rb
  52. +2 −0 railties/CHANGELOG
  53. +9 −9 railties/lib/commands/plugin.rb
  54. +2 −2 railties/lib/commands/process/spawner.rb
  55. +0 −1 railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb
  56. +18 −6 railties/lib/tasks/databases.rake
@@ -466,7 +466,7 @@ def create!(method_name, *parameters) #:nodoc:
template = template_root["#{mailer_name}/#{File.basename(path)}"]
# Skip unless template has a multipart format
- next unless template.multipart?
+ next unless template && template.multipart?
@parts << Part.new(
:content_type => template.content_type,
@@ -0,0 +1,10 @@
+<html>
+ <body>
+ HTML formatted message to <strong><%= @recipient %></strong>.
+ </body>
+</html>
+<html>
+ <body>
+ HTML formatted message to <strong><%= @recipient %></strong>.
+ </body>
+</html>
@@ -1,5 +1,11 @@
*Edge*
+* Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton]
+
+* Fixed FormTagHelper#submit_tag with :disable_with option wouldn't submit the button's value when was clicked #633 [Jose Fernandez]
+
+* Stopped logging template compiles as it only clogs up the log [DHH]
+
* Changed the X-Runtime header to report in milliseconds [DHH]
* Changed BenchmarkHelper#benchmark to report in milliseconds [DHH]
View
@@ -25,14 +25,16 @@ task :default => [ :test ]
desc "Run all unit tests"
task :test => [:test_action_pack, :test_active_record_integration]
-Rake::TestTask.new(:test_action_pack) { |t|
+Rake::TestTask.new(:test_action_pack) do |t|
t.libs << "test"
-# make sure we include the tests in alphabetical order as on some systems
-# this will not happen automatically and the tests (as a whole) will error
- t.test_files=Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
-# t.pattern = 'test/*/*_test.rb'
+
+ # make sure we include the tests in alphabetical order as on some systems
+ # this will not happen automatically and the tests (as a whole) will error
+ t.test_files = Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
+
t.verbose = true
-}
+ #t.warning = true
+end
desc 'ActiveRecord Integration Tests'
Rake::TestTask.new(:test_active_record_integration) do |t|
@@ -54,6 +54,7 @@
require 'action_controller/record_identifier'
require 'action_controller/request_forgery_protection'
require 'action_controller/headers'
+require 'action_controller/translation'
require 'action_view'
@@ -74,4 +75,5 @@
include ActionController::Components
include ActionController::RecordIdentifier
include ActionController::RequestForgeryProtection
+ include ActionController::Translation
end
@@ -434,7 +434,11 @@ def hide_action(*names)
# render("test/template") will be looked up in the view load paths array and the closest match will be
# returned.
def view_paths
- @view_paths || superclass.view_paths
+ if defined? @view_paths
+ @view_paths
+ else
+ superclass.view_paths
+ end
end
def view_paths=(value)
@@ -449,7 +453,7 @@ def view_paths=(value)
# ArticleController.prepend_view_path(["views/default", "views/custom"])
#
def prepend_view_path(path)
- @view_paths = superclass.view_paths.dup if @view_paths.nil?
+ @view_paths = superclass.view_paths.dup if !defined?(@view_paths) || @view_paths.nil?
@view_paths.unshift(*path)
end
@@ -76,7 +76,8 @@ def perform_action_with_benchmark
log_message << view_runtime if logging_view
if logging_active_record
- log_message << ", " + active_record_runtime + ")"
+ log_message << ", " if logging_view
+ log_message << active_record_runtime + ")"
else
")"
end
@@ -134,6 +134,9 @@ def to_plain_segments(str)
def write_recognize_optimized!
tree = segment_tree(routes)
body = generate_code(tree)
+
+ remove_recognize_optimized!
+
instance_eval %{
def recognize_optimized(path, env)
segments = to_plain_segments(path)
@@ -147,6 +150,25 @@ def recognize_optimized(path, env)
end
}, __FILE__, __LINE__
end
+
+ def clear_recognize_optimized!
+ remove_recognize_optimized!
+
+ class << self
+ def recognize_optimized(path, environment)
+ write_recognize_optimized!
+ recognize_optimized(path, environment)
+ end
+ end
+ end
+
+ def remove_recognize_optimized!
+ if respond_to?(:recognize_optimized)
+ class << self
+ remove_method :recognize_optimized
+ end
+ end
+ end
end
end
end
@@ -195,7 +195,7 @@ def initialize
self.routes = []
self.named_routes = NamedRouteCollection.new
- write_recognize_optimized!
+ clear_recognize_optimized!
end
# Subclasses and plugins may override this method to specify a different
@@ -217,7 +217,7 @@ def clear!
@routes_by_controller = nil
# This will force routing/recognition_optimization.rb
# to refresh optimisations.
- @compiled_recognize_optimized = nil
+ clear_recognize_optimized!
end
def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)
@@ -0,0 +1,13 @@
+module ActionController
+ module Translation
+ def translate(*args)
+ I18n.translate *args
+ end
+ alias :t :translate
+
+ def localize(*args)
+ I18n.localize *args
+ end
+ alias :l :localize
+ end
+end
@@ -278,9 +278,9 @@ def render(options = {}, local_assigns = {}, &block) #:nodoc:
# the same name but differing formats. See +Request#template_format+
# for more details.
def template_format
- return @template_format if @template_format
-
- if controller && controller.respond_to?(:request)
+ if defined? @template_format
+ @template_format
+ elsif controller && controller.respond_to?(:request)
@template_format = controller.request.template_format
else
@template_format = :html
@@ -366,7 +366,9 @@ def _render_with_layout(options, local_assigns, &block) #:nodoc:
end
else
begin
- original_content_for_layout, @content_for_layout = @content_for_layout, render(options)
+ original_content_for_layout = @content_for_layout if defined?(@content_for_layout)
+ @content_for_layout = render(options)
+
if (options[:inline] || options[:file] || options[:text])
@cached_content_for_layout = @content_for_layout
render(:file => partial_layout, :locals => local_assigns)
@@ -116,7 +116,7 @@ def text_field_tag(name, value = nil, options = {})
# Creates a label field
#
- # ==== Options
+ # ==== Options
# * Creates standard HTML attributes for the tag.
#
# ==== Examples
@@ -351,19 +351,16 @@ def submit_tag(value = "Save changes", options = {})
disable_with = "this.value='#{disable_with}'"
disable_with << ";#{options.delete('onclick')}" if options['onclick']
- options["onclick"] = [
- "this.setAttribute('originalValue', this.value)",
- "this.disabled=true",
- disable_with,
- "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())",
- "if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false }",
- "return result;",
- ].join(";")
+ options["onclick"] = "if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }"
+ options["onclick"] << "else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }"
+ options["onclick"] << "this.setAttribute('originalValue', this.value);this.disabled = true;#{disable_with};"
+ options["onclick"] << "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());"
+ options["onclick"] << "if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;"
end
if confirm = options.delete("confirm")
options["onclick"] ||= ''
- options["onclick"] += "return #{confirm_javascript_function(confirm)};"
+ options["onclick"] << "return #{confirm_javascript_function(confirm)};"
end
tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
@@ -374,6 +371,9 @@ def submit_tag(value = "Save changes", options = {})
# <tt>source</tt> is passed to AssetTagHelper#image_path
#
# ==== Options
+ # * <tt>:confirm => 'question?'</tt> - This will add a JavaScript confirm
+ # prompt with the question specified. If the user accepts, the form is
+ # processed normally, otherwise no action is taken.
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
# * Any other key creates standard HTML options for the tag.
#
@@ -390,6 +390,13 @@ def submit_tag(value = "Save changes", options = {})
# image_submit_tag("agree.png", :disabled => true, :class => "agree-disagree-button")
# # => <input class="agree-disagree-button" disabled="disabled" src="/images/agree.png" type="image" />
def image_submit_tag(source, options = {})
+ options.stringify_keys!
+
+ if confirm = options.delete("confirm")
+ options["onclick"] ||= ''
+ options["onclick"] += "return #{confirm_javascript_function(confirm)};"
+ end
+
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
end
@@ -1,8 +1,7 @@
module ActionView
- module Renderable
- # NOTE: The template that this mixin is beening include into is frozen
- # So you can not set or modify any instance variables
-
+ # NOTE: The template that this mixin is being included into is frozen
+ # so you cannot set or modify any instance variables
+ module Renderable #:nodoc:
extend ActiveSupport::Memoizable
def self.included(base)
@@ -33,10 +32,11 @@ def render(view, local_assigns = {})
view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
view.send(method_name(local_assigns), local_assigns) do |*names|
- if proc = view.instance_variable_get("@_proc_for_layout")
+ ivar = :@_proc_for_layout
+ if view.instance_variable_defined?(ivar) and proc = view.instance_variable_get(ivar)
view.capture(*names, &proc)
- else
- view.instance_variable_get("@content_for_#{names.first || 'layout'}")
+ elsif view.instance_variable_defined?(ivar = :"@content_for_#{names.first || :layout}")
+ view.instance_variable_get(ivar)
end
end
end
@@ -72,12 +72,9 @@ def #{render_symbol}(local_assigns)
end_src
begin
- logger = defined?(ActionController) && Base.logger
- logger.debug "Compiling template #{render_symbol}" if logger
-
ActionView::Base::CompiledTemplates.module_eval(source, filename, 0)
rescue Exception => e # errors from template code
- if logger
+ if logger = defined?(ActionController) && Base.logger
logger.debug "ERROR: compiling #{render_symbol} RAISED #{e}"
logger.debug "Function body: #{source}"
logger.debug "Backtrace: #{e.backtrace.join("\n")}"
@@ -1,8 +1,7 @@
module ActionView
- module RenderablePartial
- # NOTE: The template that this mixin is beening include into is frozen
- # So you can not set or modify any instance variables
-
+ # NOTE: The template that this mixin is being included into is frozen
+ # so you cannot set or modify any instance variables
+ module RenderablePartial #:nodoc:
extend ActiveSupport::Memoizable
def variable_name
@@ -30,10 +29,13 @@ def render_partial(view, object = nil, local_assigns = {}, as = nil)
local_assigns[variable_name]
if view.respond_to?(:controller)
- object ||= ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
- view.controller.instance_variable_get("@#{variable_name}"),
- "@#{variable_name} will no longer be implicitly assigned to #{variable_name}"
- )
+ ivar = :"@#{variable_name}"
+ object ||=
+ if view.controller.instance_variable_defined?(ivar)
+ ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
+ view.controller.instance_variable_get(ivar),
+ "#{ivar} will no longer be implicitly assigned to #{variable_name}")
+ end
end
# Ensure correct object is reassigned to other accessors
@@ -1375,6 +1375,36 @@ def test_failed_requirements_raises_exception_with_violated_requirements
x.send(:foo_with_requirement_url, "I am Against the requirements")
end
end
+
+ def test_routes_changed_correctly_after_clear
+ ActionController::Base.optimise_named_routes = true
+ rs = ::ActionController::Routing::RouteSet.new
+ rs.draw do |r|
+ r.connect 'ca', :controller => 'ca', :action => "aa"
+ r.connect 'cb', :controller => 'cb', :action => "ab"
+ r.connect 'cc', :controller => 'cc', :action => "ac"
+ r.connect ':controller/:action/:id'
+ r.connect ':controller/:action/:id.:format'
+ end
+
+ hash = rs.recognize_path "/cc"
+
+ assert_not_nil hash
+ assert_equal %w(cc ac), [hash[:controller], hash[:action]]
+
+ rs.draw do |r|
+ r.connect 'cb', :controller => 'cb', :action => "ab"
+ r.connect 'cc', :controller => 'cc', :action => "ac"
+ r.connect ':controller/:action/:id'
+ r.connect ':controller/:action/:id.:format'
+ end
+
+ hash = rs.recognize_path "/cc"
+
+ assert_not_nil hash
+ assert_equal %w(cc ac), [hash[:controller], hash[:action]]
+
+ end
end
class RouteTest < Test::Unit::TestCase
@@ -0,0 +1,26 @@
+require 'abstract_unit'
+
+# class TranslatingController < ActionController::Base
+# end
+
+class TranslationControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = ActionController::Base.new
+ end
+
+ def test_action_controller_base_responds_to_translate
+ assert @controller.respond_to?(:translate)
+ end
+
+ def test_action_controller_base_responds_to_t
+ assert @controller.respond_to?(:t)
+ end
+
+ def test_action_controller_base_responds_to_localize
+ assert @controller.respond_to?(:localize)
+ end
+
+ def test_action_controller_base_responds_to_l
+ assert @controller.respond_to?(:l)
+ end
+end
Oops, something went wrong. Retry.

0 comments on commit 6d1be5f

Please sign in to comment.