aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-11-24 11:11:08 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-24 11:11:08 +0100
commitf3f67ce6212e2ae35470ab2960bb4967ae967ee2 (patch)
tree6a3054b9e4882a3faea6acc8b935db16a0831c4e
parenteea5dc3a34328267407f2cb861e14d9d1f5d7c02 (diff)
parent2dd0ec48a5068a095e362fad2a77d63b86fdfd95 (diff)
downloadrails-f3f67ce6212e2ae35470ab2960bb4967ae967ee2.tar.gz
rails-f3f67ce6212e2ae35470ab2960bb4967ae967ee2.tar.bz2
rails-f3f67ce6212e2ae35470ab2960bb4967ae967ee2.zip
Merge branch 'master' of git@github.com:rails/rails
-rw-r--r--actionmailer/lib/action_mailer.rb38
-rw-r--r--actionmailer/lib/action_mailer/base.rb17
-rw-r--r--actionmailer/lib/action_mailer/mail_helper.rb2
-rw-r--r--actionmailer/lib/action_mailer/part.rb10
-rw-r--r--actionmailer/lib/action_mailer/test_case.rb2
-rw-r--r--actionmailer/lib/action_mailer/test_helper.rb1
-rw-r--r--actionmailer/lib/action_mailer/utils.rb1
-rw-r--r--actionmailer/lib/action_mailer/vendor.rb14
-rw-r--r--actionmailer/lib/action_mailer/vendor/text_format.rb10
-rw-r--r--actionmailer/lib/action_mailer/vendor/tmail.rb17
-rw-r--r--actionmailer/test/quoting_test.rb1
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/lib/action_controller.rb96
-rw-r--r--actionpack/lib/action_controller/assertions/response_assertions.rb3
-rw-r--r--actionpack/lib/action_controller/assertions/selector_assertions.rb3
-rw-r--r--actionpack/lib/action_controller/assertions/tag_assertions.rb5
-rw-r--r--actionpack/lib/action_controller/base.rb15
-rw-r--r--actionpack/lib/action_controller/caching.rb18
-rw-r--r--actionpack/lib/action_controller/cgi_process.rb1
-rw-r--r--actionpack/lib/action_controller/integration.rb4
-rw-r--r--actionpack/lib/action_controller/performance_test.rb1
-rw-r--r--actionpack/lib/action_controller/rack_process.rb1
-rw-r--r--actionpack/lib/action_controller/request_profiler.rb1
-rw-r--r--actionpack/lib/action_controller/resources.rb4
-rw-r--r--actionpack/lib/action_controller/routing.rb1
-rw-r--r--actionpack/lib/action_controller/routing/route_set.rb2
-rw-r--r--actionpack/lib/action_controller/session_management.rb7
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner.rb9
-rw-r--r--actionpack/lib/action_view.rb36
-rw-r--r--actionpack/lib/action_view/base.rb2
-rw-r--r--actionpack/lib/action_view/erb/util.rb38
-rw-r--r--actionpack/lib/action_view/helpers.rb29
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb7
-rw-r--r--actionpack/lib/action_view/helpers/sanitize_helper.rb11
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb10
-rw-r--r--actionpack/lib/action_view/locale/en.yml1
-rw-r--r--actionpack/lib/action_view/template_handler.rb26
-rw-r--r--actionpack/lib/action_view/template_handlers.rb9
-rw-r--r--actionpack/lib/action_view/template_handlers/erb.rb39
-rw-r--r--actionpack/lib/action_view/test_case.rb2
-rw-r--r--actionpack/test/abstract_unit.rb2
-rw-r--r--actionpack/test/activerecord/active_record_store_test.rb1
-rw-r--r--actionpack/test/controller/assert_select_test.rb5
-rw-r--r--actionpack/test/controller/cgi_test.rb1
-rw-r--r--actionpack/test/controller/dispatcher_test.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/integration_upload_test.rb2
-rw-r--r--actionpack/test/controller/rack_test.rb1
-rw-r--r--actionpack/test/controller/request_test.rb1
-rw-r--r--actionpack/test/controller/routing_test.rb1
-rw-r--r--actionpack/test/controller/session/cookie_store_test.rb3
-rw-r--r--actionpack/test/controller/session/mem_cache_store_test.rb3
-rw-r--r--actionpack/test/template/form_options_helper_test.rb3
-rw-r--r--actionpack/test/template/number_helper_i18n_test.rb3
-rw-r--r--actionpack/test/template/render_test.rb11
-rw-r--r--activemodel/test/test_helper.rb2
-rw-r--r--activesupport/lib/active_support.rb29
-rw-r--r--activesupport/lib/active_support/cache.rb13
-rw-r--r--activesupport/lib/active_support/cache/drb_store.rb5
-rw-r--r--activesupport/lib/active_support/core_ext.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb3
-rw-r--r--activesupport/lib/active_support/core_ext/file/atomic.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/object/conversions.rb4
-rw-r--r--activesupport/lib/active_support/deprecation.rb59
-rw-r--r--activesupport/lib/active_support/duration.rb2
-rw-r--r--activesupport/lib/active_support/json/encoding.rb28
-rw-r--r--activesupport/lib/active_support/message_verifier.rb3
-rw-r--r--activesupport/lib/active_support/secure_random.rb14
-rw-r--r--activesupport/lib/active_support/test_case.rb18
-rw-r--r--activesupport/lib/active_support/testing/deprecation.rb55
-rw-r--r--activesupport/lib/active_support/testing/mocha_minitest_adapter.rb45
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb1
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb1
-rw-r--r--activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb4
-rw-r--r--activesupport/test/abstract_unit.rb2
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb1
-rw-r--r--railties/lib/console_with_helpers.rb23
-rw-r--r--railties/test/abstract_unit.rb9
79 files changed, 415 insertions, 458 deletions
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb
index 2a9210deb9..d442004011 100644
--- a/actionmailer/lib/action_mailer.rb
+++ b/actionmailer/lib/action_mailer.rb
@@ -31,22 +31,32 @@ rescue LoadError
end
end
-require 'action_mailer/vendor'
-require 'tmail'
-
-require 'action_mailer/base'
-require 'action_mailer/helpers'
-require 'action_mailer/mail_helper'
-require 'action_mailer/quoting'
-require 'action_mailer/test_helper'
+module ActionMailer
+ def self.load_all!
+ [Base, Part, ::Text::Format, ::Net::SMTP]
+ end
-require 'net/smtp'
+ autoload :AdvAttrAccessor, 'action_mailer/adv_attr_accessor'
+ autoload :Base, 'action_mailer/base'
+ autoload :Helpers, 'action_mailer/helpers'
+ autoload :Part, 'action_mailer/part'
+ autoload :PartContainer, 'action_mailer/part_container'
+ autoload :Quoting, 'action_mailer/quoting'
+ autoload :TestCase, 'action_mailer/test_case'
+ autoload :TestHelper, 'action_mailer/test_helper'
+ autoload :Utils, 'action_mailer/utils'
+end
-ActionMailer::Base.class_eval do
- include ActionMailer::Quoting
- include ActionMailer::Helpers
+module Text
+ autoload :Format, 'action_mailer/vendor/text_format'
+end
- helper MailHelper
+module Net
+ autoload :SMTP, 'net/smtp'
end
-silence_warnings { TMail::Encoder.const_set("MAX_LINE_LEN", 200) }
+autoload :MailHelper, 'action_mailer/mail_helper'
+autoload :TMail, 'action_mailer/vendor/tmail'
+
+# TODO: Don't explicitly load entire lib
+ActionMailer.load_all!
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index e41c88d81b..acb9aff6aa 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -1,9 +1,3 @@
-require 'action_mailer/adv_attr_accessor'
-require 'action_mailer/part'
-require 'action_mailer/part_container'
-require 'action_mailer/utils'
-require 'tmail/net'
-
module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
#
@@ -245,7 +239,7 @@ module ActionMailer #:nodoc:
# and appear last in the mime encoded message. You can also pick a different order from inside a method with
# +implicit_parts_order+.
class Base
- include AdvAttrAccessor, PartContainer
+ include AdvAttrAccessor, PartContainer, Quoting, Utils
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
include ActionController::Layout
@@ -648,11 +642,11 @@ module ActionMailer #:nodoc:
if @parts.empty?
m.set_content_type(real_content_type, nil, ctype_attrs)
- m.body = Utils.normalize_new_lines(body)
+ m.body = normalize_new_lines(body)
else
if String === body
part = TMail::Mail.new
- part.body = Utils.normalize_new_lines(body)
+ part.body = normalize_new_lines(body)
part.set_content_type(real_content_type, nil, ctype_attrs)
part.set_content_disposition "inline"
m.parts << part
@@ -698,4 +692,9 @@ module ActionMailer #:nodoc:
deliveries << mail
end
end
+
+ Base.class_eval do
+ include Helpers
+ helper MailHelper
+ end
end
diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb
index 11fd7d77e0..351b966abe 100644
--- a/actionmailer/lib/action_mailer/mail_helper.rb
+++ b/actionmailer/lib/action_mailer/mail_helper.rb
@@ -1,5 +1,3 @@
-require 'text/format'
-
module MailHelper
# Uses Text::Format to take the text and format it, indented two spaces for
# each line, and wrapped at 72 columns.
diff --git a/actionmailer/lib/action_mailer/part.rb b/actionmailer/lib/action_mailer/part.rb
index 2dabf15f08..977c0b2b5c 100644
--- a/actionmailer/lib/action_mailer/part.rb
+++ b/actionmailer/lib/action_mailer/part.rb
@@ -1,15 +1,10 @@
-require 'action_mailer/adv_attr_accessor'
-require 'action_mailer/part_container'
-require 'action_mailer/utils'
-
module ActionMailer
# Represents a subpart of an email message. It shares many similar
# attributes of ActionMailer::Base. Although you can create parts manually
# and add them to the +parts+ list of the mailer, it is easier
# to use the helper methods in ActionMailer::PartContainer.
class Part
- include ActionMailer::AdvAttrAccessor
- include ActionMailer::PartContainer
+ include AdvAttrAccessor, PartContainer, Utils
# Represents the body of the part, as a string. This should not be a
# Hash (like ActionMailer::Base), but if you want a template to be rendered
@@ -64,7 +59,7 @@ module ActionMailer
when "base64" then
part.body = TMail::Base64.folding_encode(body)
when "quoted-printable"
- part.body = [Utils.normalize_new_lines(body)].pack("M*")
+ part.body = [normalize_new_lines(body)].pack("M*")
else
part.body = body
end
@@ -102,7 +97,6 @@ module ActionMailer
end
private
-
def squish(values={})
values.delete_if { |k,v| v.nil? }
end
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb
index d474afe3a2..8035db6f03 100644
--- a/actionmailer/lib/action_mailer/test_case.rb
+++ b/actionmailer/lib/action_mailer/test_case.rb
@@ -10,7 +10,7 @@ module ActionMailer
end
class TestCase < ActiveSupport::TestCase
- include ActionMailer::Quoting
+ include Quoting, TestHelper
setup :initialize_test_deliveries
setup :set_expected_mail
diff --git a/actionmailer/lib/action_mailer/test_helper.rb b/actionmailer/lib/action_mailer/test_helper.rb
index 3a1612442f..f234c0248c 100644
--- a/actionmailer/lib/action_mailer/test_helper.rb
+++ b/actionmailer/lib/action_mailer/test_helper.rb
@@ -58,6 +58,7 @@ module ActionMailer
end
end
+# TODO: Deprecate this
module Test
module Unit
class TestCase
diff --git a/actionmailer/lib/action_mailer/utils.rb b/actionmailer/lib/action_mailer/utils.rb
index 552f695a92..26d2e60aaf 100644
--- a/actionmailer/lib/action_mailer/utils.rb
+++ b/actionmailer/lib/action_mailer/utils.rb
@@ -3,6 +3,5 @@ module ActionMailer
def normalize_new_lines(text)
text.to_s.gsub(/\r\n?/, "\n")
end
- module_function :normalize_new_lines
end
end
diff --git a/actionmailer/lib/action_mailer/vendor.rb b/actionmailer/lib/action_mailer/vendor.rb
deleted file mode 100644
index 7a20e9bd6e..0000000000
--- a/actionmailer/lib/action_mailer/vendor.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# Prefer gems to the bundled libs.
-require 'rubygems'
-
-begin
- gem 'tmail', '~> 1.2.3'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/tmail-1.2.3"
-end
-
-begin
- gem 'text-format', '>= 0.6.3'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/text-format-0.6.3"
-end
diff --git a/actionmailer/lib/action_mailer/vendor/text_format.rb b/actionmailer/lib/action_mailer/vendor/text_format.rb
new file mode 100644
index 0000000000..c6c8c394d0
--- /dev/null
+++ b/actionmailer/lib/action_mailer/vendor/text_format.rb
@@ -0,0 +1,10 @@
+# Prefer gems to the bundled libs.
+require 'rubygems'
+
+begin
+ gem 'text-format', '>= 0.6.3'
+rescue Gem::LoadError
+ $:.unshift "#{File.dirname(__FILE__)}/text-format-0.6.3"
+end
+
+require 'text/format'
diff --git a/actionmailer/lib/action_mailer/vendor/tmail.rb b/actionmailer/lib/action_mailer/vendor/tmail.rb
new file mode 100644
index 0000000000..51d36cdd0d
--- /dev/null
+++ b/actionmailer/lib/action_mailer/vendor/tmail.rb
@@ -0,0 +1,17 @@
+# Prefer gems to the bundled libs.
+require 'rubygems'
+
+begin
+ gem 'tmail', '~> 1.2.3'
+rescue Gem::LoadError
+ $:.unshift "#{File.dirname(__FILE__)}/tmail-1.2.3"
+end
+
+module TMail
+end
+
+require 'tmail'
+
+silence_warnings do
+ TMail::Encoder.const_set("MAX_LINE_LEN", 200)
+end
diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb
index 13a859a5cc..2650efccdb 100644
--- a/actionmailer/test/quoting_test.rb
+++ b/actionmailer/test/quoting_test.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
require 'abstract_unit'
-require 'tmail'
require 'tempfile'
class QuotingTest < Test::Unit::TestCase
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 9581442208..1d6e5455da 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -27,7 +27,9 @@
* Fixed RedCloth and BlueCloth shouldn't preload. Instead just assume that they're available if you want to use textilize and markdown and let autoload require them [DHH]
-*2.2.1 [RC2] (November 14th, 2008)*
+*2.2.2 (November 21st, 2008)*
+
+* I18n: translate number_to_human_size. Add storage_units: [Bytes, KB, MB, GB, TB] to your translations. #1448 [Yaroslav Markin]
* Restore backwards compatible functionality for setting relative_url_root. Include deprecation
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index ff8ec0d2fc..5f87429aca 100644
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -32,47 +32,63 @@ rescue LoadError
end
$:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner"
-require 'action_controller/vendor/rack'
-require 'action_controller/base'
-require 'action_controller/request'
-require 'action_controller/rescue'
-require 'action_controller/benchmarking'
-require 'action_controller/flash'
-require 'action_controller/filters'
-require 'action_controller/layout'
-require 'action_controller/mime_responds'
-require 'action_controller/helpers'
-require 'action_controller/cookies'
-require 'action_controller/cgi_process'
-require 'action_controller/caching'
-require 'action_controller/verification'
-require 'action_controller/streaming'
-require 'action_controller/session_management'
-require 'action_controller/http_authentication'
-require 'action_controller/rack_process'
-require 'action_controller/record_identifier'
-require 'action_controller/request_forgery_protection'
-require 'action_controller/headers'
-require 'action_controller/translation'
+module ActionController
+ # TODO: Review explicit to see if they will automatically be handled by
+ # the initilizer if they are really needed.
+ def self.load_all!
+ [Base, CgiRequest, CgiResponse, RackRequest, RackRequest, Http::Headers, UrlRewriter, UrlWriter]
+ end
-require 'action_view'
+ autoload :AbstractRequest, 'action_controller/request'
+ autoload :AbstractResponse, 'action_controller/response'
+ autoload :Base, 'action_controller/base'
+ autoload :Benchmarking, 'action_controller/benchmarking'
+ autoload :Caching, 'action_controller/caching'
+ autoload :CgiRequest, 'action_controller/cgi_process'
+ autoload :CgiResponse, 'action_controller/cgi_process'
+ autoload :Cookies, 'action_controller/cookies'
+ autoload :Dispatcher, 'action_controller/dispatcher'
+ autoload :Filters, 'action_controller/filters'
+ autoload :Flash, 'action_controller/flash'
+ autoload :Helpers, 'action_controller/helpers'
+ autoload :HttpAuthentication, 'action_controller/http_authentication'
+ autoload :IntegrationTest, 'action_controller/integration'
+ autoload :Layout, 'action_controller/layout'
+ autoload :MimeResponds, 'action_controller/mime_responds'
+ autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'
+ autoload :RackRequest, 'action_controller/rack_process'
+ autoload :RackResponse, 'action_controller/rack_process'
+ autoload :RecordIdentifier, 'action_controller/record_identifier'
+ autoload :RequestForgeryProtection, 'action_controller/request_forgery_protection'
+ autoload :Rescue, 'action_controller/rescue'
+ autoload :Resources, 'action_controller/resources'
+ autoload :Routing, 'action_controller/routing'
+ autoload :SessionManagement, 'action_controller/session_management'
+ autoload :StatusCodes, 'action_controller/status_codes'
+ autoload :Streaming, 'action_controller/streaming'
+ autoload :TestCase, 'action_controller/test_case'
+ autoload :TestProcess, 'action_controller/test_process'
+ autoload :Translation, 'action_controller/translation'
+ autoload :UrlRewriter, 'action_controller/url_rewriter'
+ autoload :UrlWriter, 'action_controller/url_rewriter'
+ autoload :Verification, 'action_controller/verification'
-ActionController::Base.class_eval do
- include ActionController::Flash
- include ActionController::Filters
- include ActionController::Layout
- include ActionController::Benchmarking
- include ActionController::Rescue
- include ActionController::MimeResponds
- include ActionController::Helpers
- include ActionController::Cookies
- include ActionController::Caching
- include ActionController::Verification
- include ActionController::Streaming
- include ActionController::SessionManagement
- include ActionController::HttpAuthentication::Basic::ControllerMethods
- include ActionController::RecordIdentifier
- include ActionController::RequestForgeryProtection
- include ActionController::Translation
+ module Http
+ autoload :Headers, 'action_controller/headers'
+ end
end
+
+class CGI
+ class Session
+ autoload :ActiveRecordStore, 'action_controller/session/active_record_store'
+ autoload :CookieStore, 'action_controller/session/cookie_store'
+ autoload :DRbStore, 'action_controller/session/drb_store'
+ autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
+ end
+end
+
+autoload :Mime, 'action_controller/mime_type'
+autoload :Rack, 'action_controller/vendor/rack'
+
+ActionController.load_all!
diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index e2e8bbdc71..7ab24389b8 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -1,6 +1,3 @@
-require 'rexml/document'
-require 'html/document'
-
module ActionController
module Assertions
# A small suite of assertions that test responses from Rails applications.
diff --git a/actionpack/lib/action_controller/assertions/selector_assertions.rb b/actionpack/lib/action_controller/assertions/selector_assertions.rb
index bcbb570e4b..40ac572fdb 100644
--- a/actionpack/lib/action_controller/assertions/selector_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/selector_assertions.rb
@@ -3,8 +3,7 @@
# Under MIT and/or CC By license.
#++
-require 'rexml/document'
-require 'html/document'
+require 'action_controller/vendor/html-scanner'
module ActionController
module Assertions
diff --git a/actionpack/lib/action_controller/assertions/tag_assertions.rb b/actionpack/lib/action_controller/assertions/tag_assertions.rb
index 90ba3668fb..80249e0e83 100644
--- a/actionpack/lib/action_controller/assertions/tag_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/tag_assertions.rb
@@ -1,6 +1,3 @@
-require 'rexml/document'
-require 'html/document'
-
module ActionController
module Assertions
# Pair of assertions to testing elements in the HTML output of the response.
@@ -127,4 +124,4 @@ module ActionController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index ad6562024a..041ff62a74 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1,12 +1,4 @@
-require 'action_controller/mime_type'
-require 'action_controller/request'
-require 'action_controller/response'
-require 'action_controller/routing'
-require 'action_controller/resources'
-require 'action_controller/url_rewriter'
-require 'action_controller/status_codes'
require 'action_view'
-require 'drb'
require 'set'
module ActionController #:nodoc:
@@ -1332,4 +1324,11 @@ module ActionController #:nodoc:
close_session
end
end
+
+ Base.class_eval do
+ include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers
+ include Cookies, Caching, Verification, Streaming
+ include SessionManagement, HttpAuthentication::Basic::ControllerMethods
+ include RecordIdentifier, RequestForgeryProtection, Translation
+ end
end
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index c4063dfb4b..b4d251eb3c 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -2,13 +2,6 @@ require 'fileutils'
require 'uri'
require 'set'
-require 'action_controller/caching/pages'
-require 'action_controller/caching/actions'
-require 'action_controller/caching/sql_cache'
-require 'action_controller/caching/sweeping'
-require 'action_controller/caching/fragments'
-
-
module ActionController #:nodoc:
# Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls
# around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment.
@@ -31,6 +24,12 @@ module ActionController #:nodoc:
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
module Caching
+ autoload :Actions, 'action_controller/caching/actions'
+ autoload :Fragments, 'action_controller/caching/fragments'
+ autoload :Pages, 'action_controller/caching/pages'
+ autoload :SqlCache, 'action_controller/caching/sql_cache'
+ autoload :Sweeping, 'action_controller/caching/sweeping'
+
def self.included(base) #:nodoc:
base.class_eval do
@@cache_store = nil
@@ -63,10 +62,9 @@ module ActionController #:nodoc:
end
end
-
- private
+ private
def cache_configured?
self.class.cache_configured?
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb
index fabacd9b83..45b51a7488 100644
--- a/actionpack/lib/action_controller/cgi_process.rb
+++ b/actionpack/lib/action_controller/cgi_process.rb
@@ -1,5 +1,4 @@
require 'action_controller/cgi_ext'
-require 'action_controller/session/cookie_store'
module ActionController #:nodoc:
class Base
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index b3771c1ebc..333fb742e4 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -1,7 +1,3 @@
-require 'action_controller/test_case'
-require 'action_controller/dispatcher'
-require 'action_controller/test_process'
-
require 'stringio'
require 'uri'
diff --git a/actionpack/lib/action_controller/performance_test.rb b/actionpack/lib/action_controller/performance_test.rb
index 85543fffae..d88180087d 100644
--- a/actionpack/lib/action_controller/performance_test.rb
+++ b/actionpack/lib/action_controller/performance_test.rb
@@ -1,4 +1,3 @@
-require 'action_controller/integration'
require 'active_support/testing/performance'
require 'active_support/testing/default'
diff --git a/actionpack/lib/action_controller/rack_process.rb b/actionpack/lib/action_controller/rack_process.rb
index e8ea3704a8..58d7b53e31 100644
--- a/actionpack/lib/action_controller/rack_process.rb
+++ b/actionpack/lib/action_controller/rack_process.rb
@@ -1,5 +1,4 @@
require 'action_controller/cgi_ext'
-require 'action_controller/session/cookie_store'
module ActionController #:nodoc:
class RackRequest < AbstractRequest #:nodoc:
diff --git a/actionpack/lib/action_controller/request_profiler.rb b/actionpack/lib/action_controller/request_profiler.rb
index a6471d0c08..70bb77e7ac 100644
--- a/actionpack/lib/action_controller/request_profiler.rb
+++ b/actionpack/lib/action_controller/request_profiler.rb
@@ -1,5 +1,4 @@
require 'optparse'
-require 'action_controller/integration'
module ActionController
class RequestProfiler
diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb
index 7700b9d4d0..b5ea764911 100644
--- a/actionpack/lib/action_controller/resources.rb
+++ b/actionpack/lib/action_controller/resources.rb
@@ -669,7 +669,3 @@ module ActionController
end
end
end
-
-class ActionController::Routing::RouteSet::Mapper
- include ActionController::Resources
-end
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 8d51e823a6..efd474097e 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -1,6 +1,5 @@
require 'cgi'
require 'uri'
-require 'action_controller/polymorphic_routes'
require 'action_controller/routing/optimisations'
require 'action_controller/routing/routing_ext'
require 'action_controller/routing/route'
diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb
index 1b8b52ad10..3bb25dbba9 100644
--- a/actionpack/lib/action_controller/routing/route_set.rb
+++ b/actionpack/lib/action_controller/routing/route_set.rb
@@ -7,6 +7,8 @@ module ActionController
# Mapper instances have relatively few instance methods, in order to avoid
# clashes with named routes.
class Mapper #:doc:
+ include ActionController::Resources
+
def initialize(set) #:nodoc:
@set = set
end
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb
index fd3d94ed97..60a9aec39c 100644
--- a/actionpack/lib/action_controller/session_management.rb
+++ b/actionpack/lib/action_controller/session_management.rb
@@ -1,10 +1,3 @@
-require 'action_controller/session/cookie_store'
-require 'action_controller/session/drb_store'
-require 'action_controller/session/mem_cache_store'
-if Object.const_defined?(:ActiveRecord)
- require 'action_controller/session/active_record_store'
-end
-
module ActionController #:nodoc:
module SessionManagement #:nodoc:
def self.included(base)
diff --git a/actionpack/lib/action_controller/vendor/html-scanner.rb b/actionpack/lib/action_controller/vendor/html-scanner.rb
new file mode 100644
index 0000000000..5c6db99858
--- /dev/null
+++ b/actionpack/lib/action_controller/vendor/html-scanner.rb
@@ -0,0 +1,9 @@
+$LOAD_PATH << "#{File.dirname(__FILE__)}/html-scanner"
+
+module HTML
+ autoload :Document, 'html/document'
+ autoload :Sanitizer, 'html/sanitizer'
+ autoload :FullSanitizer, 'html/sanitizer'
+ autoload :LinkSanitizer, 'html/sanitizer'
+ autoload :WhiteListSanitizer, 'html/sanitizer'
+end
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index 7b1d3f8e7c..0c76204060 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -31,23 +31,29 @@ rescue LoadError
end
end
-require 'action_view/template_handlers'
-require 'action_view/renderable'
-require 'action_view/renderable_partial'
+module ActionView
+ def self.load_all!
+ [Base, InlineTemplate, TemplateError]
+ end
-require 'action_view/template'
-require 'action_view/inline_template'
-require 'action_view/paths'
+ autoload :Base, 'action_view/base'
+ autoload :Helpers, 'action_view/helpers'
+ autoload :InlineTemplate, 'action_view/inline_template'
+ autoload :Partials, 'action_view/partials'
+ autoload :PathSet, 'action_view/paths'
+ autoload :Renderable, 'action_view/renderable'
+ autoload :RenderablePartial, 'action_view/renderable_partial'
+ autoload :Template, 'action_view/template'
+ autoload :TemplateError, 'action_view/template_error'
+ autoload :TemplateHandler, 'action_view/template_handler'
+ autoload :TemplateHandlers, 'action_view/template_handlers'
+ autoload :Helpers, 'action_view/helpers'
+end
-require 'action_view/base'
-require 'action_view/partials'
-require 'action_view/template_error'
+class ERB
+ autoload :Util, 'action_view/erb/util'
+end
I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
-require 'action_view/helpers'
-
-ActionView::Base.class_eval do
- include ActionView::Partials
- include ActionView::Helpers
-end
+ActionView.load_all!
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 0d3752d875..7697848713 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -157,7 +157,7 @@ module ActionView #:nodoc:
#
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
class Base
- include ERB::Util
+ include Helpers, Partials, ::ERB::Util
extend ActiveSupport::Memoizable
attr_accessor :base_path, :assigns, :template_extension
diff --git a/actionpack/lib/action_view/erb/util.rb b/actionpack/lib/action_view/erb/util.rb
new file mode 100644
index 0000000000..3c77c5ce76
--- /dev/null
+++ b/actionpack/lib/action_view/erb/util.rb
@@ -0,0 +1,38 @@
+require 'erb'
+
+class ERB
+ module Util
+ HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
+ JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
+
+ # 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.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
+ end
+
+ # A utility method for escaping HTML entities in JSON strings.
+ # This method is also aliased as <tt>j</tt>.
+ #
+ # In your ERb templates, use this method to escape any HTML entities:
+ # <%=j @person.to_json %>
+ #
+ # ==== Example:
+ # puts json_escape("is a > 0 & a < 10?")
+ # # => is a \u003E 0 \u0026 a \u003C 10?
+ def json_escape(s)
+ s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
+ end
+
+ alias j json_escape
+ module_function :j
+ module_function :json_escape
+ end
+end
diff --git a/actionpack/lib/action_view/helpers.rb b/actionpack/lib/action_view/helpers.rb
index ff97df204c..693ab7c2e0 100644
--- a/actionpack/lib/action_view/helpers.rb
+++ b/actionpack/lib/action_view/helpers.rb
@@ -1,10 +1,28 @@
-Dir.entries(File.expand_path("#{File.dirname(__FILE__)}/helpers")).sort.each do |file|
- next unless file =~ /^([a-z][a-z_]*_helper).rb$/
- require "action_view/helpers/#{$1}"
-end
-
module ActionView #:nodoc:
module Helpers #:nodoc:
+ autoload :ActiveRecordHelper, 'action_view/helpers/active_record_helper'
+ autoload :AssetTagHelper, 'action_view/helpers/asset_tag_helper'
+ autoload :AtomFeedHelper, 'action_view/helpers/atom_feed_helper'
+ autoload :BenchmarkHelper, 'action_view/helpers/benchmark_helper'
+ autoload :CacheHelper, 'action_view/helpers/cache_helper'
+ autoload :CaptureHelper, 'action_view/helpers/capture_helper'
+ autoload :DateHelper, 'action_view/helpers/date_helper'
+ autoload :DebugHelper, 'action_view/helpers/debug_helper'
+ autoload :FormHelper, 'action_view/helpers/form_helper'
+ autoload :FormOptionsHelper, 'action_view/helpers/form_options_helper'
+ autoload :FormTagHelper, 'action_view/helpers/form_tag_helper'
+ autoload :JavascriptHelper, 'action_view/helpers/javascript_helper'
+ autoload :NumberHelper, 'action_view/helpers/number_helper'
+ autoload :PrototypeHelper, 'action_view/helpers/prototype_helper'
+ autoload :RecordIdentificationHelper, 'action_view/helpers/record_identification_helper'
+ autoload :RecordTagHelper, 'action_view/helpers/record_tag_helper'
+ autoload :SanitizeHelper, 'action_view/helpers/sanitize_helper'
+ autoload :ScriptaculousHelper, 'action_view/helpers/scriptaculous_helper'
+ autoload :TagHelper, 'action_view/helpers/tag_helper'
+ autoload :TextHelper, 'action_view/helpers/text_helper'
+ autoload :TranslationHelper, 'action_view/helpers/translation_helper'
+ autoload :UrlHelper, 'action_view/helpers/url_helper'
+
def self.included(base)
base.extend(ClassMethods)
end
@@ -24,6 +42,7 @@ module ActionView #:nodoc:
include FormHelper
include FormOptionsHelper
include FormTagHelper
+ include JavaScriptHelper
include NumberHelper
include PrototypeHelper
include RecordIdentificationHelper
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 77f19b36a6..3e734ccaab 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -220,8 +220,6 @@ module ActionView
end
end
- STORAGE_UNITS = %w( Bytes KB MB GB TB ).freeze
-
# Formats the bytes in +size+ into a more understandable representation
# (e.g., giving it 1500 yields 1.5 KB). This method is useful for
# reporting file sizes to users. This method returns nil if
@@ -257,6 +255,7 @@ module ActionView
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
human = I18n.translate(:'number.human.format', :locale => options[:locale], :raise => true) rescue {}
defaults = defaults.merge(human)
+ storage_units = I18n.translate(:'number.human.storage_units', :locale => options[:locale], :raise => true)
unless args.empty?
ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' +
@@ -268,12 +267,12 @@ module ActionView
separator ||= (options[:separator] || defaults[:separator])
delimiter ||= (options[:delimiter] || defaults[:delimiter])
- max_exp = STORAGE_UNITS.size - 1
+ max_exp = storage_units.size - 1
number = Float(number)
exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024
exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
number /= 1024 ** exponent
- unit = STORAGE_UNITS[exponent]
+ unit = storage_units[exponent]
begin
escaped_separator = Regexp.escape(separator)
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb
index 435ba936e1..200c1d6085 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -1,14 +1,5 @@
require 'action_view/helpers/tag_helper'
-
-begin
- require 'html/document'
-rescue LoadError
- html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner"
- if File.directory?(html_scanner_path)
- $:.unshift html_scanner_path
- require 'html/document'
- end
-end
+require 'action_controller/vendor/html-scanner'
module ActionView
module Helpers #:nodoc:
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 510c1a6a76..506138a735 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -1,15 +1,5 @@
require 'action_view/helpers/tag_helper'
-begin
- require 'html/document'
-rescue LoadError
- html_scanner_path = "#{File.dirname(__FILE__)}/../../action_controller/vendor/html-scanner"
- if File.directory?(html_scanner_path)
- $:.unshift html_scanner_path
- require 'html/document'
- end
-end
-
module ActionView
module Helpers #:nodoc:
# The TextHelper module provides a set of methods for filtering, formatting
diff --git a/actionpack/lib/action_view/locale/en.yml b/actionpack/lib/action_view/locale/en.yml
index 002226fd9c..9542b035aa 100644
--- a/actionpack/lib/action_view/locale/en.yml
+++ b/actionpack/lib/action_view/locale/en.yml
@@ -44,6 +44,7 @@
# separator:
delimiter: ""
precision: 1
+ storage_units: [Bytes, KB, MB, GB, TB]
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime:
diff --git a/actionpack/lib/action_view/template_handler.rb b/actionpack/lib/action_view/template_handler.rb
index d7e7c9b199..672da0ed2b 100644
--- a/actionpack/lib/action_view/template_handler.rb
+++ b/actionpack/lib/action_view/template_handler.rb
@@ -1,14 +1,34 @@
# Legacy TemplateHandler stub
-
module ActionView
- module TemplateHandlers
+ module TemplateHandlers #:nodoc:
module Compilable
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def call(template)
+ new.compile(template)
+ end
+ end
+
+ def compile(template)
+ raise "Need to implement #{self.class.name}#compile(template)"
+ end
end
end
class TemplateHandler
def self.call(template)
- new.compile(template)
+ "#{name}.new(self).render(template, local_assigns)"
+ end
+
+ def initialize(view = nil)
+ @view = view
+ end
+
+ def render(template, local_assigns)
+ raise "Need to implement #{self.class.name}#render(template, local_assigns)"
end
end
end
diff --git a/actionpack/lib/action_view/template_handlers.rb b/actionpack/lib/action_view/template_handlers.rb
index 6c8aa4c2a7..d06ddd5fb5 100644
--- a/actionpack/lib/action_view/template_handlers.rb
+++ b/actionpack/lib/action_view/template_handlers.rb
@@ -1,10 +1,9 @@
-require 'action_view/template_handler'
-require 'action_view/template_handlers/builder'
-require 'action_view/template_handlers/erb'
-require 'action_view/template_handlers/rjs'
-
module ActionView #:nodoc:
module TemplateHandlers #:nodoc:
+ autoload :ERB, 'action_view/template_handlers/erb'
+ autoload :RJS, 'action_view/template_handlers/rjs'
+ autoload :Builder, 'action_view/template_handlers/builder'
+
def self.extended(base)
base.register_default_template_handler :erb, TemplateHandlers::ERB
base.register_template_handler :rjs, TemplateHandlers::RJS
diff --git a/actionpack/lib/action_view/template_handlers/erb.rb b/actionpack/lib/action_view/template_handlers/erb.rb
index 3def949f1e..f8d3da15be 100644
--- a/actionpack/lib/action_view/template_handlers/erb.rb
+++ b/actionpack/lib/action_view/template_handlers/erb.rb
@@ -1,42 +1,3 @@
-require 'erb'
-
-class ERB
- module Util
- HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
- JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
-
- # 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.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
- end
-
- # A utility method for escaping HTML entities in JSON strings.
- # This method is also aliased as <tt>j</tt>.
- #
- # In your ERb templates, use this method to escape any HTML entities:
- # <%=j @person.to_json %>
- #
- # ==== Example:
- # puts json_escape("is a > 0 & a < 10?")
- # # => is a \u003E 0 \u0026 a \u003C 10?
- def json_escape(s)
- s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
- end
-
- alias j json_escape
- module_function :j
- module_function :json_escape
- end
-end
-
module ActionView
module TemplateHandlers
class ERB < TemplateHandler
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index cdea1def92..4ab4ed233f 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -1,5 +1,3 @@
-require 'action_controller/test_case'
-
module ActionView
class TestCase < ActiveSupport::TestCase
include ActionController::TestCase::Assertions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 76812b94df..bee598e1ef 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -8,7 +8,7 @@ require 'yaml'
require 'stringio'
require 'test/unit'
-gem 'mocha', '>= 0.9.0'
+gem 'mocha', '>= 0.9.3'
require 'mocha'
begin
diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb
index fd7da89aa7..677d434f9c 100644
--- a/actionpack/test/activerecord/active_record_store_test.rb
+++ b/actionpack/test/activerecord/active_record_store_test.rb
@@ -1,7 +1,6 @@
# These tests exercise CGI::Session::ActiveRecordStore, so you're going to
# need AR in a sibling directory to AP and have SQLite installed.
require 'active_record_unit'
-require 'action_controller/session/active_record_store'
module CommonActiveRecordStoreTests
def test_basics
diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb
index a79278159d..ed8c4427c9 100644
--- a/actionpack/test/controller/assert_select_test.rb
+++ b/actionpack/test/controller/assert_select_test.rb
@@ -9,9 +9,10 @@ require 'controller/fake_controllers'
unless defined?(ActionMailer)
begin
- $:.unshift(File.dirname(__FILE__) + "/../../../actionmailer/lib")
+ $:.unshift("#{File.dirname(__FILE__)}/../../../actionmailer/lib")
require 'action_mailer'
- rescue LoadError
+ rescue LoadError => e
+ raise unless e.message =~ /action_mailer/
require 'rubygems'
gem 'actionmailer'
end
diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb
index 87fbf1a4cd..ac1c8abc59 100644
--- a/actionpack/test/controller/cgi_test.rb
+++ b/actionpack/test/controller/cgi_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
class BaseCgiTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index 3ee78a6156..61bfb2b6e9 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -2,8 +2,6 @@ require 'abstract_unit'
uses_mocha 'dispatcher tests' do
-require 'action_controller/dispatcher'
-
class DispatcherTest < Test::Unit::TestCase
Dispatcher = ActionController::Dispatcher
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 7e4c3e171a..b39d35930d 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -1,6 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
-require 'action_controller/routing'
uses_mocha 'integration' do
diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb
index 4af9b7e697..b1dd6a6341 100644
--- a/actionpack/test/controller/integration_upload_test.rb
+++ b/actionpack/test/controller/integration_upload_test.rb
@@ -1,6 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
-require 'action_controller/routing'
unless defined? ApplicationController
class ApplicationController < ActionController::Base
diff --git a/actionpack/test/controller/rack_test.rb b/actionpack/test/controller/rack_test.rb
index d5e56b9584..7e8b0f9bf2 100644
--- a/actionpack/test/controller/rack_test.rb
+++ b/actionpack/test/controller/rack_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/rack_process'
class BaseRackTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb
index 7e264289e6..316a203e97 100644
--- a/actionpack/test/controller/request_test.rb
+++ b/actionpack/test/controller/request_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
class RequestTest < ActiveSupport::TestCase
def setup
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index b8a143cfd9..d62c7a1743 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -1,6 +1,5 @@
require 'abstract_unit'
require 'controller/fake_controllers'
-require 'action_controller/routing'
class MilestonesController < ActionController::Base
def index() head :ok end
diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/controller/session/cookie_store_test.rb
index 52c1f7559c..b5f14acc1f 100644
--- a/actionpack/test/controller/session/cookie_store_test.rb
+++ b/actionpack/test/controller/session/cookie_store_test.rb
@@ -1,7 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
-require 'action_controller/cgi_ext'
-
require 'stringio'
diff --git a/actionpack/test/controller/session/mem_cache_store_test.rb b/actionpack/test/controller/session/mem_cache_store_test.rb
index a7d48431f8..9ab927a01f 100644
--- a/actionpack/test/controller/session/mem_cache_store_test.rb
+++ b/actionpack/test/controller/session/mem_cache_store_test.rb
@@ -1,7 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
-require 'action_controller/cgi_ext'
-
class CGI::Session
def cache
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index a33eb85b66..86a0bb6a79 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'tzinfo'
TZInfo::Timezone.cattr_reader :loaded_zones
@@ -682,4 +683,4 @@ uses_mocha "FormOptionsHelperTest" do
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/template/number_helper_i18n_test.rb b/actionpack/test/template/number_helper_i18n_test.rb
index 67c61a5f2e..2528bead36 100644
--- a/actionpack/test/template/number_helper_i18n_test.rb
+++ b/actionpack/test/template/number_helper_i18n_test.rb
@@ -10,6 +10,7 @@ class NumberHelperI18nTests < Test::Unit::TestCase
@number_defaults = { :precision => 3, :delimiter => ',', :separator => '.' }
@currency_defaults = { :unit => '$', :format => '%u%n', :precision => 2 }
@human_defaults = { :precision => 1 }
+ @human_storage_units_defaults = %w(Bytes KB MB GB TB)
@percentage_defaults = { :delimiter => '' }
@precision_defaults = { :delimiter => '' }
@@ -47,6 +48,8 @@ class NumberHelperI18nTests < Test::Unit::TestCase
I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults)
I18n.expects(:translate).with(:'number.human.format', :locale => 'en',
:raise => true).returns(@human_defaults)
+ I18n.expects(:translate).with(:'number.human.storage_units', :locale => 'en',
+ :raise => true).returns(@human_storage_units_defaults)
# can't be called with 1 because this directly returns without calling I18n.translate
number_to_human_size(1025, :locale => 'en')
end
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 0323c33b95..b316d5c23e 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -175,6 +175,17 @@ class ViewRenderTest < Test::Unit::TestCase
assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
end
+ class LegacyHandler < ActionView::TemplateHandler
+ def render(template, local_assigns)
+ "source: #{template.source}; locals: #{local_assigns.inspect}"
+ end
+ end
+
+ def test_render_legacy_handler_with_custom_type
+ ActionView::Template.register_template_handler :foo, LegacyHandler
+ assert_equal 'source: Hello, <%= name %>!; locals: {:name=>"Josh"}', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
+ end
+
def test_render_with_layout
assert_equal %(<title></title>\nHello world!\n),
@view.render(:file => "test/hello_world.erb", :layout => "layouts/yield")
diff --git a/activemodel/test/test_helper.rb b/activemodel/test/test_helper.rb
index 78f1c364e3..4dd5b9832b 100644
--- a/activemodel/test/test_helper.rb
+++ b/activemodel/test/test_helper.rb
@@ -1,7 +1,7 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.5.5'
+gem 'mocha', '>= 0.9.3'
require 'mocha'
require 'active_model'
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index 7337b55a21..06bb5690d3 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -21,6 +21,19 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
+module ActiveSupport
+ autoload :Duration, 'active_support/duration'
+ autoload :Gzip, 'active_support/gzip'
+ autoload :MessageVerifier, 'active_support/message_verifier'
+ autoload :OptionMerger, 'active_support/option_merger'
+ autoload :OrderedHash, 'active_support/ordered_hash'
+ autoload :OrderedOptions, 'active_support/ordered_options'
+ autoload :SecureRandom, 'active_support/secure_random'
+ autoload :StringInquirer, 'active_support/string_inquirer'
+ autoload :TimeWithZone, 'active_support/time_with_zone'
+ autoload :TimeZone, 'active_support/values/time_zone'
+end
+
require 'active_support/vendor'
require 'active_support/basic_object'
require 'active_support/inflector'
@@ -31,21 +44,12 @@ require 'active_support/core_ext'
require 'active_support/buffered_logger'
require 'active_support/backtrace_cleaner'
-require 'active_support/gzip'
require 'active_support/cache'
require 'active_support/dependencies'
require 'active_support/deprecation'
-require 'active_support/ordered_hash'
-require 'active_support/ordered_options'
-require 'active_support/option_merger'
-
require 'active_support/memoizable'
-require 'active_support/string_inquirer'
-
-require 'active_support/values/time_zone'
-require 'active_support/duration'
require 'active_support/json'
@@ -53,11 +57,6 @@ require 'active_support/multibyte'
require 'active_support/base64'
-require 'active_support/time_with_zone'
-
-require 'active_support/secure_random'
-require 'active_support/message_verifier'
-
require 'active_support/rescuable'
-I18n.load_path << File.dirname(__FILE__) + '/active_support/locale/en.yml'
+I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index e62cec6fcb..10281d60eb 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -3,6 +3,13 @@ require 'benchmark'
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.
module Cache
+ autoload :FileStore, 'active_support/cache/file_store'
+ autoload :MemoryStore, 'active_support/cache/memory_store'
+ autoload :SynchronizedMemoryStore, 'active_support/cache/synchronized_memory_store'
+ autoload :DRbStore, 'active_support/cache/drb_store'
+ autoload :MemCacheStore, 'active_support/cache/mem_cache_store'
+ autoload :CompressedMemCacheStore, 'active_support/cache/compressed_mem_cache_store'
+
# Creates a new CacheStore object according to the given options.
#
# If no arguments are passed to this method, then a new
@@ -215,9 +222,3 @@ module ActiveSupport
end
end
end
-
-require 'active_support/cache/file_store'
-require 'active_support/cache/memory_store'
-require 'active_support/cache/drb_store'
-require 'active_support/cache/mem_cache_store'
-require 'active_support/cache/compressed_mem_cache_store'
diff --git a/activesupport/lib/active_support/cache/drb_store.rb b/activesupport/lib/active_support/cache/drb_store.rb
index b80c2ee4d5..b16ed25aa3 100644
--- a/activesupport/lib/active_support/cache/drb_store.rb
+++ b/activesupport/lib/active_support/cache/drb_store.rb
@@ -1,15 +1,14 @@
-require 'drb'
-
module ActiveSupport
module Cache
class DRbStore < MemoryStore #:nodoc:
attr_reader :address
def initialize(address = 'druby://localhost:9192')
+ require 'drb' unless defined?(DRbObject)
super()
@address = address
@data = DRbObject.new(nil, address)
end
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/core_ext.rb b/activesupport/lib/active_support/core_ext.rb
index 4deef8c7a5..f2f976df9b 100644
--- a/activesupport/lib/active_support/core_ext.rb
+++ b/activesupport/lib/active_support/core_ext.rb
@@ -1,4 +1,4 @@
Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each do |path|
- filename = File.basename(path)
+ filename = File.basename(path, '.rb')
require "active_support/core_ext/#{filename}"
end
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index cf3e03f62c..f0d6591135 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -1,5 +1,3 @@
-require 'builder'
-
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
module Array #:nodoc:
@@ -149,6 +147,7 @@ module ActiveSupport #:nodoc:
#
def to_xml(options = {})
raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
+ require 'builder' unless defined?(Builder)
options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records"
options[:children] ||= options[:root].singularize
diff --git a/activesupport/lib/active_support/core_ext/file/atomic.rb b/activesupport/lib/active_support/core_ext/file/atomic.rb
index f988eff3d9..976d462e8e 100644
--- a/activesupport/lib/active_support/core_ext/file/atomic.rb
+++ b/activesupport/lib/active_support/core_ext/file/atomic.rb
@@ -1,5 +1,3 @@
-require 'tempfile'
-
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
module File #:nodoc:
@@ -18,6 +16,8 @@ module ActiveSupport #:nodoc:
# file.write("hello")
# end
def atomic_write(file_name, temp_dir = Dir.tmpdir)
+ require 'tempfile' unless defined?(Tempfile)
+
temp_file = Tempfile.new(basename(file_name), temp_dir)
yield temp_file
temp_file.close
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 50dc7c61fc..fe38fb665b 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -1,7 +1,4 @@
require 'date'
-require 'cgi'
-require 'builder'
-require 'xmlsimple'
# Locked down XmlSimple#xml_in_string
class XmlSimple
@@ -113,6 +110,8 @@ module ActiveSupport #:nodoc:
alias_method :to_param, :to_query
def to_xml(options = {})
+ require 'builder' unless defined?(Builder)
+
options[:indent] ||= 2
options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
:root => "hash" })
@@ -167,6 +166,8 @@ module ActiveSupport #:nodoc:
module ClassMethods
def from_xml(xml)
+ require 'xmlsimple'
+
# TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
typecast_xml_value(undasherize_keys(XmlSimple.xml_in_string(xml,
'forcearray' => false,
diff --git a/activesupport/lib/active_support/core_ext/object/conversions.rb b/activesupport/lib/active_support/core_ext/object/conversions.rb
index ad752f0fc5..1dee171ec4 100644
--- a/activesupport/lib/active_support/core_ext/object/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/object/conversions.rb
@@ -1,3 +1,5 @@
+require 'cgi'
+
class Object
# Alias of <tt>to_s</tt>.
def to_param
@@ -11,4 +13,4 @@ class Object
def to_query(key)
"#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index b3ad599371..543e3b08d2 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -113,37 +113,6 @@ module ActiveSupport
end
end
- module Assertions #:nodoc:
- def assert_deprecated(match = nil, &block)
- result, warnings = collect_deprecations(&block)
- assert !warnings.empty?, "Expected a deprecation warning within the block but received none"
- if match
- match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp)
- assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}"
- end
- result
- end
-
- def assert_not_deprecated(&block)
- result, deprecations = collect_deprecations(&block)
- assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}"
- result
- end
-
- private
- def collect_deprecations
- old_behavior = ActiveSupport::Deprecation.behavior
- deprecations = []
- ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
- deprecations << message
- end
- result = yield
- [result, deprecations]
- ensure
- ActiveSupport::Deprecation.behavior = old_behavior
- end
- end
-
class DeprecationProxy #:nodoc:
silence_warnings do
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
@@ -220,31 +189,3 @@ end
class Module
include ActiveSupport::Deprecation::ClassMethods
end
-
-
-require 'active_support/test_case'
-
-class ActiveSupport::TestCase
- include ActiveSupport::Deprecation::Assertions
-end
-
-begin
- require 'test/unit/error'
-
- module Test
- module Unit
- class Error # :nodoc:
- # Silence warnings when reporting test errors.
- def message_with_silenced_deprecation
- ActiveSupport::Deprecation.silence do
- message_without_silenced_deprecation
- end
- end
-
- alias_method_chain :message, :silenced_deprecation
- end
- end
- end
-rescue LoadError
- # Using miniunit, ignore.
-end
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 8eae85d38e..c41e86dfd1 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -1,3 +1,5 @@
+require 'active_support/basic_object'
+
module ActiveSupport
# Provides accurate date and time measurements using Date#advance and
# Time#advance, respectively. It mainly supports the methods on Numeric,
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index 8650e34228..d7caffbab3 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -12,26 +12,14 @@ module ActiveSupport
class CircularReferenceError < StandardError
end
- class << self
- REFERENCE_STACK_VARIABLE = :json_reference_stack #:nodoc:
-
- # Converts a Ruby object into a JSON string.
- def encode(value, options = {})
- raise_on_circular_reference(value) do
- value.send(:to_json, options)
- end
- end
-
- protected
- def raise_on_circular_reference(value) #:nodoc:
- stack = Thread.current[REFERENCE_STACK_VARIABLE] ||= []
- raise CircularReferenceError, 'object references itself' if
- stack.include? value
- stack << value
- yield
- ensure
- stack.pop
- end
+ # Converts a Ruby object into a JSON string.
+ def self.encode(value, options = {})
+ seen = (options[:seen] ||= [])
+ raise CircularReferenceError, 'object references itself' if seen.include?(value)
+ seen << value
+ value.send(:to_json, options)
+ ensure
+ seen.pop
end
end
end
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index 304058253c..b24acb9f47 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -39,7 +39,8 @@ module ActiveSupport
private
def generate_digest(data)
+ require 'openssl' unless defined?(OpenSSL)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), @secret, data)
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/secure_random.rb b/activesupport/lib/active_support/secure_random.rb
index 97971e8830..cfbce4d754 100644
--- a/activesupport/lib/active_support/secure_random.rb
+++ b/activesupport/lib/active_support/secure_random.rb
@@ -1,16 +1,11 @@
begin
- require 'openssl'
-rescue LoadError
-end
-
-begin
require 'securerandom'
rescue LoadError
end
module ActiveSupport
if defined?(::SecureRandom)
- # Use Ruby 1.9's SecureRandom library whenever possible.
+ # Use Ruby's SecureRandom library if available.
SecureRandom = ::SecureRandom # :nodoc:
else
# = Secure random number generator interface.
@@ -64,6 +59,13 @@ module ActiveSupport
def self.random_bytes(n=nil)
n ||= 16
+ unless defined? OpenSSL
+ begin
+ require 'openssl'
+ rescue LoadError
+ end
+ end
+
if defined? OpenSSL::Random
return OpenSSL::Random.random_bytes(n)
end
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index a4a45079fa..1cc8564a18 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -1,21 +1,18 @@
-require 'test/unit/testcase'
-require 'active_support/testing/setup_and_teardown'
-require 'active_support/testing/assertions'
-require 'active_support/testing/declarative'
-
begin
- gem 'mocha', '>= 0.9.0'
+ gem 'mocha', '>= 0.9.3'
require 'mocha'
-
- if defined?(MiniTest)
- require 'active_support/testing/mocha_minitest_adapter'
- end
rescue LoadError
# Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
Object.const_set :Mocha, Module.new
Mocha.const_set :ExpectationError, Class.new(StandardError)
end
+require 'test/unit/testcase'
+require 'active_support/testing/setup_and_teardown'
+require 'active_support/testing/assertions'
+require 'active_support/testing/deprecation'
+require 'active_support/testing/declarative'
+
module ActiveSupport
class TestCase < ::Test::Unit::TestCase
if defined? MiniTest
@@ -35,6 +32,7 @@ module ActiveSupport
include ActiveSupport::Testing::SetupAndTeardown
include ActiveSupport::Testing::Assertions
+ include ActiveSupport::Testing::Deprecation
extend ActiveSupport::Testing::Declarative
end
end
diff --git a/activesupport/lib/active_support/testing/deprecation.rb b/activesupport/lib/active_support/testing/deprecation.rb
new file mode 100644
index 0000000000..e9220605bd
--- /dev/null
+++ b/activesupport/lib/active_support/testing/deprecation.rb
@@ -0,0 +1,55 @@
+module ActiveSupport
+ module Testing
+ module Deprecation #:nodoc:
+ def assert_deprecated(match = nil, &block)
+ result, warnings = collect_deprecations(&block)
+ assert !warnings.empty?, "Expected a deprecation warning within the block but received none"
+ if match
+ match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp)
+ assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}"
+ end
+ result
+ end
+
+ def assert_not_deprecated(&block)
+ result, deprecations = collect_deprecations(&block)
+ assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}"
+ result
+ end
+
+ private
+ def collect_deprecations
+ old_behavior = ActiveSupport::Deprecation.behavior
+ deprecations = []
+ ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
+ deprecations << message
+ end
+ result = yield
+ [result, deprecations]
+ ensure
+ ActiveSupport::Deprecation.behavior = old_behavior
+ end
+ end
+ end
+end
+
+begin
+ require 'test/unit/error'
+
+ module Test
+ module Unit
+ class Error # :nodoc:
+ # Silence warnings when reporting test errors.
+ def message_with_silenced_deprecation
+ ActiveSupport::Deprecation.silence do
+ message_without_silenced_deprecation
+ end
+ end
+
+ alias_method_chain :message, :silenced_deprecation
+ end
+ end
+ end
+rescue LoadError
+ # Using miniunit, ignore.
+end
diff --git a/activesupport/lib/active_support/testing/mocha_minitest_adapter.rb b/activesupport/lib/active_support/testing/mocha_minitest_adapter.rb
deleted file mode 100644
index a96ce74526..0000000000
--- a/activesupport/lib/active_support/testing/mocha_minitest_adapter.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-class MiniTest::Unit::TestCase
- include Mocha::Standalone
-
- class MochaAssertionCounter
- def initialize(runner) @runner = runner end
- def increment; @runner.assertion_count += 1 end
- end
-
- def run(runner)
- assertion_counter = MochaAssertionCounter.new(runner)
- result = '.'
- begin
- begin
- @passed = nil
- setup
- __send__ name
- mocha_verify(assertion_counter)
- @passed = true
- rescue Exception => e
- @passed = false
- result = runner.puke(self.class, self.name, e)
- ensure
- begin
- teardown
- rescue Exception => e
- result = runner.puke(self.class, self.name, e)
- end
- end
- ensure
- mocha_teardown
- end
- result
- end
-end
-
-module Test
- module Unit
- remove_const :TestCase
-
- class TestCase < MiniTest::Unit::TestCase
- include Test::Unit::Assertions
- def self.test_order; :sorted end
- end
- end
-end
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index a02cd81f72..9a2d283b30 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -1,4 +1,5 @@
require 'tzinfo'
+
module ActiveSupport
# A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are
# limited to UTC and the system's <tt>ENV['TZ']</tt> zone.
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 1d87fa64b5..836f469df7 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -288,6 +288,7 @@ module ActiveSupport
# TODO: Preload instead of lazy load for thread safety
def tzinfo
+ require 'tzinfo' unless defined?(TZInfo)
@tzinfo ||= TZInfo::Timezone.get(MAPPING[name])
end
diff --git a/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb b/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb
index 8bdbd05899..a1990be37a 100644
--- a/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb
+++ b/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb
@@ -18,7 +18,6 @@ module Builder
end
if ! defined?(Builder::XChar)
- Builder.check_for_name_collision(String, "to_xs")
Builder.check_for_name_collision(Fixnum, "xchr")
end
@@ -105,11 +104,12 @@ end
# Enhance the String class with a XML escaped character version of
# to_s.
#
+require 'active_support/core_ext/string/xchar'
class String
# XML escaped version of to_s
def to_xs
unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
rescue
unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
- end
+ end unless method_defined?(:to_xs)
end
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb
index 4655f23a34..ac362d14c8 100644
--- a/activesupport/test/abstract_unit.rb
+++ b/activesupport/test/abstract_unit.rb
@@ -1,6 +1,6 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.9.0'
+gem 'mocha', '>= 0.9.3'
require 'mocha'
$:.unshift "#{File.dirname(__FILE__)}/../lib"
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 1e5cd25527..30cbba26b0 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'builder'
class HashExtTest < Test::Unit::TestCase
def setup
diff --git a/railties/lib/console_with_helpers.rb b/railties/lib/console_with_helpers.rb
index f9e8bf9cbf..039db667c4 100644
--- a/railties/lib/console_with_helpers.rb
+++ b/railties/lib/console_with_helpers.rb
@@ -1,24 +1,5 @@
-class Module
- def include_all_modules_from(parent_module)
- parent_module.constants.each do |const|
- mod = parent_module.const_get(const)
- if mod.class == Module
- send(:include, mod)
- include_all_modules_from(mod)
- end
- end
- end
-end
-
-def helper(*helper_names)
- returning @helper_proxy ||= Object.new do |helper|
- helper_names.each { |h| helper.extend "#{h}_helper".classify.constantize }
- end
-end
-
-class << helper
- include_all_modules_from ActionView
+def helper
+ @helper ||= ApplicationController.helpers
end
@controller = ApplicationController.new
-helper :application rescue nil
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb
index e1ce32da65..516ab8523e 100644
--- a/railties/test/abstract_unit.rb
+++ b/railties/test/abstract_unit.rb
@@ -3,18 +3,15 @@ $:.unshift File.dirname(__FILE__) + "/../../actionpack/lib"
$:.unshift File.dirname(__FILE__) + "/../lib"
$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
+require 'rubygems'
require 'test/unit'
+gem 'mocha', '>= 0.9.3'
+require 'mocha'
require 'stringio'
require 'active_support'
-# Wrap tests that use Mocha and skip if unavailable.
def uses_mocha(test_name)
- require 'rubygems'
- gem 'mocha', '>= 0.5.5'
- require 'mocha'
yield
-rescue LoadError
- $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
end
if defined?(RAILS_ROOT)