aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb9
-rw-r--r--actionpack/lib/action_dispatch/middleware/debug_exceptions.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/params_parser.rb2
-rw-r--r--actionpack/lib/action_view/renderer/template_renderer.rb2
-rw-r--r--actionpack/test/controller/routing_test.rb4
-rw-r--r--actionpack/test/dispatch/request_id_test.rb2
-rw-r--r--actionpack/test/template/render_test.rb15
-rw-r--r--activemodel/test/cases/mass_assignment_security/sanitizer_test.rb4
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb1
-rw-r--r--activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb32
-rw-r--r--activerecord/lib/active_record/attribute_methods/primary_key.rb9
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb28
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb10
-rw-r--r--activerecord/lib/active_record/model_schema.rb55
-rw-r--r--activerecord/test/cases/associations/eager_load_nested_include_test.rb1
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb8
-rw-r--r--activerecord/test/cases/base_test.rb161
-rw-r--r--activerecord/test/cases/locking_test.rb42
-rw-r--r--activerecord/test/cases/named_scope_test.rb1
-rw-r--r--activerecord/test/support/connection.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/array.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/array/random_access.rb30
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb21
-rw-r--r--activesupport/lib/active_support/core_ext/kernel/singleton_class.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb42
-rw-r--r--activesupport/lib/active_support/ruby/shim.rb4
-rw-r--r--activesupport/test/core_ext/array_ext_test.rb28
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb11
-rw-r--r--activesupport/test/core_ext/kernel_test.rb7
-rw-r--r--railties/CHANGELOG.md26
-rw-r--r--railties/guides/source/active_support_core_extensions.textile112
-rw-r--r--railties/guides/source/command_line.textile14
-rw-r--r--railties/lib/rails/generators/base.rb6
-rw-r--r--railties/lib/rails/test_unit/sub_test_task.rb36
-rw-r--r--railties/lib/rails/test_unit/testing.rake60
-rw-r--r--railties/test/application/rake_test.rb17
36 files changed, 117 insertions, 697 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 5797c63924..84732085f0 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -121,14 +121,7 @@ module ActionDispatch # :nodoc:
def body=(body)
@blank = true if body == EMPTY
- # Explicitly check for strings. This is *wrong* theoretically
- # but if we don't check this, the performance on string bodies
- # is bad on Ruby 1.8 (because strings responds to each then).
- @body = if body.respond_to?(:to_str) || !body.respond_to?(:each)
- [body]
- else
- body
- end
+ @body = body.respond_to?(:each) ? body : [body]
end
def body_parts
diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
index dabbabb1e6..b903f98761 100644
--- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
@@ -76,7 +76,7 @@ module ActionDispatch
end
def stderr_logger
- @stderr_logger ||= Logger.new($stderr)
+ @stderr_logger ||= ActiveSupport::Logger.new($stderr)
end
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb
index 6ded9dbfed..1cb803ffb9 100644
--- a/actionpack/lib/action_dispatch/middleware/params_parser.rb
+++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb
@@ -69,7 +69,7 @@ module ActionDispatch
end
def logger(env)
- env['action_dispatch.logger'] || Logger.new($stderr)
+ env['action_dispatch.logger'] || ActiveSupport::Logger.new($stderr)
end
end
end
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb
index 3e3a44b432..06148ccc98 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/template_renderer.rb
@@ -25,6 +25,8 @@ module ActionView
elsif options.key?(:template)
options[:template].respond_to?(:render) ?
options[:template] : find_template(options[:template], options[:prefixes], false, keys, @details)
+ else
+ raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file or :text option."
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index f40d663ae8..a60da65ae5 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -81,10 +81,6 @@ class LegacyRouteSetTests < Test::Unit::TestCase
@rs = ::ActionDispatch::Routing::RouteSet.new
end
- def teardown
- @rs.clear!
- end
-
def test_class_and_lambda_constraints
subdomain = Class.new {
def matches? request
diff --git a/actionpack/test/dispatch/request_id_test.rb b/actionpack/test/dispatch/request_id_test.rb
index e2a38af233..4b98cd32f2 100644
--- a/actionpack/test/dispatch/request_id_test.rb
+++ b/actionpack/test/dispatch/request_id_test.rb
@@ -14,7 +14,7 @@ class RequestIdTest < ActiveSupport::TestCase
end
test "generating a request id when none is supplied" do
- assert_match /\w+-\w+-\w+-\w+-\w+/, stub_request.uuid
+ assert_match(/\w+-\w+-\w+-\w+-\w+/, stub_request.uuid)
end
private
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 2ba86306f4..761bcf61f2 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -20,6 +20,13 @@ module RenderTestCases
assert_equal ORIGINAL_LOCALES, I18n.available_locales.map {|l| l.to_s }.sort
end
+ def test_render_without_options
+ @view.render()
+ flunk "Render did not raise ArgumentError"
+ rescue ArgumentError => e
+ assert_match "You invoked render but did not give any of :partial, :template, :inline, :file or :text option.", e.message
+ end
+
def test_render_file
assert_equal "Hello world!", @view.render(:file => "test/hello_world")
end
@@ -43,21 +50,21 @@ module RenderTestCases
assert_match "<h1>No Comment</h1>", @view.render(:template => "comments/empty", :formats => [:html])
assert_match "<error>No Comment</error>", @view.render(:template => "comments/empty", :formats => [:xml])
end
-
+
def test_render_file_with_locale
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => [:de])
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => :de)
end
-
+
def test_render_template_with_locale
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:template => "comments/empty", :locale => [:de])
end
-
+
def test_render_file_with_handlers
assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => [:builder])
assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => :builder)
end
-
+
def test_render_template_with_handlers
assert_equal "<h1>No Comment</h1>\n", @view.render(:template => "comments/empty", :handlers => [:builder])
end
diff --git a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb
index 676937b5e1..3660b9b1e5 100644
--- a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb
+++ b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb
@@ -1,5 +1,5 @@
require "cases/helper"
-require 'logger'
+require 'active_support/logger'
require 'active_support/core_ext/object/inclusion'
class SanitizerTest < ActiveModel::TestCase
@@ -28,7 +28,7 @@ class SanitizerTest < ActiveModel::TestCase
test "debug mass assignment removal with LoggerSanitizer" do
original_attributes = { 'first_name' => 'allowed', 'admin' => 'denied' }
log = StringIO.new
- self.logger = Logger.new(log)
+ self.logger = ActiveSupport::Logger.new(log)
@logger_sanitizer.sanitize(original_attributes, @authorizer)
assert_match(/admin/, log.string, "Should log removed attributes: #{log.string}")
end
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 650fa3fc42..131ef09f57 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -16,7 +16,6 @@ module ActiveRecord
include TimeZoneConversion
include Dirty
include Serialization
- include DeprecatedUnderscoreRead
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
diff --git a/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb b/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb
deleted file mode 100644
index 0eb0db65b1..0000000000
--- a/activerecord/lib/active_record/attribute_methods/deprecated_underscore_read.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'active_support/concern'
-require 'active_support/deprecation'
-
-module ActiveRecord
- module AttributeMethods
- module DeprecatedUnderscoreRead
- extend ActiveSupport::Concern
-
- included do
- attribute_method_prefix "_"
- end
-
- module ClassMethods
- protected
-
- def define_method__attribute(attr_name)
- # Do nothing, let it hit method missing instead.
- end
- end
-
- protected
-
- def _attribute(attr_name)
- ActiveSupport::Deprecation.warn(
- "You have called '_#{attr_name}'. This is deprecated. Please use " \
- "either '#{attr_name}' or read_attribute('#{attr_name}')."
- )
- read_attribute(attr_name)
- end
- end
- end
-end
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index 5d37088d98..a7785f8786 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -80,10 +80,6 @@ module ActiveRecord
end
end
- def original_primary_key #:nodoc:
- deprecated_original_property_getter :primary_key
- end
-
# Sets the name of the primary key column.
#
# class Project < ActiveRecord::Base
@@ -103,11 +99,6 @@ module ActiveRecord
@primary_key = value && value.to_s
@quoted_primary_key = nil
end
-
- def set_primary_key(value = nil, &block) #:nodoc:
- deprecated_property_setter :primary_key, value, block
- @quoted_primary_key = nil
- end
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 698da34d26..401398c56b 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -162,34 +162,6 @@ module ActiveRecord
end
end
- def columns
- with_connection do |c|
- c.schema_cache.columns
- end
- end
- deprecate :columns
-
- def columns_hash
- with_connection do |c|
- c.schema_cache.columns_hash
- end
- end
- deprecate :columns_hash
-
- def primary_keys
- with_connection do |c|
- c.schema_cache.primary_keys
- end
- end
- deprecate :primary_keys
-
- def clear_cache!
- with_connection do |c|
- c.schema_cache.clear!
- end
- end
- deprecate :clear_cache!
-
# Return any checked-out connections back to the pool by threads that
# are no longer alive.
def clear_stale_cached_connections!
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index ce0a165660..7815889b47 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -144,26 +144,18 @@ module ActiveRecord
lock_optimistically && columns_hash[locking_column]
end
+ # Set the column to use for optimistic locking. Defaults to +lock_version+.
def locking_column=(value)
@original_locking_column = @locking_column if defined?(@locking_column)
@locking_column = value.to_s
end
- # Set the column to use for optimistic locking. Defaults to +lock_version+.
- def set_locking_column(value = nil, &block)
- deprecated_property_setter :locking_column, value, block
- end
-
# The version column used for optimistic locking. Defaults to +lock_version+.
def locking_column
reset_locking_column unless defined?(@locking_column)
@locking_column
end
- def original_locking_column #:nodoc:
- deprecated_original_property_getter :locking_column
- end
-
# Quote the column name used for optimistic locking.
def quoted_locking_column
connection.quote_column_name(locking_column)
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 36417d89f7..1de820b3a6 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -105,10 +105,6 @@ module ActiveRecord
@table_name
end
- def original_table_name #:nodoc:
- deprecated_original_property_getter :table_name
- end
-
# Sets the table name explicitly. Example:
#
# class Project < ActiveRecord::Base
@@ -125,13 +121,6 @@ module ActiveRecord
@relation = Relation.new(self, arel_table)
end
- def set_table_name(value = nil, &block) #:nodoc:
- deprecated_property_setter :table_name, value, block
- @quoted_table_name = nil
- @arel_table = nil
- @relation = Relation.new(self, arel_table)
- end
-
# Returns a quoted version of the table name, used to construct SQL statements.
def quoted_table_name
@quoted_table_name ||= connection.quote_table_name(table_name)
@@ -161,20 +150,12 @@ module ActiveRecord
end
end
- def original_inheritance_column #:nodoc:
- deprecated_original_property_getter :inheritance_column
- end
-
# Sets the value of inheritance_column
def inheritance_column=(value)
@original_inheritance_column = inheritance_column
@inheritance_column = value.to_s
end
- def set_inheritance_column(value = nil, &block) #:nodoc:
- deprecated_property_setter :inheritance_column, value, block
- end
-
def sequence_name
if base_class == self
@sequence_name ||= reset_sequence_name
@@ -183,10 +164,6 @@ module ActiveRecord
end
end
- def original_sequence_name #:nodoc:
- deprecated_original_property_getter :sequence_name
- end
-
def reset_sequence_name #:nodoc:
self.sequence_name = connection.default_sequence_name(table_name, primary_key)
end
@@ -210,10 +187,6 @@ module ActiveRecord
@sequence_name = value.to_s
end
- def set_sequence_name(value = nil, &block) #:nodoc:
- deprecated_property_setter :sequence_name, value, block
- end
-
# Indicates whether the table associated with this class exists
def table_exists?
connection.schema_cache.table_exists?(table_name)
@@ -329,34 +302,6 @@ module ActiveRecord
base.table_name
end
end
-
- def deprecated_property_setter(property, value, block)
- if block
- ActiveSupport::Deprecation.warn(
- "Calling set_#{property} is deprecated. If you need to lazily evaluate " \
- "the #{property}, define your own `self.#{property}` class method. You can use `super` " \
- "to get the default #{property} where you would have called `original_#{property}`."
- )
-
- define_attr_method property, value, false, &block
- else
- ActiveSupport::Deprecation.warn(
- "Calling set_#{property} is deprecated. Please use `self.#{property} = 'the_name'` instead."
- )
-
- define_attr_method property, value, false
- end
- end
-
- def deprecated_original_property_getter(property)
- ActiveSupport::Deprecation.warn("original_#{property} is deprecated. Define self.#{property} and call super instead.")
-
- if !instance_variable_defined?("@original_#{property}") && respond_to?("reset_#{property}")
- send("reset_#{property}")
- else
- instance_variable_get("@original_#{property}")
- end
- end
end
end
end
diff --git a/activerecord/test/cases/associations/eager_load_nested_include_test.rb b/activerecord/test/cases/associations/eager_load_nested_include_test.rb
index 2cf9f89c3c..1e1958410c 100644
--- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb
+++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb
@@ -6,7 +6,6 @@ require 'models/comment'
require 'models/category'
require 'models/categorization'
require 'models/tagging'
-require 'active_support/core_ext/array/random_access'
module Remembered
extend ActiveSupport::Concern
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 5e9f8028e9..8e509a9792 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -102,7 +102,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase
def test_respond_to?
topic = Topic.find(1)
assert_respond_to topic, "title"
- assert_respond_to topic, "_title"
assert_respond_to topic, "title?"
assert_respond_to topic, "title="
assert_respond_to topic, :title
@@ -114,19 +113,12 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert !topic.respond_to?(:nothingness)
end
- def test_deprecated_underscore_method
- topic = Topic.find(1)
- assert_equal topic.title, assert_deprecated { topic._title }
- end
-
def test_respond_to_with_custom_primary_key
keyboard = Keyboard.create
assert_not_nil keyboard.key_number
assert_equal keyboard.key_number, keyboard.id
assert keyboard.respond_to?('key_number')
- assert keyboard.respond_to?('_key_number')
assert keyboard.respond_to?('id')
- assert keyboard.respond_to?('_id')
end
# Syck calls respond_to? before actually calling initialize
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 2e2ab77f6e..f102634ef1 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1383,17 +1383,6 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal dev, dev.reload
end
- def test_set_table_name_with_value
- k = Class.new( ActiveRecord::Base )
- k.table_name = "foo"
- assert_equal "foo", k.table_name
-
- assert_deprecated do
- k.set_table_name "bar"
- end
- assert_equal "bar", k.table_name
- end
-
def test_switching_between_table_name
assert_difference("GoodJoke.count") do
Joke.table_name = "cold_jokes"
@@ -1416,17 +1405,6 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal klass.connection.quote_table_name("bar"), klass.quoted_table_name
end
- def test_set_table_name_with_block
- k = Class.new( ActiveRecord::Base )
- assert_deprecated do
- k.set_table_name "foo"
- k.set_table_name do
- ActiveSupport::Deprecation.silence { original_table_name } + "ks"
- end
- end
- assert_equal "fooks", k.table_name
- end
-
def test_set_table_name_with_inheritance
k = Class.new( ActiveRecord::Base )
def k.name; "Foo"; end
@@ -1434,145 +1412,6 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal "foosks", k.table_name
end
- def test_original_table_name
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.table_name = "bar"
-
- assert_deprecated do
- assert_equal "foos", k.original_table_name
- end
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "omg"
- k.table_name = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_table_name
- end
- end
-
- def test_set_primary_key_with_value
- k = Class.new( ActiveRecord::Base )
- k.primary_key = "foo"
- assert_equal "foo", k.primary_key
-
- assert_deprecated do
- k.set_primary_key "bar"
- end
- assert_equal "bar", k.primary_key
- end
-
- def test_set_primary_key_with_block
- k = Class.new( ActiveRecord::Base )
- k.primary_key = 'id'
-
- assert_deprecated do
- k.set_primary_key do
- "sys_" + ActiveSupport::Deprecation.silence { original_primary_key }
- end
- end
- assert_equal "sys_id", k.primary_key
- end
-
- def test_original_primary_key
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.table_name = "posts"
- k.primary_key = "bar"
-
- assert_deprecated do
- assert_equal "id", k.original_primary_key
- end
-
- k = Class.new(ActiveRecord::Base)
- k.primary_key = "omg"
- k.primary_key = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_primary_key
- end
- end
-
- def test_set_inheritance_column_with_value
- k = Class.new( ActiveRecord::Base )
- k.inheritance_column = "foo"
- assert_equal "foo", k.inheritance_column
-
- assert_deprecated do
- k.set_inheritance_column "bar"
- end
- assert_equal "bar", k.inheritance_column
- end
-
- def test_set_inheritance_column_with_block
- k = Class.new( ActiveRecord::Base )
- assert_deprecated do
- k.set_inheritance_column do
- ActiveSupport::Deprecation.silence { original_inheritance_column } + "_id"
- end
- end
- assert_equal "type_id", k.inheritance_column
- end
-
- def test_original_inheritance_column
- k = Class.new(ActiveRecord::Base)
- def k.name; "Foo"; end
- k.inheritance_column = "omg"
-
- assert_deprecated do
- assert_equal "type", k.original_inheritance_column
- end
- end
-
- def test_set_sequence_name_with_value
- k = Class.new( ActiveRecord::Base )
- k.sequence_name = "foo"
- assert_equal "foo", k.sequence_name
-
- assert_deprecated do
- k.set_sequence_name "bar"
- end
- assert_equal "bar", k.sequence_name
- end
-
- def test_set_sequence_name_with_block
- k = Class.new( ActiveRecord::Base )
- k.table_name = "projects"
- orig_name = k.sequence_name
- return skip "sequences not supported by db" unless orig_name
-
- assert_deprecated do
- k.set_sequence_name do
- ActiveSupport::Deprecation.silence { original_sequence_name } + "_lol"
- end
- end
- assert_equal orig_name + "_lol", k.sequence_name
- end
-
- def test_original_sequence_name
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- orig_name = k.sequence_name
- return skip "sequences not supported by db" unless orig_name
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- k.sequence_name = "omg"
-
- assert_deprecated do
- assert_equal orig_name, k.original_sequence_name
- end
-
- k = Class.new(ActiveRecord::Base)
- k.table_name = "projects"
- k.sequence_name = "omg"
- k.sequence_name = "wtf"
- assert_deprecated do
- assert_equal "omg", k.original_sequence_name
- end
- end
-
def test_sequence_name_with_abstract_class
ak = Class.new(ActiveRecord::Base)
ak.abstract_class = true
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 5978b244d4..f7ee83998d 100644
--- a/activerecord/test/cases/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -226,48 +226,6 @@ class OptimisticLockingTest < ActiveRecord::TestCase
end
end
-class SetLockingColumnTest < ActiveRecord::TestCase
- def test_set_set_locking_column_with_value
- k = Class.new( ActiveRecord::Base )
- k.locking_column = "foo"
- assert_equal "foo", k.locking_column
-
- assert_deprecated do
- k.set_locking_column "bar"
- end
- assert_equal "bar", k.locking_column
- end
-
- def test_set_locking_column_with_block
- k = Class.new( ActiveRecord::Base )
- k.locking_column = 'foo'
-
- assert_deprecated do
- k.set_locking_column do
- "lock_" + ActiveSupport::Deprecation.silence { original_locking_column }
- end
- end
- assert_equal "lock_foo", k.locking_column
- end
-
- def test_original_locking_column
- k = Class.new(ActiveRecord::Base)
- k.locking_column = "bar"
-
- assert_deprecated do
- assert_equal ActiveRecord::Locking::Optimistic::ClassMethods::DEFAULT_LOCKING_COLUMN, k.original_locking_column
- end
-
- k = Class.new(ActiveRecord::Base)
- k.locking_column = "omg"
- k.locking_column = "wtf"
-
- assert_deprecated do
- assert_equal "omg", k.original_locking_column
- end
- end
-end
-
class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase
fixtures :people, :legacy_things, :references
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 0eb3d900bd..e17ba76437 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -1,5 +1,4 @@
require "cases/helper"
-require 'active_support/core_ext/array/random_access'
require 'models/post'
require 'models/topic'
require 'models/comment'
diff --git a/activerecord/test/support/connection.rb b/activerecord/test/support/connection.rb
index a39794fa39..56369da346 100644
--- a/activerecord/test/support/connection.rb
+++ b/activerecord/test/support/connection.rb
@@ -1,4 +1,4 @@
-require 'logger'
+require 'active_support/logger'
require_dependency 'models/course'
module ARTest
@@ -12,7 +12,7 @@ module ARTest
def self.connect
puts "Using #{connection_name} with Identity Map #{ActiveRecord::IdentityMap.enabled? ? 'on' : 'off'}"
- ActiveRecord::Base.logger = Logger.new("debug.log")
+ ActiveRecord::Base.logger = ActiveSupport::Logger.new("debug.log")
ActiveRecord::Base.configurations = connection_config
ActiveRecord::Base.establish_connection 'arunit'
Course.establish_connection 'arunit2'
diff --git a/activesupport/lib/active_support/core_ext/array.rb b/activesupport/lib/active_support/core_ext/array.rb
index 268c9bed4c..79ba79192a 100644
--- a/activesupport/lib/active_support/core_ext/array.rb
+++ b/activesupport/lib/active_support/core_ext/array.rb
@@ -4,5 +4,4 @@ require 'active_support/core_ext/array/uniq_by'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/array/grouping'
-require 'active_support/core_ext/array/random_access'
require 'active_support/core_ext/array/prepend_and_append'
diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb
deleted file mode 100644
index bb1807a68a..0000000000
--- a/activesupport/lib/active_support/core_ext/array/random_access.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-class Array
- # Backport of Array#sample based on Marc-Andre Lafortune's https://github.com/marcandre/backports/
- # Returns a random element or +n+ random elements from the array.
- # If the array is empty and +n+ is nil, returns <tt>nil</tt>.
- # If +n+ is passed and its value is less than 0, it raises an +ArgumentError+ exception.
- # If the value of +n+ is equal or greater than 0 it returns <tt>[]</tt>.
- #
- # [1,2,3,4,5,6].sample # => 4
- # [1,2,3,4,5,6].sample(3) # => [2, 4, 5]
- # [1,2,3,4,5,6].sample(-3) # => ArgumentError: negative array size
- # [].sample # => nil
- # [].sample(3) # => []
- def sample(n=nil)
- return self[Kernel.rand(size)] if n.nil?
- n = n.to_int
- rescue Exception => e
- raise TypeError, "Coercion error: #{n.inspect}.to_int => Integer failed:\n(#{e.message})"
- else
- raise TypeError, "Coercion error: obj.to_int did NOT return an Integer (was #{n.class})" unless n.kind_of? Integer
- raise ArgumentError, "negative array size" if n < 0
- n = size if n > size
- result = Array.new(self)
- n.times do |i|
- r = i + Kernel.rand(size - i)
- result[i], result[r] = result[r], result[i]
- end
- result[n..size] = []
- result
- end unless method_defined? :sample
-end
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index ccd0e9692d..3f13468e4d 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -33,27 +33,6 @@ module Enumerable
collect { |element| element.send(method) }
end
- # Iterates over a collection, passing the current element *and* the
- # +memo+ to the block. Handy for building up hashes or
- # reducing collections down to one object. Examples:
- #
- # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
- # # => {'foo' => 'FOO', 'bar' => 'BAR'}
- #
- # *Note* that you can't use immutable objects like numbers, true or false as
- # the memo. You would think the following returns 120, but since the memo is
- # never changed, it does not.
- #
- # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
- #
- def each_with_object(memo)
- return to_enum :each_with_object, memo unless block_given?
- each do |element|
- yield element, memo
- end
- memo
- end unless [].respond_to?(:each_with_object)
-
# Convert an enumerable to a hash. Examples:
#
# people.index_by(&:login)
diff --git a/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
index 33612155fb..9bbf1bbd73 100644
--- a/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
+++ b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
@@ -1,11 +1,4 @@
module Kernel
- # Returns the object's singleton class.
- def singleton_class
- class << self
- self
- end
- end unless respond_to?(:singleton_class) # exists in 1.9.2
-
# class_eval on an object acts like singleton_class.class_eval.
def class_eval(*args, &block)
singleton_class.class_eval(*args, &block)
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index c6d861d124..6cb2ea68b3 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -6,33 +6,21 @@ class ERB
HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
- # Detect whether 1.9 can transcode with XML escaping.
- if '"&gt;&lt;&amp;&quot;"' == ('><&"'.encode('utf-8', :xml => :attr) rescue false)
- # A utility method for escaping HTML tag characters.
- # This method is also aliased as <tt>h</tt>.
- #
- # In your ERB templates, use this method to escape any unsafe content. For example:
- # <%=h @person.name %>
- #
- # ==== Example:
- # puts html_escape("is a > 0 & a < 10?")
- # # => is a &gt; 0 &amp; a &lt; 10?
- def html_escape(s)
- s = s.to_s
- if s.html_safe?
- s
- else
- s.encode(s.encoding, :xml => :attr)[1...-1].html_safe
- end
- end
- else
- def html_escape(s) #:nodoc:
- s = s.to_s
- if s.html_safe?
- s
- else
- s.gsub(/[&"><]/n) { |special| HTML_ESCAPE[special] }.html_safe
- end
+ # A utility method for escaping HTML tag characters.
+ # This method is also aliased as <tt>h</tt>.
+ #
+ # In your ERB templates, use this method to escape any unsafe content. For example:
+ # <%=h @person.name %>
+ #
+ # ==== Example:
+ # puts html_escape("is a > 0 & a < 10?")
+ # # => is a &gt; 0 &amp; a &lt; 10?
+ def html_escape(s)
+ s = s.to_s
+ if s.html_safe?
+ s
+ else
+ s.encode(s.encoding, :xml => :attr)[1...-1].html_safe
end
end
diff --git a/activesupport/lib/active_support/ruby/shim.rb b/activesupport/lib/active_support/ruby/shim.rb
index 608b3fe4b9..fc37ab84a3 100644
--- a/activesupport/lib/active_support/ruby/shim.rb
+++ b/activesupport/lib/active_support/ruby/shim.rb
@@ -3,7 +3,7 @@
#
# Date next_year, next_month
# DateTime to_date, to_datetime, xmlschema
-# Enumerable group_by, each_with_object, none?
+# Enumerable group_by, none?
# Process Process.daemon
# REXML security fix
# String ord
@@ -19,4 +19,4 @@ require 'active_support/core_ext/string/encoding'
require 'active_support/core_ext/rexml'
require 'active_support/core_ext/time/conversions'
require 'active_support/core_ext/file/path'
-require 'active_support/core_ext/module/method_names' \ No newline at end of file
+require 'active_support/core_ext/module/method_names'
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index 52231aaeb0..6739b4afbd 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -363,34 +363,6 @@ class ArrayUniqByTests < Test::Unit::TestCase
end
end
-class ArrayExtRandomTests < ActiveSupport::TestCase
- def test_sample_from_array
- assert_nil [].sample
- assert_equal [], [].sample(5)
- assert_equal 42, [42].sample
- assert_equal [42], [42].sample(5)
-
- a = [:foo, :bar, 42]
- s = a.sample(2)
- assert_equal 2, s.size
- assert_equal 1, (a-s).size
- assert_equal [], a-(0..20).sum{a.sample(2)}
-
- o = Object.new
- def o.to_int; 1; end
- assert_equal [0], [0].sample(o)
-
- o = Object.new
- assert_raises(TypeError) { [0].sample(o) }
-
- o = Object.new
- def o.to_int; ''; end
- assert_raises(TypeError) { [0].sample(o) }
-
- assert_raises(ArgumentError) { [0].sample(-7) }
- end
-end
-
class ArrayWrapperTests < Test::Unit::TestCase
class FakeCollection
def to_ary
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 7ce7c4d52d..7c2aec3462 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -86,15 +86,6 @@ class EnumerableTests < Test::Unit::TestCase
assert_equal 'abc', ('a'..'c').sum
end
- def test_each_with_object
- enum = GenericEnumerable.new(%w(foo bar))
- result = enum.each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
- assert_equal({'foo' => 'FOO', 'bar' => 'BAR'}, result)
- assert_equal Enumerator, enum.each_with_object({}).class
- result2 = enum.each_with_object({}).each{|str, hsh| hsh[str] = str.upcase}
- assert_equal result, result2
- end
-
def test_index_by
payments = GenericEnumerable.new([ Payment.new(5), Payment.new(15), Payment.new(10) ])
assert_equal({ 5 => Payment.new(5), 15 => Payment.new(15), 10 => Payment.new(10) },
@@ -133,4 +124,4 @@ class EnumerableTests < Test::Unit::TestCase
assert_equal [ "David", "Jamie" ], people.pluck(:name)
end
-end \ No newline at end of file
+end
diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb
index 995bc0751a..73a7179872 100644
--- a/activesupport/test/core_ext/kernel_test.rb
+++ b/activesupport/test/core_ext/kernel_test.rb
@@ -42,11 +42,6 @@ class KernelTest < Test::Unit::TestCase
assert_equal 1, silence_stderr { 1 }
end
- def test_singleton_class
- o = Object.new
- assert_equal class << o; self end, o.singleton_class
- end
-
def test_class_eval
o = Object.new
class << o; @x = 1; end
@@ -112,4 +107,4 @@ class KernelDebuggerTest < Test::Unit::TestCase
ensure
Object.send(:remove_const, "Rails")
end
-end \ No newline at end of file
+end
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 0bd76df6d7..555d466ca4 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -32,19 +32,6 @@
* Remove old 'config.paths.app.controller' API in favor of 'config.paths["app/controller"]' API *Guillermo Iguaran*
-* Rails 3.1.1
-
-* Add jquery-rails to Gemfile of plugins, test/dummy app needs it. Closes #3091. *Santiago Pastorino*
-
-* Add config.assets.initialize_on_precompile which, when set to false, forces
- `rake assets:precompile` to load the application but does not initialize it.
-
- To the app developer, this means configuration add in
- config/initializers/* will not be executed.
-
- Plugins developers need to special case their initializers that are
- meant to be run in the assets group by adding :group => :assets.
-
## Rails 3.1.2 (unreleased) ##
* Engines: don't blow up if db/seeds.rb is missing.
@@ -55,6 +42,19 @@
*GH 2564*
*José Valim*
+
+## Rails 3.1.1 ##
+
+* Add jquery-rails to Gemfile of plugins, test/dummy app needs it. Closes #3091. *Santiago Pastorino*
+
+* Add config.assets.initialize_on_precompile which, when set to false, forces
+ `rake assets:precompile` to load the application but does not initialize it.
+
+ To the app developer, this means configuration add in
+ config/initializers/* will not be executed.
+
+ Plugins developers need to special case their initializers that are
+ meant to be run in the assets group by adding :group => :assets.
## Rails 3.1.0 (August 30, 2011) ##
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 0296e27725..25d8f50a7b 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -177,19 +177,6 @@ end
NOTE: Defined in +active_support/core_ext/object/try.rb+.
-h4. +singleton_class+
-
-The method +singleton_class+ returns the singleton class of the receiver:
-
-<ruby>
-String.singleton_class # => #<Class:String>
-String.new.singleton_class # => #<Class:#<String:0x17a1d1c>>
-</ruby>
-
-WARNING: Fixnums and symbols have no singleton classes, +singleton_class+ raises +TypeError+ on them. Moreover, the singleton classes of +nil+, +true+, and +false+, are +NilClass+, +TrueClass+, and +FalseClass+, respectively.
-
-NOTE: Defined in +active_support/core_ext/kernel/singleton_class.rb+.
-
h4. +class_eval(*args, &block)+
You can evaluate code in the context of any object's singleton class using +class_eval+:
@@ -1851,43 +1838,6 @@ NOTE: Defined in +active_support/core_ext/string/inflections.rb+.
h4(#string-conversions). Conversions
-h5. +ord+
-
-Ruby 1.9 defines +ord+ to be the codepoint of the first character of the receiver. Active Support backports +ord+ for single-byte encodings like ASCII or ISO-8859-1 in Ruby 1.8:
-
-<ruby>
-"a".ord # => 97
-"à".ord # => 224, in ISO-8859-1
-</ruby>
-
-In Ruby 1.8 +ord+ doesn't work in general in UTF8 strings, use the multibyte support in Active Support for that:
-
-<ruby>
-"a".mb_chars.ord # => 97
-"à".mb_chars.ord # => 224, in UTF8
-</ruby>
-
-Note that the 224 is different in both examples. In ISO-8859-1 "à" is represented as a single byte, 224. Its single-character representation in UTF8 has two bytes, namely 195 and 160, but its Unicode codepoint is 224. If we call +ord+ on the UTF8 string "à" the return value will be 195 in Ruby 1.8. That is not an error, because UTF8 is unsupported, the call itself would be bogus.
-
-INFO: +ord+ is equivalent to +getbyte(0)+.
-
-NOTE: Defined in +active_support/core_ext/string/conversions.rb+.
-
-h5. +getbyte+
-
-Active Support backports +getbyte+ from Ruby 1.9:
-
-<ruby>
-"foo".getbyte(0) # => 102, same as "foo".ord
-"foo".getbyte(1) # => 111
-"foo".getbyte(9) # => nil
-"foo".getbyte(-1) # => 111
-</ruby>
-
-INFO: +getbyte+ is equivalent to +[]+.
-
-NOTE: Defined in +active_support/core_ext/string/conversions.rb+.
-
h5. +to_date+, +to_time+, +to_datetime+
The methods +to_date+, +to_time+, and +to_datetime+ are basically convenience wrappers around +Date._parse+:
@@ -1980,20 +1930,6 @@ h3. Extensions to +BigDecimal+
h3. Extensions to +Enumerable+
-h4. +group_by+
-
-Active Support redefines +group_by+ in Ruby 1.8.7 so that it returns an ordered hash as in 1.9:
-
-<ruby>
-entries_by_surname_initial = address_book.group_by do |entry|
- entry.surname.at(0).upcase
-end
-</ruby>
-
-Distinct block return values are added to the hash as they come, so that's the resulting order.
-
-NOTE: Defined in +active_support/core_ext/enumerable.rb+.
-
h4. +sum+
The method +sum+ adds the elements of an enumerable:
@@ -2051,32 +1987,6 @@ people.pluck(:name) # => [ "David Heinemeier Hansson", "Jamie Heinemeier Hansson
NOTE: Defined in +active_support/core_ext/enumerable.rb+.
-h4. +each_with_object+
-
-The +inject+ method offers iteration with an accumulator:
-
-<ruby>
-[2, 3, 4].inject(1) {|product, i| product*i } # => 24
-</ruby>
-
-The block is expected to return the value for the accumulator in the next iteration, and this makes building mutable objects a bit cumbersome:
-
-<ruby>
-[1, 2].inject({}) {|h, i| h[i] = i**2; h} # => {1 => 1, 2 => 4}
-</ruby>
-
-See that spurious "+; h+"?
-
-Active Support backports +each_with_object+ from Ruby 1.9, which addresses that use case. It iterates over the collection, passes the accumulator, and returns the accumulator when done. You normally modify the accumulator in place. The example above would be written this way:
-
-<ruby>
-[1, 2].each_with_object({}) {|i, h| h[i] = i**2} # => {1 => 1, 2 => 4}
-</ruby>
-
-WARNING. Note that the item of the collection and the accumulator come in different order in +inject+ and +each_with_object+.
-
-NOTE: Defined in +active_support/core_ext/enumerable.rb+.
-
h4. +index_by+
The method +index_by+ generates a hash with the elements of an enumerable indexed by some key.
@@ -2148,20 +2058,6 @@ The methods +second+, +third+, +fourth+, and +fifth+ return the corresponding el
NOTE: Defined in +active_support/core_ext/array/access.rb+.
-h4. Random Access
-
-Active Support backports +sample+ from Ruby 1.9:
-
-<ruby>
-shape_type = [Circle, Square, Triangle].sample
-# => Square, for example
-
-shape_types = [Circle, Square, Triangle].sample(2)
-# => [Triangle, Circle], for example
-</ruby>
-
-NOTE: Defined in +active_support/core_ext/array/random_access.rb+.
-
h4. Adding Elements
h5. +prepend+
@@ -2914,14 +2810,6 @@ WARNING: The original +Range#include?+ is still the one aliased to +Range#===+.
NOTE: Defined in +active_support/core_ext/range/include_range.rb+.
-h4. +cover?+
-
-Ruby 1.9 provides +cover?+, and Active Support defines it for previous versions as an alias for +include?+.
-
-The method +include?+ in Ruby 1.9 is different from the one in 1.8 for non-numeric ranges: instead of being based on comparisons between the value and the range's endpoints, it walks the range with +succ+ looking for value. This works better for ranges with holes, but it has different complexity and may not finish in some other cases.
-
-In Ruby 1.9 the old behavior is still available in the new +cover?+, which Active Support backports for forward compatibility. For example, Rails uses +cover?+ for ranges in +validates_inclusion_of+.
-
h4. +overlaps?+
The method +Range#overlaps?+ says whether any two given ranges have non-void intersection:
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index 58855bc80b..fa783edc58 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -381,16 +381,16 @@ h4. +about+
<shell>
$ rake about
About your application's environment
-Ruby version 1.8.7 (x86_64-linux)
+Ruby version 1.9.3 (x86_64-linux)
RubyGems version 1.3.6
Rack version 1.3
-Rails version 3.2.0.beta
+Rails version 4.0.0.beta
JavaScript Runtime Node.js (V8)
-Active Record version 3.2.0.beta
-Action Pack version 3.2.0.beta
-Active Resource version 3.2.0.beta
-Action Mailer version 3.2.0.beta
-Active Support version 3.2.0.beta
+Active Record version 4.0.0.beta
+Action Pack version 4.0.0.beta
+Active Resource version 4.0.0.beta
+Action Mailer version 4.0.0.beta
+Active Support version 4.0.0.beta
Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
Application root /home/foobar/commandsapp
Environment development
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index f38a487a4e..af743a9c51 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -128,13 +128,13 @@ module Rails
#
# ==== Boolean hooks
#
- # In some cases, you want to provide a boolean hook. For example, webrat
+ # In some cases, you may want to provide a boolean hook. For example, webrat
# developers might want to have webrat available on controller generator.
# This can be achieved as:
#
# Rails::Generators::ControllerGenerator.hook_for :webrat, :type => :boolean
#
- # Then, if you want, webrat to be invoked, just supply:
+ # Then, if you want webrat to be invoked, just supply:
#
# rails generate controller Account --webrat
#
@@ -146,7 +146,7 @@ module Rails
#
# You can also supply a block to hook_for to customize how the hook is
# going to be invoked. The block receives two arguments, an instance
- # of the current class and the klass to be invoked.
+ # of the current class and the class to be invoked.
#
# For example, in the resource generator, the controller should be invoked
# with a pluralized class name. But by default it is invoked with the same
diff --git a/railties/lib/rails/test_unit/sub_test_task.rb b/railties/lib/rails/test_unit/sub_test_task.rb
new file mode 100644
index 0000000000..284c70050f
--- /dev/null
+++ b/railties/lib/rails/test_unit/sub_test_task.rb
@@ -0,0 +1,36 @@
+module Rails
+ # Don't abort when tests fail; move on the next test task.
+ # Silence the default description to cut down on `rake -T` noise.
+ class SubTestTask < Rake::TestTask
+ # Create the tasks defined by this task lib.
+ def define
+ lib_path = @libs.join(File::PATH_SEPARATOR)
+ task @name do
+ run_code = ''
+ RakeFileUtils.verbose(@verbose) do
+ run_code =
+ case @loader
+ when :direct
+ "-e 'ARGV.each{|f| load f}'"
+ when :testrb
+ "-S testrb #{fix}"
+ when :rake
+ rake_loader
+ end
+ @ruby_opts.unshift( "-I\"#{lib_path}\"" )
+ @ruby_opts.unshift( "-w" ) if @warning
+
+ begin
+ ruby @ruby_opts.join(" ") +
+ " \"#{run_code}\" " +
+ file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
+ " #{option_list}"
+ rescue => error
+ warn "Error running #{name}: #{error.inspect}"
+ end
+ end
+ end
+ self
+ end
+ end
+end
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 52d92cdd96..a23d22d607 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -1,35 +1,6 @@
require 'rbconfig'
require 'rake/testtask'
-
-# Monkey-patch to silence the description from Rake::TestTask to cut down on rake -T noise
-class TestTaskWithoutDescription < Rake::TestTask
- # Create the tasks defined by this task lib.
- def define
- lib_path = @libs.join(File::PATH_SEPARATOR)
- task @name do
- run_code = ''
- RakeFileUtils.verbose(@verbose) do
- run_code =
- case @loader
- when :direct
- "-e 'ARGV.each{|f| load f}'"
- when :testrb
- "-S testrb #{fix}"
- when :rake
- rake_loader
- end
- @ruby_opts.unshift( "-I\"#{lib_path}\"" )
- @ruby_opts.unshift( "-w" ) if @warning
- ruby @ruby_opts.join(" ") +
- " \"#{run_code}\" " +
- file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
- " #{option_list}"
- end
- end
- self
- end
-end
-
+require 'rails/test_unit/sub_test_task'
TEST_CHANGES_SINCE = Time.now - 600
@@ -76,20 +47,7 @@ task :default => :test
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)'
task :test do
- tests_to_run = ENV['TEST'] ? ["test:single"] : %w(test:units test:functionals test:integration)
- errors = tests_to_run.collect do |task|
- begin
- Rake::Task[task].invoke
- nil
- rescue => e
- { :task => task, :exception => e }
- end
- end.compact
-
- if errors.any?
- puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
- abort
- end
+ Rake::Task[ENV['TEST'] ? 'test:single' : 'test:run'].invoke
end
namespace :test do
@@ -97,6 +55,8 @@ namespace :test do
# Placeholder task for other Railtie and plugins to enhance. See Active Record for an example.
end
+ task :run => %w(test:units test:functionals test:integration)
+
Rake::TestTask.new(:recent => "test:prepare") do |t|
since = TEST_CHANGES_SINCE
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
@@ -134,33 +94,33 @@ namespace :test do
t.libs << "test"
end
- TestTaskWithoutDescription.new(:units => "test:prepare") do |t|
+ Rails::SubTestTask.new(:units => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/unit/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:functionals => "test:prepare") do |t|
+ Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/functional/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:integration => "test:prepare") do |t|
+ Rails::SubTestTask.new(:integration => "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/integration/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:benchmark => 'test:prepare') do |t|
+ Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
t.options = '-- --benchmark'
end
- TestTaskWithoutDescription.new(:profile => 'test:prepare') do |t|
+ Rails::SubTestTask.new(:profile => 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
- TestTaskWithoutDescription.new(:plugins => :environment) do |t|
+ Rails::SubTestTask.new(:plugins => :environment) do |t|
t.libs << "test"
if ENV['PLUGIN']
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index d4d4e4e5ff..1d90671e44 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -63,26 +63,23 @@ module ApplicationTests
def test_rake_test_error_output
Dir.chdir(app_path){ `rake db:migrate` }
- app_file "config/database.yml", <<-RUBY
- development:
- RUBY
-
app_file "test/unit/one_unit_test.rb", <<-RUBY
+ raise 'unit'
RUBY
app_file "test/functional/one_functional_test.rb", <<-RUBY
- raise RuntimeError
+ raise 'functional'
RUBY
app_file "test/integration/one_integration_test.rb", <<-RUBY
- raise RuntimeError
+ raise 'integration'
RUBY
silence_stderr do
- output = Dir.chdir(app_path){ `rake test` }
- assert_match(/Errors running test:units! #<ActiveRecord::AdapterNotSpecified/, output)
- assert_match(/Errors running test:functionals! #<RuntimeError/, output)
- assert_match(/Errors running test:integration! #<RuntimeError/, output)
+ output = Dir.chdir(app_path) { `rake test 2>&1` }
+ assert_match 'unit', output
+ assert_match 'functional', output
+ assert_match 'integration', output
end
end