diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-03 22:27:28 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-03 22:27:28 -0800 |
commit | 5e94d3e3ea06e577d97a32eb4b38b61c4ce8ff8f (patch) | |
tree | b89d06302223be67c595e65bffce54357d41a15a /activesupport | |
parent | d7d917335e242f48fae31bc99e6d4ab381244913 (diff) | |
parent | eca11bfdb5d3cf375faf8a24e2dc0cc5abd20f92 (diff) | |
download | rails-5e94d3e3ea06e577d97a32eb4b38b61c4ce8ff8f.tar.gz rails-5e94d3e3ea06e577d97a32eb4b38b61c4ce8ff8f.tar.bz2 rails-5e94d3e3ea06e577d97a32eb4b38b61c4ce8ff8f.zip |
Merge
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/multiple.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/integer_ext_test.rb | 5 | ||||
-rw-r--r-- | activesupport/test/isolation_test.rb | 6 |
4 files changed, 11 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index ad238c1d96..6360a4614e 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -247,13 +247,13 @@ module ActiveSupport expires_in || 0 end - def instrument(operation, key, options, &block) + def instrument(operation, key, options) log(operation, key, options) if self.class.instrument payload = { :key => key } payload.merge!(options) if options.is_a?(Hash) - ActiveSupport::Notifications.instrument(:"cache_#{operation}", payload, &block) + ActiveSupport::Notifications.instrument("active_support.cache_#{operation}", payload){ yield } else yield end diff --git a/activesupport/lib/active_support/core_ext/integer/multiple.rb b/activesupport/lib/active_support/core_ext/integer/multiple.rb index 40bea54c67..8dff217ddc 100644 --- a/activesupport/lib/active_support/core_ext/integer/multiple.rb +++ b/activesupport/lib/active_support/core_ext/integer/multiple.rb @@ -1,6 +1,6 @@ class Integer # Check whether the integer is evenly divisible by the argument. def multiple_of?(number) - self % number == 0 + number != 0 ? self % number == 0 : zero? end end diff --git a/activesupport/test/core_ext/integer_ext_test.rb b/activesupport/test/core_ext/integer_ext_test.rb index e1591089f5..fe8c7eb224 100644 --- a/activesupport/test/core_ext/integer_ext_test.rb +++ b/activesupport/test/core_ext/integer_ext_test.rb @@ -5,6 +5,11 @@ class IntegerExtTest < Test::Unit::TestCase def test_multiple_of [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) } [ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) } + + # test the 0 edge case + assert 0.multiple_of?(0) + assert !5.multiple_of?(0) + # test with a prime assert !22953686867719691230002707821868552601124472329079.multiple_of?(2) assert !22953686867719691230002707821868552601124472329079.multiple_of?(3) diff --git a/activesupport/test/isolation_test.rb b/activesupport/test/isolation_test.rb index 39c2166016..a7af5e96f6 100644 --- a/activesupport/test/isolation_test.rb +++ b/activesupport/test/isolation_test.rb @@ -1,10 +1,10 @@ require 'abstract_unit' require 'rbconfig' -# if defined?(MiniTest) || defined?(Test::Unit::TestResultFailureSupport) -# $stderr.puts "Isolation tests can test test-unit 1 only" +if defined?(MiniTest) || defined?(Test::Unit::TestResultFailureSupport) + $stderr.puts "Isolation tests can test test-unit 1 only" -if ENV['CHILD'] +elsif ENV['CHILD'] class ChildIsolationTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation |