aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/Rakefile19
-rw-r--r--actionpack/lib/abstract_controller/logger.rb14
-rw-r--r--actionpack/lib/action_controller/dispatch/middlewares.rb10
-rw-r--r--actionpack/lib/action_controller/metal.rb2
-rw-r--r--actionpack/lib/action_controller/metal/rescuable.rb45
-rw-r--r--actionpack/lib/action_dispatch.rb8
-rw-r--r--actionpack/lib/action_dispatch/middleware/rescue.rb20
-rw-r--r--actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb4
-rw-r--r--actionpack/lib/action_view.rb13
-rw-r--r--actionpack/lib/action_view/template/inline.rb19
-rw-r--r--actionpack/lib/action_view/template/partial.rb18
-rw-r--r--actionpack/lib/action_view/template/renderable.rb93
-rw-r--r--actionpack/test/abstract/abstract_controller_test.rb (renamed from actionpack/test/abstract_controller/abstract_controller_test.rb)2
-rw-r--r--actionpack/test/abstract/callbacks_test.rb (renamed from actionpack/test/abstract_controller/callbacks_test.rb)2
-rw-r--r--actionpack/test/abstract/helper_test.rb (renamed from actionpack/test/abstract_controller/helper_test.rb)2
-rw-r--r--actionpack/test/abstract/layouts_test.rb (renamed from actionpack/test/abstract_controller/layouts_test.rb)2
-rw-r--r--actionpack/test/abstract/views/abstract_controller/testing/me3/formatted.html.erb (renamed from actionpack/test/abstract_controller/views/abstract_controller/testing/me3/formatted.html.erb)0
-rw-r--r--actionpack/test/abstract/views/abstract_controller/testing/me3/index.erb (renamed from actionpack/test/abstract_controller/views/abstract_controller/testing/me3/index.erb)0
-rw-r--r--actionpack/test/abstract/views/abstract_controller/testing/me4/index.erb (renamed from actionpack/test/abstract_controller/views/abstract_controller/testing/me4/index.erb)0
-rw-r--r--actionpack/test/abstract/views/abstract_controller/testing/me5/index.erb (renamed from actionpack/test/abstract_controller/views/abstract_controller/testing/me5/index.erb)0
-rw-r--r--actionpack/test/abstract/views/action_with_ivars.erb (renamed from actionpack/test/abstract_controller/views/action_with_ivars.erb)0
-rw-r--r--actionpack/test/abstract/views/helper_test.erb (renamed from actionpack/test/abstract_controller/views/helper_test.erb)0
-rw-r--r--actionpack/test/abstract/views/index.erb (renamed from actionpack/test/abstract_controller/views/index.erb)0
-rw-r--r--actionpack/test/abstract/views/layouts/abstract_controller/testing/me4.erb (renamed from actionpack/test/abstract_controller/views/layouts/abstract_controller/testing/me4.erb)0
-rw-r--r--actionpack/test/abstract/views/layouts/application.erb (renamed from actionpack/test/abstract_controller/views/layouts/application.erb)0
-rw-r--r--actionpack/test/abstract/views/naked_render.erb (renamed from actionpack/test/abstract_controller/views/naked_render.erb)0
-rw-r--r--actionpack/test/abstract_unit.rb88
-rw-r--r--actionpack/test/abstract_unit2.rb119
-rw-r--r--actionpack/test/bundler_helper.rb10
-rw-r--r--actionpack/test/controller/caching_test.rb4
-rw-r--r--actionpack/test/controller/content_type_test.rb15
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/render_js_test.rb38
-rw-r--r--actionpack/test/controller/render_json_test.rb58
-rw-r--r--actionpack/test/controller/render_other_test.rb251
-rw-r--r--actionpack/test/controller/render_xml_test.rb68
-rw-r--r--actionpack/test/controller/rescue_test.rb29
-rw-r--r--actionpack/test/dispatch/show_exceptions_test.rb3
-rw-r--r--actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb (renamed from actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.xml.erb)0
-rw-r--r--actionpack/test/fixtures/old_content_type/render_default_for_rhtml.rhtml (renamed from actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml)0
-rw-r--r--actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs (renamed from actionpack/test/fixtures/content_type/render_default_for_rjs.rjs)0
-rw-r--r--actionpack/test/fixtures/old_content_type/render_default_for_rxml.rxml (renamed from actionpack/test/fixtures/content_type/render_default_for_rxml.rxml)0
-rw-r--r--actionpack/test/new_base/base_test.rb2
-rw-r--r--actionpack/test/new_base/content_negotiation_test.rb2
-rw-r--r--actionpack/test/new_base/content_type_test.rb2
-rw-r--r--actionpack/test/new_base/etag_test.rb2
-rw-r--r--actionpack/test/new_base/metal_test.rb2
-rw-r--r--actionpack/test/new_base/middleware_test.rb2
-rw-r--r--actionpack/test/new_base/render_action_test.rb2
-rw-r--r--actionpack/test/new_base/render_file_test.rb2
-rw-r--r--actionpack/test/new_base/render_implicit_action_test.rb2
-rw-r--r--actionpack/test/new_base/render_layout_test.rb2
-rw-r--r--actionpack/test/new_base/render_partial_test.rb2
-rw-r--r--actionpack/test/new_base/render_rjs_test.rb13
-rw-r--r--actionpack/test/new_base/render_template_test.rb2
-rw-r--r--actionpack/test/new_base/render_test.rb2
-rw-r--r--actionpack/test/new_base/render_text_test.rb2
-rw-r--r--actionpack/test/new_base/render_xml_test.rb2
-rw-r--r--actionpack/test/template/render_test.rb14
-rw-r--r--activemodel/examples/validations.rb2
-rw-r--r--activemodel/lib/active_model/errors.rb2
-rw-r--r--activemodel/lib/active_model/lint.rb7
-rwxr-xr-xactiverecord/lib/active_record/base.rb48
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb5
-rw-r--r--activerecord/test/cases/connection_test_mysql.rb8
-rw-r--r--activerecord/test/schema/mysql_specific_schema.rb12
-rw-r--r--activeresource/lib/active_resource/validations.rb4
-rw-r--r--activeresource/test/cases/base_errors_test.rb4
-rw-r--r--activesupport/lib/active_support/mini.rb9
-rw-r--r--activesupport/lib/active_support/xml_mini/nokogiri.rb34
-rw-r--r--activesupport/test/xml_mini/nokogiri_engine_test.rb11
-rwxr-xr-xci/ci_build.rb2
-rw-r--r--railties/lib/generators.rb24
-rw-r--r--railties/lib/generators/base.rb1
-rw-r--r--railties/test/generators/generators_test_helper.rb6
-rw-r--r--railties/test/initializer/test_helper.rb12
76 files changed, 498 insertions, 708 deletions
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 0d8362ad0b..cc7b4b0043 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -32,24 +32,24 @@ end
# Run the unit tests
desc "Run all unit tests"
-task :test => [:test_action_pack, :test_active_record_integration, :test_new_base]
+task :test => [:test_action_pack, :test_active_record_integration]
+
+TESTS_GLOB = "test/{abstract,controller,dispatch,new_base,template,html-scanner}/**/*_test.rb"
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/{controller,dispatch,template,html-scanner}/**/*_test.rb" ).sort
+ t.test_files = Dir.glob(TESTS_GLOB).sort
t.verbose = true
- #t.warning = true
+ # t.warning = true
end
task :isolated_test do
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
- Dir.glob("test/{controller,dispatch,template}/**/*_test.rb").all? do |file|
- system(ruby, "-Itest", file)
- end or raise "Failures"
+ Dir.glob(TESTS_GLOB).all? { |file| system(ruby, '-Ilib:test', file) } or raise "Failures"
end
desc 'ActiveRecord Integration Tests'
@@ -59,13 +59,6 @@ Rake::TestTask.new(:test_active_record_integration) do |t|
t.verbose = true
end
-desc 'New Controller Tests'
-Rake::TestTask.new(:test_new_base) do |t|
- t.libs << 'test'
- t.test_files = Dir.glob("test/{abstract_controller,new_base}/*_test.rb")
- t.verbose = true
-end
-
# Genereate the RDoc documentation
Rake::RDocTask.new { |rdoc|
diff --git a/actionpack/lib/abstract_controller/logger.rb b/actionpack/lib/abstract_controller/logger.rb
index 1b879b963b..06b64d5cb2 100644
--- a/actionpack/lib/abstract_controller/logger.rb
+++ b/actionpack/lib/abstract_controller/logger.rb
@@ -11,15 +11,17 @@ module AbstractController
# just discard the String if the log level is too low.
#
# TODO: Require that Rails loggers accept a block.
- class DelayedLog
- def initialize(&blk)
- @blk = blk
+ class DelayedLog < ActiveSupport::BasicObject
+ def initialize(&block)
+ @str, @block = nil, block
end
- def to_s
- @blk.call
+ def method_missing(*args, &block)
+ unless @str
+ @str, @block = @block.call, nil
+ end
+ @str.send(*args, &block)
end
- alias to_str to_s
end
included do
diff --git a/actionpack/lib/action_controller/dispatch/middlewares.rb b/actionpack/lib/action_controller/dispatch/middlewares.rb
index b25ed3fd3f..5641b3cb8d 100644
--- a/actionpack/lib/action_controller/dispatch/middlewares.rb
+++ b/actionpack/lib/action_controller/dispatch/middlewares.rb
@@ -4,15 +4,13 @@ use "Rack::Lock", :if => lambda {
use "ActionDispatch::ShowExceptions", lambda { ActionController::Base.consider_all_requests_local }
use "ActionDispatch::Callbacks", lambda { ActionController::Dispatcher.prepare_each_request }
-use "ActionDispatch::Rescue", lambda {
- controller = (::ApplicationController rescue ActionController::Base)
- # TODO: Replace with controller.action(:_rescue_action)
- controller.method(:rescue_action)
-}
+
+# TODO: Redirect global exceptions somewhere?
+# use "ActionDispatch::Rescue"
use lambda { ActionController::Base.session_store },
lambda { ActionController::Base.session_options }
use "ActionDispatch::ParamsParser"
use "Rack::MethodOverride"
-use "Rack::Head" \ No newline at end of file
+use "Rack::Head"
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 6aa4fe6019..e9007d3631 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/inheritable_attributes'
+
module ActionController
# ActionController::Metal provides a way to get a valid Rack application from a controller.
#
diff --git a/actionpack/lib/action_controller/metal/rescuable.rb b/actionpack/lib/action_controller/metal/rescuable.rb
index 029e643d93..bbca1b2179 100644
--- a/actionpack/lib/action_controller/metal/rescuable.rb
+++ b/actionpack/lib/action_controller/metal/rescuable.rb
@@ -1,52 +1,13 @@
module ActionController #:nodoc:
- # Actions that fail to perform as expected throw exceptions. These
- # exceptions can either be rescued for the public view (with a nice
- # user-friendly explanation) or for the developers view (with tons of
- # debugging information). The developers view is already implemented by
- # the Action Controller, but the public view should be tailored to your
- # specific application.
- #
- # The default behavior for public exceptions is to render a static html
- # file with the name of the error code thrown. If no such file exists, an
- # empty response is sent with the correct status code.
- #
- # You can override what constitutes a local request by overriding the
- # <tt>local_request?</tt> method in your own controller. Custom rescue
- # behavior is achieved by overriding the <tt>rescue_action_in_public</tt>
- # and <tt>rescue_action_locally</tt> methods.
module Rescue
extend ActiveSupport::Concern
-
- included do
- include ActiveSupport::Rescuable
- end
-
- module ClassMethods
- # This can be removed once we can move action(:_rescue_action) into middlewares.rb
- # Currently, it does controller.method(:rescue_action), which is hiding the implementation
- # difference between the old and new base.
- def rescue_action(env)
- action(:_rescue_action).call(env)
- end
- end
-
- attr_internal :rescued_exception
+ include ActiveSupport::Rescuable
private
- def method_for_action(action_name)
- return action_name if self.rescued_exception = request.env.delete("action_dispatch.rescue.exception")
- super
- end
-
- def _rescue_action
- rescue_with_handler(rescued_exception) || raise(rescued_exception)
- end
-
- def process_action(*)
+ def process_action(*args)
super
rescue Exception => exception
- self.rescued_exception = exception
- _rescue_action
+ rescue_with_handler(exception) || raise(exception)
end
end
end
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb
index 849f268a8c..5bcd2143a3 100644
--- a/actionpack/lib/action_dispatch.rb
+++ b/actionpack/lib/action_dispatch.rb
@@ -21,10 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
-$:.unshift activesupport_path if File.directory?(activesupport_path)
-require 'active_support'
-
require 'rack'
module Rack
@@ -59,3 +55,7 @@ module ActionDispatch
end
autoload :Mime, 'action_dispatch/http/mime_type'
+
+activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
+$:.unshift activesupport_path if File.directory?(activesupport_path)
+require 'active_support'
diff --git a/actionpack/lib/action_dispatch/middleware/rescue.rb b/actionpack/lib/action_dispatch/middleware/rescue.rb
index 1456825526..aee672112c 100644
--- a/actionpack/lib/action_dispatch/middleware/rescue.rb
+++ b/actionpack/lib/action_dispatch/middleware/rescue.rb
@@ -1,14 +1,26 @@
module ActionDispatch
class Rescue
- def initialize(app, rescuer)
- @app, @rescuer = app, rescuer
+ def initialize(app, rescuers = {}, &block)
+ @app, @rescuers = app, {}
+ rescuers.each { |exception, rescuer| rescue_from(exception, rescuer) }
+ instance_eval(&block) if block_given?
end
def call(env)
@app.call(env)
rescue Exception => exception
- env['action_dispatch.rescue.exception'] = exception
- @rescuer.call(env)
+ if rescuer = @rescuers[exception.class.name]
+ env['action_dispatch.rescue.exception'] = exception
+ rescuer.call(env)
+ else
+ raise exception
+ end
end
+
+ protected
+ def rescue_from(exception, rescuer)
+ exception = exception.class.name if exception.is_a?(Exception)
+ @rescuers[exception.to_s] = rescuer
+ end
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
index bb2d8375bd..f8f6b424ca 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
+++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
@@ -15,12 +15,12 @@
show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';"
hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"}
%>
- <a href="#" onclick="<%= hide %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
+ <a href="#" onclick="<%= hide.join %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
<% end %>
<% traces.each do |name, trace| %>
<div id="<%= name.gsub /\s/, '-' %>" style="display: <%= name == "Application Trace" ? 'block' : 'none' %>;">
- <pre><code><%= trace.join "\n" %></code></pre>
+ <pre><code><%=h trace.join "\n" %></code></pre>
</div>
<% end %>
</div>
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index d90afb1913..3df4f2d6a3 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -21,11 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
-$:.unshift activesupport_path if File.directory?(activesupport_path)
-require 'active_support'
-require 'active_support/core_ext/class/attribute_accessors'
-
require File.join(File.dirname(__FILE__), "action_pack")
module ActionView
@@ -36,15 +31,12 @@ module ActionView
autoload :Base, 'action_view/base'
autoload :Context, 'action_view/context'
autoload :Helpers, 'action_view/helpers'
- autoload :InlineTemplate, 'action_view/template/inline'
autoload :MissingTemplate, 'action_view/base'
autoload :Partials, 'action_view/render/partials'
autoload :Resolver, 'action_view/template/resolver'
autoload :PathResolver, 'action_view/template/resolver'
autoload :PathSet, 'action_view/paths'
autoload :Rendering, 'action_view/render/rendering'
- autoload :Renderable, 'action_view/template/renderable'
- autoload :RenderablePartial, 'action_view/template/partial'
autoload :Template, 'action_view/template/template'
autoload :TemplateError, 'action_view/template/error'
autoload :TemplateHandler, 'action_view/template/handler'
@@ -59,3 +51,8 @@ class ERB
end
I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
+
+activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
+$:.unshift activesupport_path if File.directory?(activesupport_path)
+require 'active_support'
+require 'active_support/core_ext/class/attribute_accessors'
diff --git a/actionpack/lib/action_view/template/inline.rb b/actionpack/lib/action_view/template/inline.rb
deleted file mode 100644
index 54efa543c8..0000000000
--- a/actionpack/lib/action_view/template/inline.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module ActionView #:nodoc:
- class InlineTemplate #:nodoc:
- include Renderable
-
- attr_reader :source, :extension, :method_segment
-
- def initialize(source, type = nil)
- @source = source
- @extension = type
- @method_segment = "inline_#{@source.hash.abs}"
- end
-
- private
- # Always recompile inline templates
- def recompile?
- true
- end
- end
-end
diff --git a/actionpack/lib/action_view/template/partial.rb b/actionpack/lib/action_view/template/partial.rb
deleted file mode 100644
index 30dec1dc5b..0000000000
--- a/actionpack/lib/action_view/template/partial.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module ActionView
- # 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
- name.sub(/\A_/, '').to_sym
- end
- memoize :variable_name
-
- def counter_name
- "#{variable_name}_counter".to_sym
- end
- memoize :counter_name
-
- end
-end
diff --git a/actionpack/lib/action_view/template/renderable.rb b/actionpack/lib/action_view/template/renderable.rb
deleted file mode 100644
index 7687578165..0000000000
--- a/actionpack/lib/action_view/template/renderable.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# encoding: utf-8
-
-module ActionView
- # 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 render(view, locals)
- compile(locals)
- view.send(method_name(locals), locals) {|*args| yield(*args) }
- end
-
- def load!
- names = CompiledTemplates.instance_methods.grep(/#{method_name_without_locals}/)
- names.each do |name|
- CompiledTemplates.class_eval do
- remove_method(name)
- end
- end
- super
- end
-
- private
-
- def filename
- 'compiled-template'
- end
-
- def handler
- Template.handler_class_for_extension(extension)
- end
- memoize :handler
-
- def compiled_source
- handler.call(self)
- end
- memoize :compiled_source
-
- def method_name_without_locals
- ['_run', extension, method_segment].compact.join('_')
- end
- memoize :method_name_without_locals
-
- def method_name(local_assigns)
- if local_assigns && local_assigns.any?
- method_name = method_name_without_locals.dup
- method_name << "_locals_#{local_assigns.keys.map { |k| k.to_s }.sort.join('_')}"
- else
- method_name = method_name_without_locals
- end
- method_name.to_sym
- end
-
- # Compile and evaluate the template's code (if necessary)
- def compile(local_assigns)
- render_symbol = method_name(local_assigns)
-
- if !CompiledTemplates.method_defined?(render_symbol) || recompile?
- compile!(render_symbol, local_assigns)
- end
- end
-
- private
- def compile!(render_symbol, local_assigns)
- locals_code = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join
-
- source = <<-end_src
- def #{render_symbol}(local_assigns)
- old_output_buffer = output_buffer;#{locals_code};#{compiled_source}
- ensure
- self.output_buffer = old_output_buffer
- end
- end_src
-
- begin
- ActionView::CompiledTemplates.module_eval(source, filename.to_s, 0)
- rescue Exception => e # errors from template code
- 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")}"
- end
-
- raise ActionView::TemplateError.new(self, {}, e)
- end
- end
-
- def recompile?
- false
- end
- end
-end
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract/abstract_controller_test.rb
index 0e6cfba5b5..524381509d 100644
--- a/actionpack/test/abstract_controller/abstract_controller_test.rb
+++ b/actionpack/test/abstract/abstract_controller_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
diff --git a/actionpack/test/abstract_controller/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb
index 98656c0c70..0ce1dc506b 100644
--- a/actionpack/test/abstract_controller/callbacks_test.rb
+++ b/actionpack/test/abstract/callbacks_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
diff --git a/actionpack/test/abstract_controller/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index 4c013137f9..5a363c9aa5 100644
--- a/actionpack/test/abstract_controller/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module AbstractController
module Testing
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index bee3b5c556..453d31826e 100644
--- a/actionpack/test/abstract_controller/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
require 'active_support/core_ext/class/removal'
module AbstractControllerTests
diff --git a/actionpack/test/abstract_controller/views/abstract_controller/testing/me3/formatted.html.erb b/actionpack/test/abstract/views/abstract_controller/testing/me3/formatted.html.erb
index 785bf69191..785bf69191 100644
--- a/actionpack/test/abstract_controller/views/abstract_controller/testing/me3/formatted.html.erb
+++ b/actionpack/test/abstract/views/abstract_controller/testing/me3/formatted.html.erb
diff --git a/actionpack/test/abstract_controller/views/abstract_controller/testing/me3/index.erb b/actionpack/test/abstract/views/abstract_controller/testing/me3/index.erb
index f079ad8204..f079ad8204 100644
--- a/actionpack/test/abstract_controller/views/abstract_controller/testing/me3/index.erb
+++ b/actionpack/test/abstract/views/abstract_controller/testing/me3/index.erb
diff --git a/actionpack/test/abstract_controller/views/abstract_controller/testing/me4/index.erb b/actionpack/test/abstract/views/abstract_controller/testing/me4/index.erb
index 89dce12bdc..89dce12bdc 100644
--- a/actionpack/test/abstract_controller/views/abstract_controller/testing/me4/index.erb
+++ b/actionpack/test/abstract/views/abstract_controller/testing/me4/index.erb
diff --git a/actionpack/test/abstract_controller/views/abstract_controller/testing/me5/index.erb b/actionpack/test/abstract/views/abstract_controller/testing/me5/index.erb
index 84d0b7417e..84d0b7417e 100644
--- a/actionpack/test/abstract_controller/views/abstract_controller/testing/me5/index.erb
+++ b/actionpack/test/abstract/views/abstract_controller/testing/me5/index.erb
diff --git a/actionpack/test/abstract_controller/views/action_with_ivars.erb b/actionpack/test/abstract/views/action_with_ivars.erb
index 8d8ae22fd7..8d8ae22fd7 100644
--- a/actionpack/test/abstract_controller/views/action_with_ivars.erb
+++ b/actionpack/test/abstract/views/action_with_ivars.erb
diff --git a/actionpack/test/abstract_controller/views/helper_test.erb b/actionpack/test/abstract/views/helper_test.erb
index 8ae45cc195..8ae45cc195 100644
--- a/actionpack/test/abstract_controller/views/helper_test.erb
+++ b/actionpack/test/abstract/views/helper_test.erb
diff --git a/actionpack/test/abstract_controller/views/index.erb b/actionpack/test/abstract/views/index.erb
index cc1a8b8c85..cc1a8b8c85 100644
--- a/actionpack/test/abstract_controller/views/index.erb
+++ b/actionpack/test/abstract/views/index.erb
diff --git a/actionpack/test/abstract_controller/views/layouts/abstract_controller/testing/me4.erb b/actionpack/test/abstract/views/layouts/abstract_controller/testing/me4.erb
index 172dd56569..172dd56569 100644
--- a/actionpack/test/abstract_controller/views/layouts/abstract_controller/testing/me4.erb
+++ b/actionpack/test/abstract/views/layouts/abstract_controller/testing/me4.erb
diff --git a/actionpack/test/abstract_controller/views/layouts/application.erb b/actionpack/test/abstract/views/layouts/application.erb
index 27317140ad..27317140ad 100644
--- a/actionpack/test/abstract_controller/views/layouts/application.erb
+++ b/actionpack/test/abstract/views/layouts/application.erb
diff --git a/actionpack/test/abstract_controller/views/naked_render.erb b/actionpack/test/abstract/views/naked_render.erb
index 1b3d03878b..1b3d03878b 100644
--- a/actionpack/test/abstract_controller/views/naked_render.erb
+++ b/actionpack/test/abstract/views/naked_render.erb
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 7776bd0704..b9293ffb9f 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -6,26 +6,31 @@ $:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
-require 'bundler_helper'
-ensure_requirable %w( rack rack/test sqlite3 )
+bundler = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
+require bundler if File.exist?("#{bundler}.rb")
-ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
+begin
+ %w( rack rack/test sqlite3 ).each { |lib| require lib }
+rescue LoadError => e
+ abort e.message
+end
-ENV['new_base'] = "true"
-$stderr.puts "Running old tests on new_base"
+ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
require 'test/unit'
require 'active_support'
require 'active_support/test_case'
+require 'abstract_controller'
require 'action_controller'
+require 'action_view'
+require 'action_view/base'
+require 'action_dispatch'
+require 'active_model'
require 'fixture_template'
require 'action_controller/testing/process'
-require 'action_view/test_case'
require 'action_controller/testing/integration'
+require 'action_view/test_case'
require 'active_support/dependencies'
-require 'active_model'
-
-$tags[:new_base] = true
begin
require 'ruby-debug'
@@ -35,6 +40,8 @@ rescue LoadError
# Debugging disabled. `gem install ruby-debug` to enable.
end
+require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
+
ActiveSupport::Dependencies.hook!
# Show backtraces for deprecated behavior for quicker cleanup.
@@ -57,6 +64,61 @@ module ActionView
end
end
+# Temporary base class
+class Rack::TestCase < ActionController::IntegrationTest
+ setup do
+ ActionController::Base.session_options[:key] = "abc"
+ ActionController::Base.session_options[:secret] = ("*" * 30)
+ end
+
+ def app
+ @app ||= ActionController::Dispatcher.new
+ end
+
+ def self.testing(klass = nil)
+ if klass
+ @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
+ else
+ @testing
+ end
+ end
+
+ def get(thing, *args)
+ if thing.is_a?(Symbol)
+ super("#{self.class.testing}/#{thing}", *args)
+ else
+ super
+ end
+ end
+
+ def assert_body(body)
+ assert_equal body, Array.wrap(response.body).join
+ end
+
+ def assert_status(code)
+ assert_equal code, response.status
+ end
+
+ def assert_response(body, status = 200, headers = {})
+ assert_body body
+ assert_status status
+ headers.each do |header, value|
+ assert_header header, value
+ end
+ end
+
+ def assert_content_type(type)
+ assert_equal type, response.headers["Content-Type"]
+ end
+
+ def assert_header(name, value)
+ assert_equal value, response.headers[name]
+ end
+end
+
+class ::ApplicationController < ActionController::Base
+end
+
module ActionController
Base.session = {
:key => '_testing_session',
@@ -133,3 +195,11 @@ module ActionController
end
end
end
+
+class SimpleRouteCase < Rack::TestCase
+ setup do
+ ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+ end
+ end
+end
diff --git a/actionpack/test/abstract_unit2.rb b/actionpack/test/abstract_unit2.rb
deleted file mode 100644
index 0a98d8edc2..0000000000
--- a/actionpack/test/abstract_unit2.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-# TODO: Unify with abstract_unit
-
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-$:.unshift(File.dirname(__FILE__) + '/lib')
-
-require 'bundler_helper'
-ensure_requirable %w( rack rack/test )
-
-require 'test/unit'
-require 'active_support'
-require 'active_support/test_case'
-require 'abstract_controller'
-require 'action_view'
-require 'action_view/base'
-require 'action_dispatch'
-require 'fixture_template'
-
-begin
- require 'ruby-debug'
- Debugger.settings[:autoeval] = true
- Debugger.start
-rescue LoadError
- # Debugging disabled. `gem install ruby-debug` to enable.
-end
-
-require 'action_controller'
-require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
-
-require 'action_controller/testing/process'
-require 'action_controller/testing/integration'
-
-module Rails
- def self.env
- x = Object.new
- def x.test?() true end
- x
- end
-end
-
-# Temporary base class
-class Rack::TestCase < ActionController::IntegrationTest
- setup do
- ActionController::Base.session_options[:key] = "abc"
- ActionController::Base.session_options[:secret] = ("*" * 30)
- end
-
- def app
- @app ||= ActionController::Dispatcher.new
- end
-
- def self.testing(klass = nil)
- if klass
- @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
- else
- @testing
- end
- end
-
- def get(thing, *args)
- if thing.is_a?(Symbol)
- super("#{self.class.testing}/#{thing}", *args)
- else
- super
- end
- end
-
- def assert_body(body)
- assert_equal body, Array.wrap(response.body).join
- end
-
- def assert_status(code)
- assert_equal code, response.status
- end
-
- def assert_response(body, status = 200, headers = {})
- assert_body body
- assert_status status
- headers.each do |header, value|
- assert_header header, value
- end
- end
-
- def assert_content_type(type)
- assert_equal type, response.headers["Content-Type"]
- end
-
- def assert_header(name, value)
- assert_equal value, response.headers[name]
- end
-end
-
-class ::ApplicationController < ActionController::Base
-end
-
-module ActionController
- class << Routing
- def possible_controllers
- @@possible_controllers ||= []
- end
- end
-
- class Base
- def self.inherited(klass)
- name = klass.name.underscore.sub(/_controller$/, '')
- ActionController::Routing.possible_controllers << name unless name.blank?
- super
- end
- end
-end
-
-class SimpleRouteCase < Rack::TestCase
- setup do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- end
-end
diff --git a/actionpack/test/bundler_helper.rb b/actionpack/test/bundler_helper.rb
deleted file mode 100644
index f7357bdb41..0000000000
--- a/actionpack/test/bundler_helper.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-def ensure_requirable(libs)
- bundler = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
- require bundler if File.exist?("#{bundler}.rb")
-
- begin
- libs.each { |lib| require lib }
- rescue LoadError => e
- abort e.message
- end
-end
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 82c790bc19..25e035cb49 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -441,8 +441,8 @@ class ActionCacheTest < ActionController::TestCase
def test_correct_content_type_is_returned_for_cache_hit
# run it twice to cache it the first time
- get :index, :id => 'content-type.xml'
- get :index, :id => 'content-type.xml'
+ get :index, :id => 'content-type', :format => 'xml'
+ get :index, :id => 'content-type', :format => 'xml'
assert_equal 'application/xml', @response.content_type
end
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index c249788c67..e5ffe20ecc 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class ContentTypeController < ActionController::Base
+class OldContentTypeController < ActionController::Base
# :ported:
def render_content_type_from_body
response.content_type = Mime::RSS
@@ -56,7 +56,7 @@ class ContentTypeController < ActionController::Base
end
class ContentTypeTest < ActionController::TestCase
- tests ContentTypeController
+ tests OldContentTypeController
def setup
super
@@ -73,11 +73,11 @@ class ContentTypeTest < ActionController::TestCase
end
def test_render_changed_charset_default
- ContentTypeController.default_charset = "utf-16"
+ OldContentTypeController.default_charset = "utf-16"
get :render_defaults
assert_equal "utf-16", @response.charset
assert_equal Mime::HTML, @response.content_type
- ContentTypeController.default_charset = "utf-8"
+ OldContentTypeController.default_charset = "utf-8"
end
# :ported:
@@ -109,12 +109,12 @@ class ContentTypeTest < ActionController::TestCase
end
def test_nil_default_for_rhtml
- ContentTypeController.default_charset = nil
+ OldContentTypeController.default_charset = nil
get :render_default_for_rhtml
assert_equal Mime::HTML, @response.content_type
assert_nil @response.charset, @response.headers.inspect
ensure
- ContentTypeController.default_charset = "utf-8"
+ OldContentTypeController.default_charset = "utf-8"
end
def test_default_for_rhtml
@@ -143,8 +143,7 @@ class ContentTypeTest < ActionController::TestCase
end
class AcceptBasedContentTypeTest < ActionController::TestCase
-
- tests ContentTypeController
+ tests OldContentTypeController
def setup
super
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 93f5bfa272..9f56bbfd46 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -377,7 +377,7 @@ class IntegrationProcessTest < ActionController::IntegrationTest
end
end
-class MetalTest < ActionController::IntegrationTest
+class MetalIntegrationTest < ActionController::IntegrationTest
class Poller
def self.call(env)
if env["PATH_INFO"] =~ /^\/success/
diff --git a/actionpack/test/controller/render_js_test.rb b/actionpack/test/controller/render_js_test.rb
index bc850de733..491c98a0fd 100644
--- a/actionpack/test/controller/render_js_test.rb
+++ b/actionpack/test/controller/render_js_test.rb
@@ -2,23 +2,27 @@ require 'abstract_unit'
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
+class RenderJSTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- def render_vanilla_js_hello
- render :js => "alert('hello')"
- end
-
- def greeting
- # let's just rely on the template
+ def self.controller_path
+ 'test'
+ end
+
+ def render_vanilla_js_hello
+ render :js => "alert('hello')"
+ end
+
+ def greeting
+ # let's just rely on the template
+ end
+
+ def show_partial
+ render :partial => 'partial'
+ end
end
-
- def show_partial
- render :partial => 'partial'
- end
-end
-class RenderTest < ActionController::TestCase
tests TestController
def test_render_vanilla_js
@@ -26,14 +30,14 @@ class RenderTest < ActionController::TestCase
assert_equal "alert('hello')", @response.body
assert_equal "text/javascript", @response.content_type
end
-
+
def test_render_with_default_from_accept_header
xhr :get, :greeting
assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body
end
-
+
def test_should_render_js_partial
xhr :get, :show_partial, :format => 'js'
assert_equal 'partial js', @response.body
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb
index 233b2dfd89..3938fc7061 100644
--- a/actionpack/test/controller/render_json_test.rb
+++ b/actionpack/test/controller/render_json_test.rb
@@ -2,35 +2,39 @@ require 'abstract_unit'
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
-
- def render_json_nil
- render :json => nil
- end
+class RenderJsonTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- def render_json_hello_world
- render :json => ActiveSupport::JSON.encode(:hello => 'world')
- end
+ def self.controller_path
+ 'test'
+ end
- def render_json_hello_world_with_callback
- render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert'
- end
+ def render_json_nil
+ render :json => nil
+ end
- def render_json_with_custom_content_type
- render :json => ActiveSupport::JSON.encode(:hello => 'world'), :content_type => 'text/javascript'
- end
+ def render_json_hello_world
+ render :json => ActiveSupport::JSON.encode(:hello => 'world')
+ end
- def render_symbol_json
- render :json => ActiveSupport::JSON.encode(:hello => 'world')
- end
+ def render_json_hello_world_with_callback
+ render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert'
+ end
- def render_json_with_render_to_string
- render :json => {:hello => render_to_string(:partial => 'partial')}
- end
-end
+ def render_json_with_custom_content_type
+ render :json => ActiveSupport::JSON.encode(:hello => 'world'), :content_type => 'text/javascript'
+ end
+
+ def render_symbol_json
+ render :json => ActiveSupport::JSON.encode(:hello => 'world')
+ end
+
+ def render_json_with_render_to_string
+ render :json => {:hello => render_to_string(:partial => 'partial')}
+ end
+ end
-class RenderTest < ActionController::TestCase
tests TestController
def setup
@@ -40,8 +44,8 @@ class RenderTest < ActionController::TestCase
@controller.logger = Logger.new(nil)
@request.host = "www.nextangle.com"
- end
-
+ end
+
def test_render_json_nil
get :render_json_nil
assert_equal 'null', @response.body
@@ -76,5 +80,5 @@ class RenderTest < ActionController::TestCase
get :render_json_with_render_to_string
assert_equal '{"hello":"partial html"}', @response.body
assert_equal 'application/json', @response.content_type
- end
-end \ No newline at end of file
+ end
+end
diff --git a/actionpack/test/controller/render_other_test.rb b/actionpack/test/controller/render_other_test.rb
index 05645e47fa..51c3c55545 100644
--- a/actionpack/test/controller/render_other_test.rb
+++ b/actionpack/test/controller/render_other_test.rb
@@ -2,139 +2,144 @@ require 'abstract_unit'
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
- layout :determine_layout
+class RenderOtherTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- module RenderTestHelper
- def rjs_helper_method_from_module
- page.visual_effect :highlight
+ def self.controller_path
+ 'test'
end
- end
- helper RenderTestHelper
- helper do
- def rjs_helper_method(value)
- page.visual_effect :highlight, value
+ layout :determine_layout
+
+ module RenderTestHelper
+ def rjs_helper_method_from_module
+ page.visual_effect :highlight
+ end
end
- end
- def enum_rjs_test
- render :update do |page|
- page.select('.product').each do |value|
- page.rjs_helper_method_from_module
- page.rjs_helper_method(value)
- page.sortable(value, :url => { :action => "order" })
- page.draggable(value)
+ helper RenderTestHelper
+ helper do
+ def rjs_helper_method(value)
+ page.visual_effect :highlight, value
end
end
- end
-
- def render_explicit_html_template
- end
-
- def render_custom_code_rjs
- render :update, :status => 404 do |page|
- page.replace :foo, :partial => 'partial'
+
+ def enum_rjs_test
+ render :update do |page|
+ page.select('.product').each do |value|
+ page.rjs_helper_method_from_module
+ page.rjs_helper_method(value)
+ page.sortable(value, :url => { :action => "order" })
+ page.draggable(value)
+ end
+ end
end
- end
-
- def render_implicit_html_template
- end
-
- def render_js_with_explicit_template
- @project_id = 4
- render :template => 'test/delete_with_js'
- end
- def render_js_with_explicit_action_template
- @project_id = 4
- render :action => 'delete_with_js'
- end
-
- def delete_with_js
- @project_id = 4
- end
-
- def update_page
- render :update do |page|
- page.replace_html 'balance', '$37,000,000.00'
- page.visual_effect :highlight, 'balance'
+ def render_explicit_html_template
+ end
+
+ def render_custom_code_rjs
+ render :update, :status => 404 do |page|
+ page.replace :foo, :partial => 'partial'
+ end
end
- end
- def update_page_with_instance_variables
- @money = '$37,000,000.00'
- @div_id = 'balance'
- render :update do |page|
- page.replace_html @div_id, @money
- page.visual_effect :highlight, @div_id
+ def render_implicit_html_template
end
- end
- def update_page_with_view_method
- render :update do |page|
- page.replace_html 'person', pluralize(2, 'person')
+ def render_js_with_explicit_template
+ @project_id = 4
+ render :template => 'test/delete_with_js'
end
- end
-
- def partial_as_rjs
- render :update do |page|
- page.replace :foo, :partial => 'partial'
+
+ def render_js_with_explicit_action_template
+ @project_id = 4
+ render :action => 'delete_with_js'
end
- end
- def respond_to_partial_as_rjs
- respond_to do |format|
- format.js do
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
+ def delete_with_js
+ @project_id = 4
+ end
+
+ def update_page
+ render :update do |page|
+ page.replace_html 'balance', '$37,000,000.00'
+ page.visual_effect :highlight, 'balance'
end
end
- end
-
- def render_alternate_default
- # For this test, the method "default_render" is overridden:
- @alternate_default_render = lambda do
+
+ def update_page_with_instance_variables
+ @money = '$37,000,000.00'
+ @div_id = 'balance'
+ render :update do |page|
+ page.replace_html @div_id, @money
+ page.visual_effect :highlight, @div_id
+ end
+ end
+
+ def update_page_with_view_method
+ render :update do |page|
+ page.replace_html 'person', pluralize(2, 'person')
+ end
+ end
+
+ def partial_as_rjs
render :update do |page|
page.replace :foo, :partial => 'partial'
end
end
- end
-
-private
- def default_render
- if @alternate_default_render
- @alternate_default_render.call
- else
- super
+
+ def respond_to_partial_as_rjs
+ respond_to do |format|
+ format.js do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
end
- end
- def determine_layout
- case action_name
- when "hello_world", "layout_test", "rendering_without_layout",
- "rendering_nothing_on_layout", "render_text_hello_world",
- "render_text_hello_world_with_layout",
- "hello_world_with_layout_false",
- "partial_only", "partial_only_with_layout",
- "accessing_params_in_template",
- "accessing_params_in_template_with_layout",
- "render_with_explicit_template",
- "render_with_explicit_string_template",
- "update_page", "update_page_with_instance_variables"
-
- "layouts/standard"
- when "action_talk_to_layout", "layout_overriding_layout"
- "layouts/talk_from_action"
- when "render_implicit_html_template_from_xhr_request"
- (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
- end
- end
-end
+ def render_alternate_default
+ # For this test, the method "default_render" is overridden:
+ @alternate_default_render = lambda do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
+
+ private
+ def default_render
+ if @alternate_default_render
+ @alternate_default_render.call
+ else
+ super
+ end
+ end
+
+ def determine_layout
+ case action_name
+ when "hello_world", "layout_test", "rendering_without_layout",
+ "rendering_nothing_on_layout", "render_text_hello_world",
+ "render_text_hello_world_with_layout",
+ "hello_world_with_layout_false",
+ "partial_only", "partial_only_with_layout",
+ "accessing_params_in_template",
+ "accessing_params_in_template_with_layout",
+ "render_with_explicit_template",
+ "render_with_explicit_string_template",
+ "update_page", "update_page_with_instance_variables"
+
+ "layouts/standard"
+ when "action_talk_to_layout", "layout_overriding_layout"
+ "layouts/talk_from_action"
+ when "render_implicit_html_template_from_xhr_request"
+ (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
+ end
+ end
+ end
-class RenderTest < ActionController::TestCase
tests TestController
def setup
@@ -144,8 +149,8 @@ class RenderTest < ActionController::TestCase
@controller.logger = Logger.new(nil)
@request.host = "www.nextangle.com"
- end
-
+ end
+
def test_enum_rjs_test
ActiveSupport::SecureRandom.stubs(:base64).returns("asdf")
get :enum_rjs_test
@@ -153,13 +158,13 @@ class RenderTest < ActionController::TestCase
$$(".product").each(function(value, index) {
new Effect.Highlight(element,{});
new Effect.Highlight(value,{});
- Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
+ Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
new Draggable(value, {});
});
}.gsub(/^ /, '').strip
assert_equal body, @response.body
end
-
+
def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
[:js, "js"].each do |format|
assert_nothing_raised do
@@ -167,14 +172,14 @@ class RenderTest < ActionController::TestCase
assert_equal %(document.write("Hello world\\n");), @response.body
end
end
- end
-
+ end
+
def test_render_custom_code_rjs
get :render_custom_code_rjs
assert_response 404
assert_equal %(Element.replace("foo", "partial html");), @response.body
end
-
+
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
[:js, "js"].each do |format|
assert_nothing_raised do
@@ -183,7 +188,7 @@ class RenderTest < ActionController::TestCase
end
end
end
-
+
def test_render_rjs_template_explicitly
get :render_js_with_explicit_template
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
@@ -193,12 +198,12 @@ class RenderTest < ActionController::TestCase
get :render_js_with_explicit_action_template
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
-
+
def test_render_rjs_with_default
get :delete_with_js
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
-
+
def test_update_page
get :update_page
assert_template nil
@@ -219,8 +224,8 @@ class RenderTest < ActionController::TestCase
assert_template nil
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
assert_match /2 people/, @response.body
- end
-
+ end
+
def test_should_render_html_formatted_partial_with_rjs
xhr :get, :partial_as_rjs
assert_equal %(Element.replace("foo", "partial html");), @response.body
@@ -230,9 +235,9 @@ class RenderTest < ActionController::TestCase
xhr :get, :respond_to_partial_as_rjs
assert_equal %(Element.replace("foo", "partial html");), @response.body
end
-
+
def test_should_render_with_alternate_default_render
xhr :get, :render_alternate_default
assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-end \ No newline at end of file
+ end
+end
diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb
index e96e8a4d57..68a52c3e8c 100644
--- a/actionpack/test/controller/render_xml_test.rb
+++ b/actionpack/test/controller/render_xml_test.rb
@@ -2,37 +2,41 @@ require 'abstract_unit'
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
+class RenderXmlTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- def render_with_location
- render :xml => "<hello/>", :location => "http://example.com", :status => 201
- end
+ def self.controller_path
+ 'test'
+ end
- def render_with_object_location
- customer = Customer.new("Some guy", 1)
- render :xml => "<customer/>", :location => customer, :status => :created
- end
+ def render_with_location
+ render :xml => "<hello/>", :location => "http://example.com", :status => 201
+ end
- def render_with_to_xml
- to_xmlable = Class.new do
- def to_xml
- "<i-am-xml/>"
- end
- end.new
+ def render_with_object_location
+ customer = Customer.new("Some guy", 1)
+ render :xml => "<customer/>", :location => customer, :status => :created
+ end
- render :xml => to_xmlable
- end
-
- def formatted_xml_erb
+ def render_with_to_xml
+ to_xmlable = Class.new do
+ def to_xml
+ "<i-am-xml/>"
+ end
+ end.new
+
+ render :xml => to_xmlable
+ end
+
+ def formatted_xml_erb
+ end
+
+ def render_xml_with_custom_content_type
+ render :xml => "<blah/>", :content_type => "application/atomsvc+xml"
+ end
end
-
- def render_xml_with_custom_content_type
- render :xml => "<blah/>", :content_type => "application/atomsvc+xml"
- end
-end
-class RenderTest < ActionController::TestCase
tests TestController
def setup
@@ -42,8 +46,8 @@ class RenderTest < ActionController::TestCase
@controller.logger = Logger.new(nil)
@request.host = "www.nextangle.com"
- end
-
+ end
+
def test_rendering_with_location_should_set_header
get :render_with_location
assert_equal "http://example.com", @response.headers["Location"]
@@ -53,7 +57,7 @@ class RenderTest < ActionController::TestCase
get :render_with_to_xml
assert_equal "<i-am-xml/>", @response.body
end
-
+
def test_rendering_with_object_location_should_set_header_with_url_for
with_routing do |set|
set.draw do |map|
@@ -65,19 +69,19 @@ class RenderTest < ActionController::TestCase
assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"]
end
end
-
+
def test_should_render_formatted_xml_erb_template
get :formatted_xml_erb, :format => :xml
assert_equal '<test>passed formatted xml erb</test>', @response.body
end
-
+
def test_should_render_xml_but_keep_custom_content_type
get :render_xml_with_custom_content_type
assert_equal "application/atomsvc+xml", @response.content_type
end
-
+
def test_should_use_implicit_content_type
get :implicit_content_type, :format => 'atom'
assert_equal Mime::ATOM, @response.content_type
- end
+ end
end
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index 23408712e9..09eddfe4a7 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -227,12 +227,6 @@ class ControllerInheritanceRescueControllerTest < ActionController::TestCase
end
end
-class ApplicationController < ActionController::Base
- rescue_from ActionController::RoutingError do
- render :text => 'no way'
- end
-end
-
class RescueControllerTest < ActionController::TestCase
def test_rescue_handler
get :not_authorized
@@ -332,23 +326,20 @@ class RescueTest < ActionController::IntegrationTest
end
test 'rescue routing exceptions' do
- assert_equal 1, ApplicationController.rescue_handlers.length
-
- begin
- with_test_routing do
- get '/no_way'
- assert_equal 'no way', response.body
- end
- ensure
- ActionController::Base.rescue_handlers.clear
+ app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do
+ rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, "Gotcha!"] }
end
+ @integration_session = open_session(app)
+
+ get '/b00m'
+ assert_equal "Gotcha!", response.body
end
test 'unrescued exception' do
- with_test_routing do
- get '/b00m'
- assert_match(/Action Controller: Exception caught/, response.body)
- end
+ app = ActionDispatch::Rescue.new(ActionController::Routing::Routes)
+ @integration_session = open_session(app)
+
+ assert_raise(ActionController::RoutingError) { get '/b00m' }
end
private
diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb
index ce1973853e..d4800e4edb 100644
--- a/actionpack/test/dispatch/show_exceptions_test.rb
+++ b/actionpack/test/dispatch/show_exceptions_test.rb
@@ -70,8 +70,7 @@ class ShowExceptionsTest < ActionController::IntegrationTest
test "localize public rescue message" do
# Change locale
- old_locale = I18n.locale
- I18n.locale = :da
+ old_locale, I18n.locale = I18n.locale, :da
begin
@integration_session = open_session(ProductionApp)
diff --git a/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.xml.erb b/actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb
index 25dc746886..25dc746886 100644
--- a/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.xml.erb
+++ b/actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb
diff --git a/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml b/actionpack/test/fixtures/old_content_type/render_default_for_rhtml.rhtml
index c7926d48bb..c7926d48bb 100644
--- a/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml
+++ b/actionpack/test/fixtures/old_content_type/render_default_for_rhtml.rhtml
diff --git a/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs b/actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs
index 8d614d04ad..8d614d04ad 100644
--- a/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs
+++ b/actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs
diff --git a/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml b/actionpack/test/fixtures/old_content_type/render_default_for_rxml.rxml
index 598d62e2fc..598d62e2fc 100644
--- a/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml
+++ b/actionpack/test/fixtures/old_content_type/render_default_for_rxml.rxml
diff --git a/actionpack/test/new_base/base_test.rb b/actionpack/test/new_base/base_test.rb
index 3a559c9cb6..effde324bc 100644
--- a/actionpack/test/new_base/base_test.rb
+++ b/actionpack/test/new_base/base_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
# Tests the controller dispatching happy path
module Dispatching
diff --git a/actionpack/test/new_base/content_negotiation_test.rb b/actionpack/test/new_base/content_negotiation_test.rb
index a2f9df597f..c43cb677f8 100644
--- a/actionpack/test/new_base/content_negotiation_test.rb
+++ b/actionpack/test/new_base/content_negotiation_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ContentNegotiation
diff --git a/actionpack/test/new_base/content_type_test.rb b/actionpack/test/new_base/content_type_test.rb
index 7e95c715a0..898d0bb9f3 100644
--- a/actionpack/test/new_base/content_type_test.rb
+++ b/actionpack/test/new_base/content_type_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ContentType
class BaseController < ActionController::Base
diff --git a/actionpack/test/new_base/etag_test.rb b/actionpack/test/new_base/etag_test.rb
index 64ae10b7a7..d5b7942ab6 100644
--- a/actionpack/test/new_base/etag_test.rb
+++ b/actionpack/test/new_base/etag_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module Etags
class BasicController < ActionController::Base
diff --git a/actionpack/test/new_base/metal_test.rb b/actionpack/test/new_base/metal_test.rb
index 613d03446c..e1d46b906e 100644
--- a/actionpack/test/new_base/metal_test.rb
+++ b/actionpack/test/new_base/metal_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module MetalTest
class MetalMiddleware < ActionController::Middleware
diff --git a/actionpack/test/new_base/middleware_test.rb b/actionpack/test/new_base/middleware_test.rb
index ecca7e51eb..ada0215b1a 100644
--- a/actionpack/test/new_base/middleware_test.rb
+++ b/actionpack/test/new_base/middleware_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module MiddlewareTest
class MyMiddleware
diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb
index 72a16e3b67..d5896c1ebd 100644
--- a/actionpack/test/new_base/render_action_test.rb
+++ b/actionpack/test/new_base/render_action_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderAction
# This has no layout and it works
diff --git a/actionpack/test/new_base/render_file_test.rb b/actionpack/test/new_base/render_file_test.rb
index 7067baca18..c4098855e6 100644
--- a/actionpack/test/new_base/render_file_test.rb
+++ b/actionpack/test/new_base/render_file_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderFile
diff --git a/actionpack/test/new_base/render_implicit_action_test.rb b/actionpack/test/new_base/render_implicit_action_test.rb
index 03b9ff6eeb..2b78fa7d4f 100644
--- a/actionpack/test/new_base/render_implicit_action_test.rb
+++ b/actionpack/test/new_base/render_implicit_action_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderImplicitAction
class SimpleController < ::ApplicationController
diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb
index 0dfbae4e9d..f840a47ecf 100644
--- a/actionpack/test/new_base/render_layout_test.rb
+++ b/actionpack/test/new_base/render_layout_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module ControllerLayouts
class ImplicitController < ::ApplicationController
diff --git a/actionpack/test/new_base/render_partial_test.rb b/actionpack/test/new_base/render_partial_test.rb
index ff775dbfd7..7c2c20e1c7 100644
--- a/actionpack/test/new_base/render_partial_test.rb
+++ b/actionpack/test/new_base/render_partial_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderPartial
diff --git a/actionpack/test/new_base/render_rjs_test.rb b/actionpack/test/new_base/render_rjs_test.rb
index eecc275b1e..7b76c54ab9 100644
--- a/actionpack/test/new_base/render_rjs_test.rb
+++ b/actionpack/test/new_base/render_rjs_test.rb
@@ -1,9 +1,7 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderRjs
-
class BasicController < ActionController::Base
-
self.view_paths = [ActionView::FixtureResolver.new(
"render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')",
"render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
@@ -26,6 +24,14 @@ module RenderRjs
class TestBasic < SimpleRouteCase
testing BasicController
+ def setup
+ @old_locale = I18n.locale
+ end
+
+ def teardown
+ I18n.locale = @old_locale
+ end
+
test "rendering a partial in an RJS template should pick the JS template over the HTML one" do
get :index, "format" => "js"
assert_response("$(\"customer\").update(\"JS Partial\");")
@@ -40,6 +46,5 @@ module RenderRjs
get :index_locale, "format" => "js"
assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
end
-
end
end
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb
index 5637565dac..3b24c2d75a 100644
--- a/actionpack/test/new_base/render_template_test.rb
+++ b/actionpack/test/new_base/render_template_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderTemplate
class WithoutLayoutController < ActionController::Base
diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb
index 94820f1c9c..804be79d17 100644
--- a/actionpack/test/new_base/render_test.rb
+++ b/actionpack/test/new_base/render_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module Render
class BlankRenderController < ActionController::Base
diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb
index 23660ed101..f5839ee16f 100644
--- a/actionpack/test/new_base/render_text_test.rb
+++ b/actionpack/test/new_base/render_text_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderText
class SimpleController < ActionController::Base
diff --git a/actionpack/test/new_base/render_xml_test.rb b/actionpack/test/new_base/render_xml_test.rb
index 86a7d9c8a5..d044738a78 100644
--- a/actionpack/test/new_base/render_xml_test.rb
+++ b/actionpack/test/new_base/render_xml_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit2'
+require 'abstract_unit'
module RenderXml
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index c86d5215cd..3c192906ae 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -33,18 +33,14 @@ module RenderTestCases
end
def test_render_file_with_localization
- begin
- old_locale = I18n.locale
- I18n.locale = :da
- assert_equal "Hey verden", @view.render(:file => "test/hello_world")
- ensure
- I18n.locale = old_locale
- end
+ old_locale, I18n.locale = I18n.locale, :da
+ assert_equal "Hey verden", @view.render(:file => "test/hello_world")
+ ensure
+ I18n.locale = old_locale
end
def test_render_file_with_dashed_locale
- old_locale = I18n.locale
- I18n.locale = :"pt-BR"
+ old_locale, I18n.locale = I18n.locale, :"pt-BR"
assert_equal "Ola mundo", @view.render(:file => "test/hello_world")
ensure
I18n.locale = old_locale
diff --git a/activemodel/examples/validations.rb b/activemodel/examples/validations.rb
index 3f8311ff96..b039897ea5 100644
--- a/activemodel/examples/validations.rb
+++ b/activemodel/examples/validations.rb
@@ -1,4 +1,4 @@
-require 'activemodel'
+require 'active_model'
class Person
include ActiveModel::Conversion
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 590420de0b..7a48960f89 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -114,7 +114,7 @@ module ActiveModel
full_messages
end
- # Translates an error message in it's default scope (<tt>activemodel.errrors.messages</tt>).
+ # Translates an error message in its default scope (<tt>activemodel.errors.messages</tt>).
# Error messages are first looked up in <tt>models.MODEL.attributes.ATTRIBUTE.MESSAGE</tt>, if it's not there,
# it's looked up in <tt>models.MODEL.MESSAGE</tt> and if that is not there it returns the translation of the
# default message (e.g. <tt>activemodel.errors.messages.MESSAGE</tt>). The translated model name,
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb
index 46af8ca9de..478f887043 100644
--- a/activemodel/lib/active_model/lint.rb
+++ b/activemodel/lib/active_model/lint.rb
@@ -2,7 +2,7 @@ require "test/unit"
require "test/unit/ui/console/testrunner"
# You can test whether an object is compliant with the ActiveModel API by
-# calling ActiveModel::Compliance.test(object). It will emit a Test::Unit
+# calling ActiveModel::Lint.test(object). It will emit a Test::Unit
# output that tells you whether your object is fully compliant, or if not,
# which aspects of the API are not implemented.
#
@@ -13,7 +13,6 @@ require "test/unit/ui/console/testrunner"
#
# Objects you pass in are expected to return a compliant object from a
# call to to_model. It is perfectly fine for to_model to return self.
-
module ActiveModel
module Lint
def self.test(object, verbosity = 2, output = STDOUT)
@@ -59,7 +58,7 @@ module ActiveModel
end
def test_destroyed?
- assert @object.respond_to?(:new_record?), "The model should respond to destroyed?"
+ assert @object.respond_to?(:destroyed?), "The model should respond to destroyed?"
assert_boolean "destroyed?", @object.destroyed?
end
@@ -93,4 +92,4 @@ module ActiveModel
include Errors
end
end
-end \ No newline at end of file
+end
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 036c1319c7..a1b6606e3e 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1660,36 +1660,10 @@ module ActiveRecord #:nodoc:
# single-table inheritance model that makes it possible to create
# objects of different types from the same table.
def instantiate(record)
- object =
- if subclass_name = record[inheritance_column]
- # No type given.
- if subclass_name.empty?
- allocate
+ object = find_sti_class(record[inheritance_column]).allocate
- else
- # Ignore type if no column is present since it was probably
- # pulled in from a sloppy join.
- unless columns_hash.include?(inheritance_column)
- allocate
-
- else
- begin
- compute_type(subclass_name).allocate
- rescue NameError
- raise SubclassNotFound,
- "The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
- "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
- "Please rename this column if you didn't intend it to be used for storing the inheritance class " +
- "or overwrite #{self.to_s}.inheritance_column to use another column for that information."
- end
- end
- end
- else
- allocate
- end
-
- object.instance_variable_set("@attributes", record)
- object.instance_variable_set("@attributes_cache", Hash.new)
+ object.instance_variable_set(:'@attributes', record)
+ object.instance_variable_set(:'@attributes_cache', {})
object.send(:_run_find_callbacks)
object.send(:_run_initialize_callbacks)
@@ -1697,6 +1671,22 @@ module ActiveRecord #:nodoc:
object
end
+ def find_sti_class(type_name)
+ if type_name.blank? || !columns_hash.include?(inheritance_column)
+ self
+ else
+ begin
+ compute_type(type_name)
+ rescue NameError
+ raise SubclassNotFound,
+ "The single-table inheritance mechanism failed to locate the subclass: '#{type_name}'. " +
+ "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
+ "Please rename this column if you didn't intend it to be used for storing the inheritance class " +
+ "or overwrite #{name}.inheritance_column to use another column for that information."
+ end
+ end
+ end
+
# Nest the type name in the same module as this class.
# Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo
def type_name_with_module(type_name)
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index ddcbba032f..ad36ff22e3 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -65,12 +65,15 @@ module ActiveRecord
raise
end
end
+
MysqlCompat.define_all_hashes_method!
mysql = Mysql.init
mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslca] || config[:sslkey]
- ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)
+ default_flags = Mysql.const_defined?(:CLIENT_MULTI_RESULTS) ? Mysql::CLIENT_MULTI_RESULTS : 0
+ options = [host, username, password, database, port, socket, default_flags]
+ ConnectionAdapters::MysqlAdapter.new(mysql, logger, options, config)
end
end
diff --git a/activerecord/test/cases/connection_test_mysql.rb b/activerecord/test/cases/connection_test_mysql.rb
index f79ee2f1f7..8e4842a1b6 100644
--- a/activerecord/test/cases/connection_test_mysql.rb
+++ b/activerecord/test/cases/connection_test_mysql.rb
@@ -41,6 +41,14 @@ class MysqlConnectionTest < ActiveRecord::TestCase
sleep 2
@connection.verify!
assert @connection.active?
+ end
+
+ # Test that MySQL allows multiple results for stored procedures
+ if Mysql.const_defined?(:CLIENT_MULTI_RESULTS)
+ def test_multi_results
+ rows = ActiveRecord::Base.connection.select_rows('CALL ten();')
+ assert_equal 10, rows[0][0].to_i, "ten() did not return 10 as expected: #{rows.inspect}"
+ end
end
private
diff --git a/activerecord/test/schema/mysql_specific_schema.rb b/activerecord/test/schema/mysql_specific_schema.rb
index f44c33ae67..c78d99f4af 100644
--- a/activerecord/test/schema/mysql_specific_schema.rb
+++ b/activerecord/test/schema/mysql_specific_schema.rb
@@ -9,4 +9,16 @@ ActiveRecord::Schema.define do
t.text :medium_text, :limit => 16777215
t.text :long_text, :limit => 2147483647
end
+
+ ActiveRecord::Base.connection.execute <<-SQL
+DROP PROCEDURE IF EXISTS ten;
+SQL
+
+ ActiveRecord::Base.connection.execute <<-SQL
+CREATE PROCEDURE ten() SQL SECURITY INVOKER
+BEGIN
+ select 10;
+END
+SQL
+
end
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index d4d282e273..67b69fa505 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -93,9 +93,9 @@ module ActiveResource
# content-type of the error-block received
def load_remote_errors(remote_errors, save_cache = false ) #:nodoc:
case remote_errors.response['Content-Type']
- when 'application/xml'
+ when /xml/
errors.from_xml(remote_errors.response.body, save_cache)
- when 'application/json'
+ when /json/
errors.from_json(remote_errors.response.body, save_cache)
end
end
diff --git a/activeresource/test/cases/base_errors_test.rb b/activeresource/test/cases/base_errors_test.rb
index eca00e9ca8..1eb7765132 100644
--- a/activeresource/test/cases/base_errors_test.rb
+++ b/activeresource/test/cases/base_errors_test.rb
@@ -4,8 +4,8 @@ require "fixtures/person"
class BaseErrorsTest < Test::Unit::TestCase
def setup
ActiveResource::HttpMock.respond_to do |mock|
- mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml'}
- mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json'}
+ mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml; charset=utf-8'}
+ mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json; charset=utf-8'}
end
end
diff --git a/activesupport/lib/active_support/mini.rb b/activesupport/lib/active_support/mini.rb
deleted file mode 100644
index b787650655..0000000000
--- a/activesupport/lib/active_support/mini.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-$LOAD_PATH.unshift File.dirname(__FILE__)
-
-# whole object.rb pulls up rarely used introspection extensions
-require "core_ext/object/blank"
-require "core_ext/object/metaclass"
-require 'core_ext/array'
-require 'core_ext/hash'
-require 'core_ext/module/attribute_accessors'
-require 'core_ext/string/inflections'
diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb
index 847ab0152b..17bacd8441 100644
--- a/activesupport/lib/active_support/xml_mini/nokogiri.rb
+++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb
@@ -18,7 +18,7 @@ module ActiveSupport
{}
else
data.ungetc(char)
- doc = Nokogiri::XML(data)
+ doc = Nokogiri::XML(data) { |cfg| cfg.noblanks }
raise doc.errors.first if doc.errors.length > 0
doc.to_hash
end
@@ -39,33 +39,25 @@ module ActiveSupport
# hash::
# Hash to merge the converted element into.
def to_hash(hash = {})
- hash[name] ||= attributes_as_hash
+ attributes = attributes_as_hash
+ if hash[name]
+ hash[name] = [hash[name]].flatten
+ hash[name] << attributes
+ else
+ hash[name] ||= attributes
+ end
- walker = lambda { |memo, parent, child, callback|
- next if child.blank? && 'file' != parent['type']
+ children.each { |child|
+ next if child.blank? && 'file' != self['type']
- if child.text?
- (memo[CONTENT_ROOT] ||= '') << child.content
+ if child.text? || child.cdata?
+ (attributes[CONTENT_ROOT] ||= '') << child.content
next
end
- name = child.name
-
- child_hash = child.attributes_as_hash
- if memo[name]
- memo[name] = [memo[name]].flatten
- memo[name] << child_hash
- else
- memo[name] = child_hash
- end
-
- # Recursively walk children
- child.children.each { |c|
- callback.call(child_hash, child, c, callback)
- }
+ child.to_hash attributes
}
- children.each { |c| walker.call(hash[name], self, c, walker) }
hash
end
diff --git a/activesupport/test/xml_mini/nokogiri_engine_test.rb b/activesupport/test/xml_mini/nokogiri_engine_test.rb
index 1eeff73d32..e16f36acee 100644
--- a/activesupport/test/xml_mini/nokogiri_engine_test.rb
+++ b/activesupport/test/xml_mini/nokogiri_engine_test.rb
@@ -159,6 +159,17 @@ class NokogiriEngineTest < Test::Unit::TestCase
XmlMini.parse(io)
end
+ def test_children_with_cdata
+ assert_equal_rexml(<<-eoxml)
+ <root>
+ <products>
+ hello <![CDATA[everyone]]>
+ morning
+ </products>
+ </root>
+ eoxml
+ end
+
private
def assert_equal_rexml(xml)
hash = XmlMini.with_backend('REXML') { XmlMini.parse(xml) }
diff --git a/ci/ci_build.rb b/ci/ci_build.rb
index 101edce77b..ab627b93e6 100755
--- a/ci/ci_build.rb
+++ b/ci/ci_build.rb
@@ -65,7 +65,7 @@ cd "#{root_dir}/actionpack" do
puts
puts "[CruiseControl] Building ActionPack"
puts
- build_results[:actionpack] = system 'rake'
+ build_results[:actionpack] = system 'gem bundle && rake'
end
cd "#{root_dir}/actionmailer" do
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb
index 879abb1c41..2a196f65ea 100644
--- a/railties/lib/generators.rb
+++ b/railties/lib/generators.rb
@@ -1,17 +1,15 @@
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
-$:.unshift(activesupport_path) if File.directory?(activesupport_path)
-
-begin
- require 'active_support/mini'
-rescue LoadError
- require 'rubygems'
- gem 'activesupport'
- require 'active_support/mini'
-end
-
-$:.unshift(File.dirname(__FILE__))
-
-require 'vendor/thor-0.11.6/lib/thor'
+$LOAD_PATH.unshift(activesupport_path) if File.directory?(activesupport_path)
+require 'active_support'
+require 'active_support/core_ext/object/blank'
+require 'active_support/core_ext/object/metaclass'
+require 'active_support/core_ext/array'
+require 'active_support/core_ext/hash'
+require 'active_support/core_ext/module/attribute_accessors'
+require 'active_support/core_ext/string/inflections'
+
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.11.6/lib")
require 'generators/base'
require 'generators/named_base'
diff --git a/railties/lib/generators/base.rb b/railties/lib/generators/base.rb
index c5d769b6ed..cb6a129264 100644
--- a/railties/lib/generators/base.rb
+++ b/railties/lib/generators/base.rb
@@ -1,3 +1,4 @@
+require 'thor'
require 'generators/actions'
module Rails
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index a258574dce..2a9d680c6a 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -9,10 +9,12 @@ else
end
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
+require 'generators'
+
+require 'rubygems'
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../../activerecord/lib"
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../../actionpack/lib"
-require 'generators'
-require 'activerecord'
+require 'active_record'
require 'action_dispatch'
CURRENT_PATH = File.expand_path(Dir.pwd)
diff --git a/railties/test/initializer/test_helper.rb b/railties/test/initializer/test_helper.rb
index 4cb9c1b814..f6a2547efc 100644
--- a/railties/test/initializer/test_helper.rb
+++ b/railties/test/initializer/test_helper.rb
@@ -2,16 +2,16 @@
# boot from scratch in vendored mode. This file should really only be
# required in test cases that use the isolation helper so that requires
# can be reset correctly.
-RAILS_ROOT = File.join(File.dirname(__FILE__), "root")
-RAILS_FRAMEWORK_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
+RAILS_ROOT = "#{File.dirname(__FILE__)}/root"
+RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..")
require 'rubygems'
gem 'rack', '~> 1.0.0'
require "test/unit"
# We are purposely avoiding adding things to the load path to catch bugs that only happen in the genuine article
-require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'isolation')
-require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'declarative')
+require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/isolation"
+require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/declarative"
class Test::Unit::TestCase
extend ActiveSupport::Testing::Declarative
@@ -38,7 +38,7 @@ module Rails
def boot!
# Require the initializer
- require File.join(RAILS_FRAMEWORK_ROOT, 'railties', 'lib', 'initializer')
+ require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
# Run the initializer the same way boot.rb does it
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
@@ -48,4 +48,4 @@ module Rails
end
# All that for this:
-Rails.boot! \ No newline at end of file
+Rails.boot!