diff options
71 files changed, 168 insertions, 83 deletions
@@ -12,7 +12,7 @@ end desc 'Run all tests by default' task :default => :test -%w(test rdoc pgem package release).each do |task_name| +%w(test isolated_test rdoc pgem package release).each do |task_name| desc "Run #{task_name} task for all projects" task task_name do PROJECTS.each do |project| diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index f06f18ff76..24c25abc8b 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -28,6 +28,12 @@ Rake::TestTask.new { |t| t.warning = false } +task :isolated_test do + ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) + Dir.glob("test/*_test.rb").all? do |file| + system(ruby, '-Ilib:test', file) + end or raise "Failures" +end # Generate the RDoc documentation Rake::RDocTask.new { |rdoc| diff --git a/actionmailer/lib/action_mailer/vendor/tmail.rb b/actionmailer/lib/action_mailer/vendor/tmail.rb index 51d36cdd0d..60555605f6 100644 --- a/actionmailer/lib/action_mailer/vendor/tmail.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail.rb @@ -12,6 +12,7 @@ end require 'tmail' +require 'active_support/core_ext/kernel/reporting' silence_warnings do TMail::Encoder.const_set("MAX_LINE_LEN", 200) end diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index ab78bc9222..39083a84e9 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -21,16 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end -require 'active_support/core/all' +activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" +$:.unshift activesupport_path if File.directory?(activesupport_path) +require 'active_support' require File.join(File.dirname(__FILE__), "action_pack") diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index d25801b17b..2813e71d12 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -1,5 +1,7 @@ require 'action_controller/deprecated' require 'set' +require 'active_support/core_ext/class/inheritable_attributes' +require 'active_support/core_ext/module/attr_internal' module ActionController #:nodoc: class ActionControllerError < StandardError #:nodoc: diff --git a/actionpack/lib/action_controller/base/chained/benchmarking.rb b/actionpack/lib/action_controller/base/chained/benchmarking.rb index 066150f58a..66e9e9c31d 100644 --- a/actionpack/lib/action_controller/base/chained/benchmarking.rb +++ b/actionpack/lib/action_controller/base/chained/benchmarking.rb @@ -1,4 +1,4 @@ -require 'benchmark' +require 'active_support/core_ext/benchmark' module ActionController #:nodoc: # The benchmarking module times the performance of actions and reports to the logger. If the Active Record diff --git a/actionpack/lib/action_controller/base/http_authentication.rb b/actionpack/lib/action_controller/base/http_authentication.rb index b6b5267c66..fa8ecea408 100644 --- a/actionpack/lib/action_controller/base/http_authentication.rb +++ b/actionpack/lib/action_controller/base/http_authentication.rb @@ -1,3 +1,5 @@ +require 'active_support/base64' + module ActionController module HttpAuthentication # Makes it dead easy to do HTTP Basic authentication. @@ -276,7 +278,7 @@ module ActionController t = time.to_i hashed = [t, secret_key] digest = ::Digest::MD5.hexdigest(hashed.join(":")) - Base64.encode64("#{t}:#{digest}").gsub("\n", '') + ActiveSupport::Base64.encode64("#{t}:#{digest}").gsub("\n", '') end # Might want a shorter timeout depending on whether the request @@ -285,7 +287,7 @@ module ActionController # allow a user to use new nonce without prompting user again for their # username and password. def validate_nonce(request, value, seconds_to_timeout=5*60) - t = Base64.decode64(value).split(":").first.to_i + t = ActiveSupport::Base64.decode64(value).split(":").first.to_i nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout end diff --git a/actionpack/lib/action_controller/base/layout.rb b/actionpack/lib/action_controller/base/layout.rb index 1ad5191c73..cf5f46a32b 100644 --- a/actionpack/lib/action_controller/base/layout.rb +++ b/actionpack/lib/action_controller/base/layout.rb @@ -1,3 +1,7 @@ +require 'active_support/core_ext/enumerable' +require 'active_support/core_ext/class/delegating_attributes' +require 'active_support/core_ext/class/inheritable_attributes' + module ActionController #:nodoc: module Layout #:nodoc: def self.included(base) diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index 6bda27e23a..b4408e4e1d 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module' + module ActionController # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or # Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate diff --git a/actionpack/lib/action_controller/routing/builder.rb b/actionpack/lib/action_controller/routing/builder.rb index d9590c88b8..42ad12e1ea 100644 --- a/actionpack/lib/action_controller/routing/builder.rb +++ b/actionpack/lib/action_controller/routing/builder.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/hash/except' + module ActionController module Routing class RouteBuilder #:nodoc: diff --git a/actionpack/lib/action_controller/routing/route.rb b/actionpack/lib/action_controller/routing/route.rb index e2077edad8..eba05a3c5a 100644 --- a/actionpack/lib/action_controller/routing/route.rb +++ b/actionpack/lib/action_controller/routing/route.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/object/misc' + module ActionController module Routing class Route #:nodoc: @@ -65,7 +67,7 @@ module ActionController # map.connect '/page/:id', :controller => 'pages', :action => 'show', :id => /\d+/ # def parameter_shell - @parameter_shell ||= returning({}) do |shell| + @parameter_shell ||= {}.tap do |shell| requirements.each do |key, requirement| shell[key] = requirement unless requirement.is_a? Regexp end @@ -76,7 +78,7 @@ module ActionController # includes keys that appear inside the path, and keys that have requirements # placed upon them. def significant_keys - @significant_keys ||= returning([]) do |sk| + @significant_keys ||= [].tap do |sk| segments.each { |segment| sk << segment.key if segment.respond_to? :key } sk.concat requirements.keys sk.uniq! @@ -86,7 +88,7 @@ module ActionController # Return a hash of key/value pairs representing the keys in the route that # have defaults, or which are specified by non-regexp requirements. def defaults - @defaults ||= returning({}) do |hash| + @defaults ||= {}.tap do |hash| segments.each do |segment| next unless segment.respond_to? :default hash[segment.key] = segment.default unless segment.default.nil? diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index 936f97ecb5..8f4358c33e 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -1,4 +1,5 @@ require 'rack/session/abstract/id' +require 'active_support/core_ext/object/conversions' module ActionController #:nodoc: class TestRequest < ActionDispatch::TestRequest #:nodoc: diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index c882930e64..27d229835a 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -21,16 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end -require 'active_support/core/all' +activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" +$:.unshift activesupport_path if File.directory?(activesupport_path) +require 'active_support' begin gem 'rack', '~> 1.1.pre' diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 02ad7f7d94..dfcf3a558f 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -1,4 +1,5 @@ require 'set' +require 'active_support/core_ext/class/attribute_accessors' module Mime SET = [] diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index e4f3a8f125..13ff049a97 100755 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -3,6 +3,7 @@ require 'stringio' require 'strscan' require 'active_support/memoizable' +require 'active_support/core_ext/hash/indifferent_access' module ActionDispatch class Request < Rack::Request diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index c3b5a68f40..edb522ff49 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -1,4 +1,5 @@ require 'digest/md5' +require 'active_support/core_ext/module/delegation' module ActionDispatch # :nodoc: # Represents an HTTP response generated by a controller action. One can use diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb index dd352f9ce0..c3786af439 100644 --- a/actionpack/lib/action_view.rb +++ b/actionpack/lib/action_view.rb @@ -21,16 +21,9 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -begin - require 'active_support' -rescue LoadError - activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" - if File.directory?(activesupport_path) - $:.unshift activesupport_path - require 'active_support' - end -end -require 'active_support/core/all' +activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" +$:.unshift activesupport_path if File.directory?(activesupport_path) +require 'active_support' require File.join(File.dirname(__FILE__), "action_pack") diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 44bd401631..56f0b5ef4f 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -1,3 +1,6 @@ +require 'active_support/core_ext/module/attr_internal' +require 'active_support/core_ext/module/delegation' + module ActionView #:nodoc: class ActionViewError < StandardError #:nodoc: end diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index a59829b23f..beef661a37 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -2,6 +2,7 @@ require 'cgi' require 'action_view/helpers/date_helper' require 'action_view/helpers/tag_helper' require 'action_view/helpers/form_tag_helper' +require 'active_support/core_ext/class/inheritable_attributes' module ActionView module Helpers @@ -1039,8 +1040,8 @@ module ActionView end end - class Base - cattr_accessor :default_form_builder - self.default_form_builder = ::ActionView::Helpers::FormBuilder + class << Base + attr_accessor :default_form_builder end -end
\ No newline at end of file + Base.default_form_builder = ::ActionView::Helpers::FormBuilder +end diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index a20b1b0cd3..fdcb108ffc 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -1,4 +1,5 @@ require 'erb' +require 'active_support/core_ext/class/attribute_accessors' module ActionView module TemplateHandlers diff --git a/actionpack/test/abstract_controller/test_helper.rb b/actionpack/test/abstract_controller/test_helper.rb index a08ab5a6d7..915054f7fb 100644 --- a/actionpack/test/abstract_controller/test_helper.rb +++ b/actionpack/test/abstract_controller/test_helper.rb @@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'test/unit' -require 'active_support/core/all' +require 'active_support' require 'active_support/test_case' require 'action_controller/abstract' require 'action_view' @@ -18,4 +18,4 @@ begin Debugger.start rescue LoadError # Debugging disabled. `gem install ruby-debug` to enable. -end
\ No newline at end of file +end diff --git a/actionpack/test/abstract_unit2.rb b/actionpack/test/abstract_unit2.rb index 2fdaba7342..932f594ad2 100644 --- a/actionpack/test/abstract_unit2.rb +++ b/actionpack/test/abstract_unit2.rb @@ -5,7 +5,6 @@ $:.unshift(File.dirname(__FILE__) + '/lib') require 'test/unit' require 'active_support' -require 'active_support/core/all' require 'active_support/test_case' require 'action_controller/abstract' require 'action_controller/new_base' @@ -129,4 +128,4 @@ module ActionController end end end -end
\ No newline at end of file +end diff --git a/actionpack/test/controller/addresses_render_test.rb b/actionpack/test/controller/addresses_render_test.rb index 2f092b6731..2d2a2745b0 100644 --- a/actionpack/test/controller/addresses_render_test.rb +++ b/actionpack/test/controller/addresses_render_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'logger' class Address def Address.count(conditions = nil, join = nil) diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 0c54d61426..a09db95d7d 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'logger' require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late # Provide some controller to run the tests on. diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb index 9a0976ca9f..06a5af6b32 100644 --- a/actionpack/test/controller/capture_test.rb +++ b/actionpack/test/controller/capture_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'logger' class CaptureController < ActionController::Base def self.controller_name; "test"; end diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 19cd5f4db2..7b8096fccc 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'active_support/core_ext/kernel/reporting' ActionController::Base.helpers_dir = File.dirname(__FILE__) + '/../fixtures/helpers' diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 4b60f8d682..544f49310a 100755 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -11,6 +11,12 @@ Rake::TestTask.new do |t| t.verbose = true t.warning = true end +task :isolated_test do + ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) + Dir.glob("test/**/*_test.rb").all? do |file| + system(ruby, '-Ilib:test', file) + end or raise "Failures" +end # Generate the RDoc documentation Rake::RDocTask.new do |rdoc| diff --git a/activemodel/test/state_machine/event_test.rb b/activemodel/test/state_machine/event_test.rb index 64dc8c4875..05e7c78e8a 100644 --- a/activemodel/test/state_machine/event_test.rb +++ b/activemodel/test/state_machine/event_test.rb @@ -1,4 +1,5 @@ require 'test_helper' +require 'active_model/state_machine/event' class EventTest < ActiveModel::TestCase def setup diff --git a/activemodel/test/state_machine/state_transition_test.rb b/activemodel/test/state_machine/state_transition_test.rb index b59ff5a6a7..966396fab1 100644 --- a/activemodel/test/state_machine/state_transition_test.rb +++ b/activemodel/test/state_machine/state_transition_test.rb @@ -1,4 +1,5 @@ require 'test_helper' +require 'active_model/state_machine/state_transition' class StateTransitionTest < ActiveModel::TestCase test 'should set from, to, and opts attr readers' do diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 892d52f30d..0b3f50d17e 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -32,6 +32,9 @@ desc 'Run mysql, sqlite, and postgresql tests' task :test => defined?(JRUBY_VERSION) ? %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) : %w(test_mysql test_sqlite3 test_postgresql) +task :isolated_test => defined?(JRUBY_VERSION) ? + %w(isolated_test_jdbcmysql isolated_test_jdbcsqlite3 isolated_test_jdbcpostgresql) : + %w(isolated_test_mysql isolated_test_sqlite3 isolated_test_postgresql) %w( mysql postgresql sqlite sqlite3 firebird db2 oracle sybase openbase frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter| Rake::TestTask.new("test_#{adapter}") { |t| diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index c9e9a84ce7..2d98239052 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -24,7 +24,6 @@ activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib" $:.unshift(activesupport_path) if File.directory?(activesupport_path) require 'active_support' -require 'active_support/core/all' module ActiveRecord # TODO: Review explicit loads to see if they will automatically be handled by the initilizer. diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index e2dd36158f..c5e4df4950 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/module/delegation' + module ActiveRecord class InverseOfAssociationNotFoundError < ActiveRecordError #:nodoc: def initialize(reflection) diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 8d68d77eac..55d9a4d15d 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/enumerable' + module ActiveRecord module AttributeMethods #:nodoc: extend ActiveSupport::DependencyModule diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 97c36a675d..b9ba727a3f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1,6 +1,15 @@ require 'yaml' require 'set' require 'active_support/dependencies' +require 'active_support/core_ext/class/attribute_accessors' +require 'active_support/core_ext/class/delegating_attributes' +require 'active_support/core_ext/class/inheritable_attributes' +require 'active_support/core_ext/array/extract_options' +require 'active_support/core_ext/hash/deep_merge' +require 'active_support/core_ext/hash/indifferent_access' +require 'active_support/core_ext/hash/slice' +require 'active_support/core_ext/string/behavior' +require 'active_support/core/time' module ActiveRecord #:nodoc: # Generic Active Record exception class. @@ -1888,7 +1897,7 @@ module ActiveRecord #:nodoc: else find(:#{finder}, options.merge(finder_options)) end - #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect {|pair| "#{pair.first} = #{pair.second}"}.join(\', \')}")' if bang} + #{'result || raise(RecordNotFound, "Couldn\'t find #{name} with #{attributes.to_a.collect { |pair| pair.join(\' = \') }.join(\', \')}")' if bang} end }, __FILE__, __LINE__ send(method_id, *arguments) @@ -2610,11 +2619,11 @@ module ActiveRecord #:nodoc: # Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either # instance will affect the other. def becomes(klass) - returning klass.new do |became| - became.instance_variable_set("@attributes", @attributes) - became.instance_variable_set("@attributes_cache", @attributes_cache) - became.instance_variable_set("@new_record", new_record?) - end + became = klass.new + became.instance_variable_set("@attributes", @attributes) + became.instance_variable_set("@attributes_cache", @attributes_cache) + became.instance_variable_set("@new_record", new_record?) + became end # Updates a single attribute and saves the record without going through the normal validation procedure. 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 e8e736bf38..500dafdc2e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -1,5 +1,6 @@ require 'monitor' require 'set' +require 'active_support/core_ext/module/synchronization' module ActiveRecord # Raised when a connection could not be obtained within the connection diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 3a7bf35248..720fba29e9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/big_decimal/conversions' + module ActiveRecord module ConnectionAdapters # :nodoc: module Quoting diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index a8cd9f033b..91b111ab55 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -12,6 +12,8 @@ require 'active_record/connection_adapters/abstract/connection_pool' require 'active_record/connection_adapters/abstract/connection_specification' require 'active_record/connection_adapters/abstract/query_cache' +require 'active_support/core_ext/benchmark' + module ActiveRecord module ConnectionAdapters # :nodoc: # ActiveRecord supports multiple database systems. AbstractAdapter and diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 9300df28ee..d5536e4d67 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -1,4 +1,5 @@ require 'active_record/connection_adapters/abstract_adapter' +require 'active_support/core_ext/kernel/requires' require 'set' module MysqlCompat #:nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 4961793866..002696d2c4 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -1,4 +1,5 @@ require 'active_record/connection_adapters/abstract_adapter' +require 'active_support/core_ext/kernel/requires' begin require_library_or_gem 'pg' diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 75420f69aa..5eef692d05 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -25,9 +25,9 @@ module ActiveRecord module ConnectionAdapters #:nodoc: class SQLite3Adapter < SQLiteAdapter # :nodoc: def table_structure(table_name) - returning structure = @connection.table_info(quote_table_name(table_name)) do - raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? - end + structure = @connection.table_info(quote_table_name(table_name)) + raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? + structure end end end diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 05334a830a..c9d0c9574f 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -1,4 +1,5 @@ require 'active_record/connection_adapters/abstract_adapter' +require 'active_support/core_ext/kernel/requires' module ActiveRecord class Base diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb index fac6ca40d3..ac84f6b209 100644 --- a/activerecord/lib/active_record/dirty.rb +++ b/activerecord/lib/active_record/dirty.rb @@ -168,7 +168,9 @@ module ActiveRecord module ClassMethods def self.extended(base) - base.metaclass.alias_method_chain(:alias_attribute, :dirty) + class << base + alias_method_chain :alias_attribute, :dirty + end end def alias_attribute_with_dirty(new_name, old_name) diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 91b4b4e182..e30fcf9a4f 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -3,6 +3,7 @@ require 'yaml' require 'csv' require 'active_support/dependencies' require 'active_support/test_case' +require 'active_support/core_ext/logger' if RUBY_VERSION < '1.9' module YAML #:nodoc: diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 657acd6dc0..a7be3539d5 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -511,11 +511,11 @@ module ActiveRecord raise DuplicateMigrationNameError.new(name.camelize) end - klasses << returning(MigrationProxy.new) do |migration| - migration.name = name.camelize - migration.version = version - migration.filename = file - end + migration = MigrationProxy.new + migration.name = name.camelize + migration.version = version + migration.filename = file + klasses << migration end migrations = migrations.sort_by(&:version) diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 32bb36c07c..07f98dc743 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -1,3 +1,6 @@ +require 'active_support/core_ext/array' +require 'active_support/core_ext/hash/except' + module ActiveRecord module NamedScope extend ActiveSupport::DependencyModule diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 1ea2f53fd8..c532d3dfa3 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -1,3 +1,6 @@ +require 'active_support/core_ext/hash/except' +require 'active_support/core_ext/object/try' + module ActiveRecord module NestedAttributes #:nodoc: extend ActiveSupport::DependencyModule diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 557a554966..de530a3456 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -1,5 +1,5 @@ require 'stringio' -require 'bigdecimal' +require 'active_support/core_ext/big_decimal' module ActiveRecord # This class is used to dump the database schema for some connection to some @@ -176,4 +176,4 @@ HEADER end end end -end
\ No newline at end of file +end diff --git a/activerecord/lib/active_record/serialization.rb b/activerecord/lib/active_record/serialization.rb index 78f66c3a73..7959f2b510 100644 --- a/activerecord/lib/active_record/serialization.rb +++ b/activerecord/lib/active_record/serialization.rb @@ -1,5 +1,3 @@ -require 'active_support/json' - module ActiveRecord #:nodoc: module Serialization class Serializer #:nodoc: @@ -73,16 +71,19 @@ module ActiveRecord #:nodoc: end def serializable_record - returning(serializable_record = {}) do - serializable_names.each { |name| serializable_record[name] = @record.send(name) } - add_includes do |association, records, opts| + record = {} + serializable_names.each { |name| record[name] = @record.send(name) } + + add_includes do |association, records, opts| + record[association] = if records.is_a?(Enumerable) - serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record } + records.collect { |r| self.class.new(r, opts).serializable_record } else - serializable_record[association] = self.class.new(records, opts).serializable_record + self.class.new(records, opts).serializable_record end - end end + + record end def serialize diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb index fa75874603..4eaf9531e2 100644 --- a/activerecord/lib/active_record/serializers/xml_serializer.rb +++ b/activerecord/lib/active_record/serializers/xml_serializer.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/hash/conversions' + module ActiveRecord #:nodoc: module Serialization # Builds an XML document to represent the model. Some configuration is @@ -165,8 +167,9 @@ module ActiveRecord #:nodoc: class XmlSerializer < ActiveRecord::Serialization::Serializer #:nodoc: def builder @builder ||= begin + require 'builder' unless defined? ::Builder options[:indent] ||= 2 - builder = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) + builder = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent]) unless options[:skip_instruct] builder.instruct! diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 9907a3c9b7..b6e848fa79 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -1,5 +1,3 @@ -require 'builder' - module ActiveRecord # Raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid. Use the # +record+ method to retrieve the record which did not validate. @@ -247,9 +245,10 @@ module ActiveRecord # # <error>Address can't be blank</error> # # </errors> def to_xml(options={}) + require 'builder' unless defined? ::Builder options[:root] ||= "errors" options[:indent] ||= 2 - options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) + options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent]) options[:builder].instruct! unless options.delete(:skip_instruct) options[:builder].errors do |e| diff --git a/activerecord/test/cases/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb index 4e0e1c7f15..8b6ec04018 100644 --- a/activerecord/test/cases/aggregations_test.rb +++ b/activerecord/test/cases/aggregations_test.rb @@ -1,5 +1,6 @@ require "cases/helper" require 'models/customer' +require 'active_support/core_ext/exception' class AggregationsTest < ActiveRecord::TestCase fixtures :customers 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 5f824f9c74..cb7fe9698b 100644 --- a/activerecord/test/cases/associations/eager_load_nested_include_test.rb +++ b/activerecord/test/cases/associations/eager_load_nested_include_test.rb @@ -4,6 +4,7 @@ require 'models/author' require 'models/comment' require 'models/category' require 'models/categorization' +require 'active_support/core_ext/array/random_access' module Remembered extend ActiveSupport::DependencyModule diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 5e8b2cadfc..8dc95806b9 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -24,6 +24,7 @@ require 'models/club' require 'models/member' require 'models/membership' require 'models/sponsor' +require 'active_support/core_ext/string/conversions' class ProjectWithAfterCreateHook < ActiveRecord::Base set_table_name 'projects' diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 7ca2807f7e..59aa6953e3 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -18,6 +18,7 @@ require 'models/minimalistic' require 'models/warehouse_thing' require 'models/parrot' require 'rexml/document' +require 'active_support/core_ext/exception' class Category < ActiveRecord::Base; end class Categorization < ActiveRecord::Base; end diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 28eb311618..ad4588db69 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -485,8 +485,9 @@ class FinderTest < ActiveRecord::TestCase assert_equal "foo in (#{quoted_nil})", bind('foo in (?)', []) end - def test_bind_string - assert_equal ActiveRecord::Base.connection.quote(''), bind('?', '') + def test_bind_empty_string + quoted_empty = ActiveRecord::Base.connection.quote('') + assert_equal quoted_empty, bind('?', '') end def test_bind_chars diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 1ec52ac24d..05e92433cd 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -15,6 +15,11 @@ require 'connection' require 'cases/repair_helper' +begin + require 'ruby-debug' +rescue LoadError +end + # Show backtraces for deprecated behavior for quicker cleanup. ActiveSupport::Deprecation.debug = true diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index ae6a54a5bd..7dcea6d42e 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'active_support/core_ext/array/random_access' require 'models/post' require 'models/topic' require 'models/comment' @@ -265,7 +266,7 @@ class NamedScopeTest < ActiveRecord::TestCase end def test_rand_should_select_a_random_object_from_proxy - assert Topic.approved.rand.is_a?(Topic) + assert_kind_of Topic, Topic.approved.rand end def test_should_use_where_in_query_for_named_scope diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index f1741ed54d..f31275163d 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -4,6 +4,7 @@ require "models/ship" require "models/bird" require "models/parrot" require "models/treasure" +require 'active_support/hash_with_indifferent_access' module AssertRaiseWithMessage def assert_raise_with_message(expected_exception, expected_message) diff --git a/activerecord/test/models/company_in_module.rb b/activerecord/test/models/company_in_module.rb index 7f02403d5a..3c34efbe16 100644 --- a/activerecord/test/models/company_in_module.rb +++ b/activerecord/test/models/company_in_module.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/object/misc' + module MyApplication module Business class Company < ActiveRecord::Base diff --git a/activeresource/Rakefile b/activeresource/Rakefile index c3cde26b6c..eb5b1dd1ac 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -34,6 +34,13 @@ Rake::TestTask.new { |t| t.verbose = true t.warning = true } +task :isolated_test do + ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) + activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib" + Dir.glob("test/**/*_test.rb").all? do |file| + system(ruby, "-Ilib:test:#{activesupport_path}", file) + end or raise "Failures" +end # Generate the RDoc documentation diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 8a1236c9a8..dc24e713ff 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -1,8 +1,10 @@ +require 'active_support' require 'active_support/core_ext/class/attribute_accessors' require 'active_support/core_ext/class/inheritable_attributes' require 'active_support/core_ext/module/attr_accessor_with_default' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/aliasing' +require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/misc' require 'set' @@ -1027,7 +1029,7 @@ module ActiveResource private # Tries to find a resource for a given collection name; if it fails, then the resource is created def find_or_create_resource_for_collection(name) - find_or_create_resource_for(name.to_s.singularize) + find_or_create_resource_for(ActiveSupport::Inflector.singularize(name.to_s)) end # Tries to find a resource in a non empty list of nested modules diff --git a/activeresource/test/base/custom_methods_test.rb b/activeresource/test/base/custom_methods_test.rb index 61887f4ec7..2d81549a65 100644 --- a/activeresource/test/base/custom_methods_test.rb +++ b/activeresource/test/base/custom_methods_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' require 'fixtures/person' require 'fixtures/street_address' +require 'active_support/core_ext/hash/conversions' class CustomMethodsTest < Test::Unit::TestCase def setup diff --git a/activeresource/test/base/load_test.rb b/activeresource/test/base/load_test.rb index cd2103acb7..035bd965c2 100644 --- a/activeresource/test/base/load_test.rb +++ b/activeresource/test/base/load_test.rb @@ -2,6 +2,7 @@ require 'abstract_unit' require "fixtures/person" require "fixtures/street_address" require 'active_support/core_ext/symbol' +require 'active_support/core_ext/hash/conversions' module Highrise class Note < ActiveResource::Base diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index a6cef6b2ae..82d3b2ae96 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -3,6 +3,7 @@ require "fixtures/person" require "fixtures/customer" require "fixtures/street_address" require "fixtures/beast" +require 'active_support/core_ext/hash/conversions' class BaseTest < Test::Unit::TestCase def setup diff --git a/activesupport/Rakefile b/activesupport/Rakefile index a4e8200a43..c3ea09d424 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -22,8 +22,8 @@ Rake::TestTask.new { |t| t.warning = true } task :isolated_test do + ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) Dir['test/**/*_test.rb'].all? do |file| - ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) system(ruby, '-Ilib:test', file) end or raise "Failures" end diff --git a/activesupport/lib/active_support/core_ext/object/conversions.rb b/activesupport/lib/active_support/core_ext/object/conversions.rb index 278b856c45..638f0decc1 100644 --- a/activesupport/lib/active_support/core_ext/object/conversions.rb +++ b/activesupport/lib/active_support/core_ext/object/conversions.rb @@ -1,3 +1,6 @@ +require 'active_support/core_ext/array/conversions' +require 'active_support/core_ext/hash/conversions' + class Object # Alias of <tt>to_s</tt>. def to_param diff --git a/railties/Rakefile b/railties/Rakefile index 7637293007..133a603ed6 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -31,6 +31,7 @@ task :test do system(ruby, '-Itest', "-I#{File.dirname(__FILE__)}/../activesupport/lib", file) end or raise "Failures" end +task :isolated_test => :test Rake::TestTask.new("regular_test") do |t| t.libs << 'test' << "#{File.dirname(__FILE__)}/../activesupport/lib" diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 9d27488e8a..40000f0dfd 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -264,8 +264,8 @@ module Rails # Action Pack, Action Mailer, and Active Resource) are loaded. def require_frameworks require 'active_support' - require 'active_support/core/all' configuration.frameworks.each { |framework| require(framework.to_s) } + require 'active_support/core/all' rescue LoadError => e # Re-raise as RuntimeError because Mongrel would swallow LoadError. raise e.to_s diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 0f924724cd..e66166306a 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/kernel/reporting' + module Rails # The Plugin class should be an object which provides the following methods: # diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index ffd60ee662..0addcb8bf3 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -13,7 +13,6 @@ gem 'mocha', '>= 0.9.5' require 'mocha' require 'active_support' -require 'active_support/core/all' require 'active_support/test_case' if defined?(RAILS_ROOT) diff --git a/railties/test/plugin_test_helper.rb b/railties/test/plugin_test_helper.rb index adb62de665..55d1a1fa96 100644 --- a/railties/test/plugin_test_helper.rb +++ b/railties/test/plugin_test_helper.rb @@ -3,7 +3,6 @@ $:.unshift File.dirname(__FILE__) + "/../../activesupport/lib" require 'test/unit' require 'active_support' -require 'active_support/core/all' require 'initializer' require File.join(File.dirname(__FILE__), 'abstract_unit') |