From 7a2554d9a35545ad24937f04c6416df3ed3f26d9 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 15 Nov 2009 01:22:26 +0100 Subject: Let Integer#multiple_of? accept zero as argument [#2982 state:committed] Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/core_ext/integer/multiple.rb | 2 +- activesupport/test/core_ext/integer_ext_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'activesupport') 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) -- cgit v1.2.3 From 7ad7c82caf53e0ef7f26221826ddc202a00f2631 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 2 Jan 2010 20:29:47 -0800 Subject: Skip isolation test tests until they work --- activesupport/test/isolation_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport') 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 -- cgit v1.2.3 From 6fbe9ef2ffb1858027130789246f3ae24a0a182f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 3 Jan 2010 20:39:42 +0100 Subject: Use namespaces in notifications. --- activesupport/lib/active_support/cache.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index ad238c1d96..25314ffd43 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("activesupport.cache_#{operation}", payload){ yield } else yield end -- cgit v1.2.3 From 3990310a2bedd0dff5753e3e9b1282e686cff0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 4 Jan 2010 00:03:56 +0100 Subject: Use underscore in notification namespaces. --- activesupport/lib/active_support/cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 25314ffd43..6360a4614e 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -253,7 +253,7 @@ module ActiveSupport if self.class.instrument payload = { :key => key } payload.merge!(options) if options.is_a?(Hash) - ActiveSupport::Notifications.instrument("activesupport.cache_#{operation}", payload){ yield } + ActiveSupport::Notifications.instrument("active_support.cache_#{operation}", payload){ yield } else yield end -- cgit v1.2.3