From 278186534c0ccf285a20497461f40d2e54aa20a0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 3 Feb 2009 18:25:37 -0800 Subject: Bump mocha requirement for Ruby 1.9 compat. Remove uses_mocha. --- activesupport/test/abstract_unit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index ac362d14c8..a0c0c59e47 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,6 +1,7 @@ require 'rubygems' require 'test/unit' -gem 'mocha', '>= 0.9.3' + +gem 'mocha', '>= 0.9.5' require 'mocha' $:.unshift "#{File.dirname(__FILE__)}/../lib" -- cgit v1.2.3 From bdaf3348de0ea99525c685f9acfd7abb523f59c5 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 3 Feb 2009 18:41:06 -0800 Subject: Ruby 1.9: force ascii encoding for comparison with utf8 regexp --- activesupport/lib/active_support/multibyte/chars.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index a00b165222..62b6d798ef 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -617,6 +617,8 @@ module ActiveSupport #:nodoc: # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. def tidy_bytes(string) string.split(//u).map do |c| + c.force_encoding(Encoding::ASCII) if c.respond_to?(:force_encoding) + if !UTF8_PAT.match(c) n = c.unpack('C')[0] n < 128 ? n.chr : -- cgit v1.2.3 From be1dbf321aba03c2e9bec423f753308e9bba3ef5 Mon Sep 17 00:00:00 2001 From: Thijs de Vries Date: Sat, 31 Jan 2009 18:31:59 -0500 Subject: created unit tests and fixed bug that failed tests Signed-off-by: David Heinemeier Hansson --- activesupport/lib/active_support/cache.rb | 2 +- activesupport/test/caching_test.rb | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 83174d3a85..0f848c5933 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -138,7 +138,7 @@ module ActiveSupport # cache.fetch("foo") # => nil def fetch(key, options = {}) @logger_off = true - if !options[:force] && value = read(key, options) + if !options[:force] && ((value = read(key, options)) || exist?(key, options)) @logger_off = false log("hit", key, options) value diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 4e212f1661..e5105e92a2 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -90,7 +90,27 @@ module CacheStoreBehavior @cache.write('foo', nil) assert_equal nil, @cache.read('foo') end - + + def test_should_read_and_write_false + @cache.write('foo', false) + assert_equal false, @cache.read('foo') + end + + def test_should_read_and_write_true + @cache.write('foo', true) + assert_equal true, @cache.read('foo') + end + + def test_fetch_false_without_cache_miss + @cache.write('foo', false) + assert_equal false, @cache.fetch('foo') { 'baz' } + end + + def test_fetch_nil_without_cache_miss + @cache.write('foo', nil) + assert_equal nil, @cache.fetch('foo') { 'baz' } + end + def test_fetch_without_cache_miss @cache.write('foo', 'bar') assert_equal 'bar', @cache.fetch('foo') { 'baz' } -- cgit v1.2.3 From 9b4aa9bcd9cb03f689eed374e870dd5a46e4a661 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 5 Feb 2009 21:00:44 +0100 Subject: Revert "created unit tests and fixed bug that failed tests" This reverts commit be1dbf321aba03c2e9bec423f753308e9bba3ef5. --- activesupport/lib/active_support/cache.rb | 2 +- activesupport/test/caching_test.rb | 22 +--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 0f848c5933..83174d3a85 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -138,7 +138,7 @@ module ActiveSupport # cache.fetch("foo") # => nil def fetch(key, options = {}) @logger_off = true - if !options[:force] && ((value = read(key, options)) || exist?(key, options)) + if !options[:force] && value = read(key, options) @logger_off = false log("hit", key, options) value diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index e5105e92a2..4e212f1661 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -90,27 +90,7 @@ module CacheStoreBehavior @cache.write('foo', nil) assert_equal nil, @cache.read('foo') end - - def test_should_read_and_write_false - @cache.write('foo', false) - assert_equal false, @cache.read('foo') - end - - def test_should_read_and_write_true - @cache.write('foo', true) - assert_equal true, @cache.read('foo') - end - - def test_fetch_false_without_cache_miss - @cache.write('foo', false) - assert_equal false, @cache.fetch('foo') { 'baz' } - end - - def test_fetch_nil_without_cache_miss - @cache.write('foo', nil) - assert_equal nil, @cache.fetch('foo') { 'baz' } - end - + def test_fetch_without_cache_miss @cache.write('foo', 'bar') assert_equal 'bar', @cache.fetch('foo') { 'baz' } -- cgit v1.2.3 From 4e4f961c112f1ffac73a1397d94dfbb4a10effae Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 6 Feb 2009 13:32:47 +1300 Subject: Handle every error that can come out of the Iconv branch by rescuing and returning nil [#1195 state:committed] --- activesupport/lib/active_support/inflector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 4921b99677..5ff6f50fb3 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -284,7 +284,7 @@ module ActiveSupport # The iconv transliteration code doesn't function correctly # on some platforms, but it's very fast where it does function. - elsif "foo" != Inflector.transliterate("föö") + elsif "foo" != (Inflector.transliterate("föö") rescue nil) undef_method :transliterate def transliterate(string) string.mb_chars.normalize(:kd). # Decompose accented characters -- cgit v1.2.3