aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md13
-rw-r--r--activesupport/lib/active_support/backtrace_cleaner.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/securerandom.rb8
-rw-r--r--activesupport/lib/active_support/dependencies.rb4
-rw-r--r--activesupport/lib/active_support/inflector/inflections.rb2
-rw-r--r--activesupport/lib/active_support/testing/isolation.rb22
-rw-r--r--activesupport/test/dependencies_test.rb6
-rw-r--r--activesupport/test/inflector_test.rb8
8 files changed, 44 insertions, 21 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index d0a5ddcc1e..f8e8544e72 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,8 +1,13 @@
+* Make the `apply_inflections` method case-insensitive when checking
+ whether a word is uncountable or not.
+
+ *Robin Dupret*
+
* Make Dependencies pass a name to NameError error.
*arthurnn*
* Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
- *Adam Panzer / Michael Grosser*
+ *Adam Panzer / Michael Grosser*
* Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
when working with objects with a nanosecond component.
@@ -27,12 +32,12 @@
* Fixed precision error in NumberHelper when using Rationals.
Before:
-
+
ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
#=> "330.00"
-
+
After:
-
+
ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
#=> "333.33"
diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb
index 1fec1bea0d..d06f22ad5c 100644
--- a/activesupport/lib/active_support/backtrace_cleaner.rb
+++ b/activesupport/lib/active_support/backtrace_cleaner.rb
@@ -13,7 +13,7 @@ module ActiveSupport
# can focus on the rest.
#
# bc = BacktraceCleaner.new
- # bc.add_filter { |line| line.gsub(Rails.root, '') } # strip the Rails.root prefix
+ # bc.add_filter { |line| line.gsub(Rails.root.to_s, '') } # strip the Rails.root prefix
# bc.add_silencer { |line| line =~ /mongrel|rubygems/ } # skip any lines from mongrel or rubygems
# bc.clean(exception.backtrace) # perform the cleanup
#
diff --git a/activesupport/lib/active_support/core_ext/securerandom.rb b/activesupport/lib/active_support/core_ext/securerandom.rb
index fec8f7c0ec..ff1eb52843 100644
--- a/activesupport/lib/active_support/core_ext/securerandom.rb
+++ b/activesupport/lib/active_support/core_ext/securerandom.rb
@@ -1,4 +1,4 @@
-module SecureRandom
+module SecureRandom #:nodoc:
UUID_DNS_NAMESPACE = "k\xA7\xB8\x10\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc:
UUID_URL_NAMESPACE = "k\xA7\xB8\x11\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc:
UUID_OID_NAMESPACE = "k\xA7\xB8\x12\x9D\xAD\x11\xD1\x80\xB4\x00\xC0O\xD40\xC8" #:nodoc:
@@ -10,7 +10,7 @@ module SecureRandom
# ::uuid_from_hash always generates the same UUID for a given name and namespace combination.
#
# See RFC 4122 for details of UUID at: http://www.ietf.org/rfc/rfc4122.txt
- def self.uuid_from_hash(hash_class, uuid_namespace, name)
+ def self.uuid_from_hash(hash_class, uuid_namespace, name) #:nodoc:
if hash_class == Digest::MD5
version = 3
elsif hash_class == Digest::SHA1
@@ -31,12 +31,12 @@ module SecureRandom
end
# Convenience method for ::uuid_from_hash using Digest::MD5.
- def self.uuid_v3(uuid_namespace, name)
+ def self.uuid_v3(uuid_namespace, name) #:nodoc:
self.uuid_from_hash(Digest::MD5, uuid_namespace, name)
end
# Convenience method for ::uuid_from_hash using Digest::SHA1.
- def self.uuid_v5(uuid_namespace, name)
+ def self.uuid_v5(uuid_namespace, name) #:nodoc:
self.uuid_from_hash(Digest::SHA1, uuid_namespace, name)
end
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index a8d12366cc..93a11d4586 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -187,7 +187,7 @@ module ActiveSupport #:nodoc:
# top-level constant.
def guess_for_anonymous(const_name)
if Object.const_defined?(const_name)
- raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name.to_s
+ raise NameError.new "#{const_name} cannot be autoloaded from an anonymous class or module", const_name
else
Object
end
@@ -516,7 +516,7 @@ module ActiveSupport #:nodoc:
end
end
- name_error = NameError.new("uninitialized constant #{qualified_name}", qualified_name)
+ name_error = NameError.new("uninitialized constant #{qualified_name}", const_name)
name_error.set_backtrace(caller.reject {|l| l.starts_with? __FILE__ })
raise name_error
end
diff --git a/activesupport/lib/active_support/inflector/inflections.rb b/activesupport/lib/active_support/inflector/inflections.rb
index eda0edff28..97401ccec7 100644
--- a/activesupport/lib/active_support/inflector/inflections.rb
+++ b/activesupport/lib/active_support/inflector/inflections.rb
@@ -160,7 +160,7 @@ module ActiveSupport
# uncountable 'money', 'information'
# uncountable %w( money information rice )
def uncountable(*words)
- (@uncountables << words).flatten!
+ @uncountables += words.flatten.map(&:downcase)
end
# Specifies a humanized form of a string by a regular expression rule or
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb
index 908af176be..68bda35980 100644
--- a/activesupport/lib/active_support/testing/isolation.rb
+++ b/activesupport/lib/active_support/testing/isolation.rb
@@ -70,14 +70,24 @@ module ActiveSupport
exit!
else
Tempfile.open("isolation") do |tmpfile|
- ENV["ISOLATION_TEST"] = self.class.name
- ENV["ISOLATION_OUTPUT"] = tmpfile.path
+ env = {
+ ISOLATION_TEST: self.class.name,
+ ISOLATION_OUTPUT: tmpfile.path
+ }
load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
- `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")}`
-
- ENV.delete("ISOLATION_TEST")
- ENV.delete("ISOLATION_OUTPUT")
+ orig_args = ORIG_ARGV.join(" ")
+ test_opts = "-n#{self.class.name}##{self.name}"
+ command = "#{Gem.ruby} #{load_paths} #{$0} #{orig_args} #{test_opts}"
+
+ # IO.popen lets us pass env in a cross-platform way
+ child = IO.popen([env, command])
+
+ begin
+ Process.wait(child.pid)
+ rescue Errno::ECHILD # The child process may exit before we wait
+ nil
+ end
return tmpfile.read.unpack("m")[0]
end
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index ef0955e1a8..a013aadd67 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -367,11 +367,11 @@ class DependenciesTest < ActiveSupport::TestCase
with_autoloading_fixtures do
e = assert_raise(NameError) { A::DoesNotExist.nil? }
assert_equal "uninitialized constant A::DoesNotExist", e.message
- assert_equal "A::DoesNotExist", e.name
+ assert_equal :DoesNotExist, e.name
e = assert_raise(NameError) { A::B::DoesNotExist.nil? }
assert_equal "uninitialized constant A::B::DoesNotExist", e.message
- assert_equal "A::B::DoesNotExist", e.name
+ assert_equal :DoesNotExist, e.name
end
end
@@ -539,7 +539,7 @@ class DependenciesTest < ActiveSupport::TestCase
mod = Module.new
e = assert_raise(NameError) { mod::E }
assert_equal 'E cannot be autoloaded from an anonymous class or module', e.message
- assert_equal 'E', e.name
+ assert_equal :E, e.name
end
end
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index eb8b0d878e..58fdea0972 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -509,6 +509,14 @@ class InflectorTest < ActiveSupport::TestCase
end
end
+ def test_inflections_with_uncountable_words
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.uncountable "HTTP"
+ end
+
+ assert_equal "HTTP", ActiveSupport::Inflector.pluralize("HTTP")
+ end
+
# Dups the singleton and yields, restoring the original inflections later.
# Use this in tests what modify the state of the singleton.
#