From 9ee600fe0c4730bba346c41547521bc937373edb Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 15 Mar 2010 15:38:28 -0700 Subject: Allow memcache-client 1.8.0 --- activesupport/activesupport.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 78fb48924e..7486a9a659 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -21,5 +21,5 @@ Gem::Specification.new do |s| s.add_dependency('i18n', '~> 0.3.6.pre') s.add_dependency('tzinfo', '~> 0.3.16') s.add_dependency('builder', '~> 2.1.2') - s.add_dependency('memcache-client', '~> 1.7.5') + s.add_dependency('memcache-client', '>= 1.7.5') end -- cgit v1.2.3 From 67d8b9743add53f908ca417c641c4a54dd326c7d Mon Sep 17 00:00:00 2001 From: James Golick Date: Tue, 16 Mar 2010 09:49:25 -0700 Subject: Improve performance of multibyte utils. Switch from using String#match to using String#=~. There's no need to generate a MatchData for each iteration since we're not using it. Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/multibyte/utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/multibyte/utils.rb b/activesupport/lib/active_support/multibyte/utils.rb index b243df46d8..94b393cee2 100644 --- a/activesupport/lib/active_support/multibyte/utils.rb +++ b/activesupport/lib/active_support/multibyte/utils.rb @@ -27,7 +27,7 @@ module ActiveSupport #:nodoc: def self.verify(string) if expression = valid_character # Splits the string on character boundaries, which are determined based on $KCODE. - string.split(//).all? { |c| expression.match(c) } + string.split(//).all? { |c| expression =~ c } else true end -- cgit v1.2.3 From cd9ffd11e13ef6e62eba2cbd5c3760ff04132820 Mon Sep 17 00:00:00 2001 From: wycats Date: Tue, 16 Mar 2010 23:24:00 -0700 Subject: Eliminate warnings for AM on 1.8 --- activesupport/lib/active_support/core_ext/module.rb | 3 ++- activesupport/lib/active_support/core_ext/module/delegation.rb | 6 +++++- activesupport/lib/active_support/core_ext/module/remove_method.rb | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 activesupport/lib/active_support/core_ext/module/remove_method.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/module.rb b/activesupport/lib/active_support/core_ext/module.rb index bf272e9e73..e74bbde344 100644 --- a/activesupport/lib/active_support/core_ext/module.rb +++ b/activesupport/lib/active_support/core_ext/module.rb @@ -7,4 +7,5 @@ require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/attr_accessor_with_default' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/synchronization' -require 'active_support/core_ext/module/deprecation' \ No newline at end of file +require 'active_support/core_ext/module/deprecation' +require 'active_support/core_ext/module/remove_method' \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index df8aefea5a..d78cecc390 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -34,7 +34,7 @@ class Module # class Foo # CONSTANT_ARRAY = [0,1,2,3] # @@class_array = [4,5,6,7] - # + # # def initialize # @instance_array = [8,9,10,11] # end @@ -120,6 +120,10 @@ class Module end module_eval(<<-EOS, file, line) + if instance_methods(false).map(&:to_s).include?("#{prefix}#{method}") + remove_method("#{prefix}#{method}") + end + def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) #{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block) rescue NoMethodError # rescue NoMethodError diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb new file mode 100644 index 0000000000..2714a46b28 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb @@ -0,0 +1,6 @@ +class Module + def remove_possible_method(method) + remove_method(method) + rescue NameError + end +end \ No newline at end of file -- cgit v1.2.3 From a5587efc1903fd27d4b179753aa6e139445ad18c Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:15:55 -0700 Subject: Remove some 1.9 warnings (resulting in some fixed bugs). Remaining AM warnings are in dependencies. --- .../lib/active_support/core_ext/class/attribute.rb | 3 +++ activesupport/lib/active_support/core_ext/module.rb | 3 ++- .../lib/active_support/core_ext/module/method_names.rb | 14 ++++++++++++++ .../lib/active_support/core_ext/string/inflections.rb | 2 -- .../lib/active_support/core_ext/string/output_safety.rb | 6 ++++-- activesupport/lib/active_support/multibyte.rb | 4 ++-- activesupport/lib/active_support/ruby/shim.rb | 1 + activesupport/lib/active_support/test_case.rb | 2 +- activesupport/lib/active_support/testing/isolation.rb | 4 ++-- 9 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 activesupport/lib/active_support/core_ext/module/method_names.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index c18905b369..9631a7d242 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/object/singleton_class' require 'active_support/core_ext/module/delegation' +require 'active_support/core_ext/module/remove_method' class Class # Declare a class-level attribute whose value is inheritable and @@ -45,12 +46,14 @@ class Class s.send(:define_method, attr) { } s.send(:define_method, :"#{attr}?") { !!send(attr) } s.send(:define_method, :"#{attr}=") do |value| + singleton_class.remove_possible_method(attr) singleton_class.send(:define_method, attr) { value } end define_method(attr) { self.class.send(attr) } define_method(:"#{attr}?") { !!send(attr) } define_method(:"#{attr}=") do |value| + singleton_class.remove_possible_method(attr) singleton_class.send(:define_method, attr) { value } end if instance_writer end diff --git a/activesupport/lib/active_support/core_ext/module.rb b/activesupport/lib/active_support/core_ext/module.rb index e74bbde344..f59fcd123c 100644 --- a/activesupport/lib/active_support/core_ext/module.rb +++ b/activesupport/lib/active_support/core_ext/module.rb @@ -8,4 +8,5 @@ require 'active_support/core_ext/module/attr_accessor_with_default' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/synchronization' require 'active_support/core_ext/module/deprecation' -require 'active_support/core_ext/module/remove_method' \ No newline at end of file +require 'active_support/core_ext/module/remove_method' +require 'active_support/core_ext/module/method_names' \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/module/method_names.rb b/activesupport/lib/active_support/core_ext/module/method_names.rb new file mode 100644 index 0000000000..2eb40a83ab --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/method_names.rb @@ -0,0 +1,14 @@ +class Module + if instance_methods[0].is_a?(Symbol) + def instance_method_names(*args) + instance_methods(*args).map(&:to_s) + end + + def method_names(*args) + methods(*args).map(&:to_s) + end + else + alias_method :instance_method_names, :instance_methods + alias_method :method_names, :methods + end +end \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index fbb7b79fc6..48b028bb64 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -1,5 +1,3 @@ -require 'active_support/inflector' - # String inflections define new methods on the String class to transform names for different purposes. # For instance, you can figure out the name of a database from the name of a class. # diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 9a7c520e75..5babc297c1 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -23,12 +23,14 @@ class ERB end end - undef :h + remove_method(:h) alias h html_escape - module_function :html_escape module_function :h + singleton_class.send(:remove_method, :html_escape) + module_function :html_escape + # A utility method for escaping HTML entities in JSON strings. # This method is also aliased as j. # diff --git a/activesupport/lib/active_support/multibyte.rb b/activesupport/lib/active_support/multibyte.rb index 7e6f7d754b..428c48a484 100644 --- a/activesupport/lib/active_support/multibyte.rb +++ b/activesupport/lib/active_support/multibyte.rb @@ -53,8 +53,8 @@ module ActiveSupport #:nodoc: \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf])\z /xn, # Quick check for valid Shift-JIS characters, disregards the odd-even pairing 'Shift_JIS' => /\A(?: - [\x00-\x7e \xa1-\xdf] | - [\x81-\x9f \xe0-\xef] [\x40-\x7e \x80-\x9e \x9f-\xfc])\z /xn + [\x00-\x7e\xa1-\xdf] | + [\x81-\x9f\xe0-\xef] [\x40-\x7e\x80-\x9e\x9f-\xfc])\z /xn } end end diff --git a/activesupport/lib/active_support/ruby/shim.rb b/activesupport/lib/active_support/ruby/shim.rb index f0db5b3021..4a9ac920e8 100644 --- a/activesupport/lib/active_support/ruby/shim.rb +++ b/activesupport/lib/active_support/ruby/shim.rb @@ -18,3 +18,4 @@ require 'active_support/core_ext/string/interpolation' require 'active_support/core_ext/rexml' require 'active_support/core_ext/time/conversions' require 'active_support/core_ext/file/path' +require 'active_support/core_ext/module/method_names' \ No newline at end of file diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index ab30984d62..bfe2bc41d0 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -7,7 +7,7 @@ require 'active_support/testing/pending' require 'active_support/testing/isolation' begin - require 'mocha' + silence_warnings { require 'mocha' } rescue LoadError # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh. Object.const_set :Mocha, Module.new diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb index 453f4fcc0f..9507dbf473 100644 --- a/activesupport/lib/active_support/testing/isolation.rb +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -78,8 +78,8 @@ module ActiveSupport @@ran_class_setup = true end - serialized = run_in_isolation do |runner| - super(runner) + serialized = run_in_isolation do |isolated_runner| + super(isolated_runner) end retval, proxy = Marshal.load(serialized) -- cgit v1.2.3 From 640ee5b68d1078fc164bd4e10c019f284ad9b760 Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:53:48 -0700 Subject: Fix some more warnings on 1.9 --- .../active_support/core_ext/class/delegating_attributes.rb | 2 ++ activesupport/test/abstract_unit.rb | 11 +++++++++-- activesupport/test/core_ext/string_ext_test.rb | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb index b5785bdcd3..df4954e67a 100644 --- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb @@ -27,7 +27,9 @@ private # inheritance behavior, without having to store the object in an instance # variable and look up the superclass chain manually. def _stash_object_in_method(object, method, instance_reader = true) + singleton_class.send(:remove_possible_method, method) singleton_class.send(:define_method, method) { object } + remove_possible_method(method) define_method(method) { object } if instance_reader end diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index da338a2a26..67f652325e 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,10 +1,17 @@ -require File.expand_path('../../../load_paths', __FILE__) +begin + old, $VERBOSE = $VERBOSE, nil + require File.expand_path('../../../load_paths', __FILE__) +ensure + $VERBOSE = old +end lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'test/unit' -require 'mocha' +require 'active_support/core_ext/kernel/reporting' + +silence_warnings { require 'mocha' } ENV['NO_RELOAD'] = '1' require 'active_support' diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index a50e259726..234e41c772 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -285,7 +285,7 @@ class TestGetTextString < Test::Unit::TestCase def test_percent assert_equal("% 1", "%% %d" % {:num => 1.0}) - assert_equal("%{num} %d", "%%{num} %%d" % {:num => 1}) + assert_equal("%{num} %d 1", "%%{num} %%d %d" % {:num => 1}) end def test_sprintf_percent_in_replacement -- cgit v1.2.3 From 7a83abe52fd982c2b34e8026f3ae34664ad60bc6 Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:54:42 -0700 Subject: Any reason we can't just use the slow 1.8 path for transliteration in 1.9? --- .../lib/active_support/inflector/transliterate.rb | 4 ++-- activesupport/test/inflector_test_cases.rb | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb index 236f2eb628..2ce27cf406 100644 --- a/activesupport/lib/active_support/inflector/transliterate.rb +++ b/activesupport/lib/active_support/inflector/transliterate.rb @@ -14,8 +14,8 @@ module ActiveSupport if RUBY_VERSION >= '1.9' undef_method :transliterate def transliterate(string) - warn "Ruby 1.9 doesn't support Unicode normalization yet" - string.dup + proxy = ActiveSupport::Multibyte.proxy_class.new(string) + proxy.normalize(:kd).gsub(/[^\x00-\x7F]+/, '') end # The iconv transliteration code doesn't function correctly diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index ebd26d3fc6..56372903f3 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -180,18 +180,10 @@ module InflectorTestCases "Test with + sign" => "test_with_sign" } - # Ruby 1.9 doesn't do Unicode normalization yet. - if RUBY_VERSION >= '1.9' - StringToParameterizedAndNormalized = { - "Malmö" => "malm", - "Garçons" => "gar-ons" - } - else - StringToParameterizedAndNormalized = { - "Malmö" => "malmo", - "Garçons" => "garcons" - } - end + StringToParameterizedAndNormalized = { + "Malmö" => "malmo", + "Garçons" => "garcons" + } UnderscoreToHuman = { "employee_salary" => "Employee salary", -- cgit v1.2.3 From 843255a763c5e68beaa3a1b0bca306c625c30797 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 17 Mar 2010 10:04:49 -0700 Subject: fixing activerecord tests [#4205 state:resolved] Signed-off-by: Jeremy Kemper --- .../lib/active_support/core_ext/class/delegating_attributes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb index df4954e67a..9b2dc21d87 100644 --- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb @@ -27,7 +27,7 @@ private # inheritance behavior, without having to store the object in an instance # variable and look up the superclass chain manually. def _stash_object_in_method(object, method, instance_reader = true) - singleton_class.send(:remove_possible_method, method) + singleton_class.remove_possible_method(method) singleton_class.send(:define_method, method) { object } remove_possible_method(method) define_method(method) { object } if instance_reader @@ -37,7 +37,7 @@ private singleton_class.send(:define_method, "#{name}=") do |value| _stash_object_in_method(value, name, options[:instance_reader] != false) end - self.send("#{name}=", nil) + send("#{name}=", nil) end end -- cgit v1.2.3 From 067b350301279f608a369a39aff9b6f5a22357aa Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 17 Mar 2010 10:11:38 -0700 Subject: Move require closer to home --- activesupport/lib/active_support/core_ext/class/delegating_attributes.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb index 9b2dc21d87..12caa76c98 100644 --- a/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb @@ -1,6 +1,7 @@ require 'active_support/core_ext/object/blank' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/object/singleton_class' +require 'active_support/core_ext/module/remove_method' class Class def superclass_delegating_accessor(name, options = {}) -- cgit v1.2.3 From db2d96a6ba9c8d6d07121853955abe46af350f87 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 17 Mar 2010 13:44:24 -0700 Subject: fixing activemodel tests. [#4210 state:resolved] Signed-off-by: wycats --- activesupport/lib/active_support/test_case.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index bfe2bc41d0..ed8c02ba3e 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -5,6 +5,7 @@ require 'active_support/testing/deprecation' require 'active_support/testing/declarative' require 'active_support/testing/pending' require 'active_support/testing/isolation' +require 'active_support/core_ext/kernel/reporting' begin silence_warnings { require 'mocha' } -- cgit v1.2.3 From 644219a680c97cea206e2029dbbbb19d35fd8047 Mon Sep 17 00:00:00 2001 From: snusnu Date: Wed, 17 Mar 2010 19:10:20 +0100 Subject: Require AS singleton_class code in AS output_safety Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 5babc297c1..3ee5bcaab4 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -1,4 +1,5 @@ -require "erb" +require 'erb' +require 'active_support/core_ext/object/singleton_class' class ERB module Util -- cgit v1.2.3 From a6dc227167a8a720bd18495268305b15aa08d8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Mar 2010 23:44:03 +0100 Subject: Mark bang instrumentations as something that you shuold not be listening to. --- activesupport/lib/active_support/notifications/fanout.rb | 2 +- activesupport/test/notifications_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index cd60054862..a3ddc7705a 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -44,7 +44,7 @@ module ActiveSupport when Regexp, NilClass pattern else - /^#{Regexp.escape(pattern.to_s)}/ + /^#{Regexp.escape(pattern.to_s)}$/ end end diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 67c3527e23..92fbe5b92f 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -65,7 +65,7 @@ module Notifications assert_equal [[:foo]] * 4, @events end - def test_log_subscriber_with_pattern + def test_log_subscriber_with_string events = [] @notifier.subscribe('1') { |*args| events << args } @@ -74,10 +74,10 @@ module Notifications @notifier.publish 'a.1' @notifier.wait - assert_equal [['1'], ['1.a']], events + assert_equal [['1']], events end - def test_log_subscriber_with_pattern_as_regexp + def test_log_subscriber_with_pattern events = [] @notifier.subscribe(/\d/) { |*args| events << args } -- cgit v1.2.3 From d164d868b3617b9e496cb76576c0ee0f20f7bdf5 Mon Sep 17 00:00:00 2001 From: snusnu Date: Thu, 18 Mar 2010 18:40:22 +0100 Subject: AS datetime conversions now require AS time conversions --- activesupport/lib/active_support/core_ext/date_time/conversions.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index 47a31839a6..a9f821b01e 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -1,4 +1,5 @@ require 'active_support/inflector' +require 'active_support/core_ext/time/conversions' class DateTime # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows -- cgit v1.2.3 From 14b1dc209d4201021f1e40bca8a18efde3b97065 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Thu, 18 Mar 2010 13:25:12 -0300 Subject: Fixed require line Signed-off-by: wycats --- activesupport/test/ts_isolated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb index cbab61a523..fc1bbd6e3d 100644 --- a/activesupport/test/ts_isolated.rb +++ b/activesupport/test/ts_isolated.rb @@ -1,6 +1,6 @@ require 'test/unit' require 'rbconfig' -require 'active_support/core_ext/kernel/reporting' +require 'lib/active_support/core_ext/kernel/reporting' class TestIsolated < Test::Unit::TestCase ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) -- cgit v1.2.3 From 1e2caa5d52b9f367a1d7dc51d063a7ab1444b712 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino and Sebastian Martinez Date: Thu, 18 Mar 2010 18:59:13 -0300 Subject: Added missing requires abstract_unit and activesupport to the loadpath of ts_isolated [#4215 state:committed] Signed-off-by: wycats --- activesupport/test/callback_inheritance_test.rb | 1 + activesupport/test/callbacks_test.rb | 2 +- activesupport/test/flush_cache_on_private_memoization_test.rb | 1 + activesupport/test/ts_isolated.rb | 4 +++- 4 files changed, 6 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb index e74c64ba8d..8caf000c5d 100644 --- a/activesupport/test/callback_inheritance_test.rb +++ b/activesupport/test/callback_inheritance_test.rb @@ -1,3 +1,4 @@ +require 'abstract_unit' require 'test/unit' require 'active_support' diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 3fb940ad3c..49d9de63b0 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -1,4 +1,4 @@ -# require 'abstract_unit' +require 'abstract_unit' require 'test/unit' require 'active_support' diff --git a/activesupport/test/flush_cache_on_private_memoization_test.rb b/activesupport/test/flush_cache_on_private_memoization_test.rb index 1cd313ec81..91b856ed7c 100644 --- a/activesupport/test/flush_cache_on_private_memoization_test.rb +++ b/activesupport/test/flush_cache_on_private_memoization_test.rb @@ -1,3 +1,4 @@ +require 'abstract_unit' require 'active_support' require 'test/unit' diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb index fc1bbd6e3d..58710e0165 100644 --- a/activesupport/test/ts_isolated.rb +++ b/activesupport/test/ts_isolated.rb @@ -1,6 +1,8 @@ +$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') + require 'test/unit' require 'rbconfig' -require 'lib/active_support/core_ext/kernel/reporting' +require 'active_support/core_ext/kernel/reporting' class TestIsolated < Test::Unit::TestCase ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) -- cgit v1.2.3 From e7276a9f099b0229ac76422f8341d5d91dad8872 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino and Sebastian Martinez Date: Thu, 18 Mar 2010 18:59:50 -0300 Subject: Make dependencies_test pass running standalone [#4215 state:resolved] Signed-off-by: wycats --- activesupport/test/dependencies_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 6ff6dfb607..2cbf9e5042 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -88,7 +88,7 @@ class DependenciesTest < Test::Unit::TestCase old_warnings, ActiveSupport::Dependencies.warnings_on_first_load = ActiveSupport::Dependencies.warnings_on_first_load, true filename = "check_warnings" - expanded = File.expand_path("test/dependencies/#{filename}") + expanded = File.expand_path("#{File.dirname(__FILE__)}/dependencies/#{filename}") $check_warnings_load_count = 0 assert !ActiveSupport::Dependencies.loaded.include?(expanded) -- cgit v1.2.3 From fbe35656a95228f760a2cd09676423ba41fe70ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 19 Mar 2010 12:01:48 +0100 Subject: Singleton classes returns parent's methods with instance_methods(false) and this makes remove_method in Module#delegate fail. Add a test case and fix the bug. --- .../lib/active_support/core_ext/module/delegation.rb | 4 +++- activesupport/test/core_ext/module_test.rb | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index d78cecc390..db6aea9b87 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/module/remove_method" + class Module # Provides a delegate class method to easily expose contained objects' methods # as your own. Pass one or more methods (specified as symbols or strings) @@ -121,7 +123,7 @@ class Module module_eval(<<-EOS, file, line) if instance_methods(false).map(&:to_s).include?("#{prefix}#{method}") - remove_method("#{prefix}#{method}") + remove_possible_method("#{prefix}#{method}") end def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 9edd7cc7c0..1712b0649b 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -141,6 +141,20 @@ class ModuleTest < Test::Unit::TestCase assert_equal 0.0, nil_project.to_f end + def test_delegation_does_not_raise_error_when_removing_singleton_instance_methods + parent = Class.new do + def self.parent_method; end + end + + assert_nothing_raised do + child = Class.new(parent) do + class << self + delegate :parent_method, :to => :superclass + end + end + end + end + def test_parent assert_equal Yz::Zy, Yz::Zy::Cd.parent assert_equal Yz, Yz::Zy.parent -- cgit v1.2.3 From 16cad60fd3734740f30ddc770f60da8a5a8deb97 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 21 Mar 2010 21:09:48 -0300 Subject: avoid active_support/core_ext/time/conversions.rb warnings [#4250 state:committed] Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/core_ext/time/conversions.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb index 6d9c080442..86103ebce2 100644 --- a/activesupport/lib/active_support/core_ext/time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/time/conversions.rb @@ -1,4 +1,5 @@ require 'active_support/inflector' +require 'active_support/core_ext/time/publicize_conversion_methods' require 'active_support/values/time_zone' class Time -- cgit v1.2.3 From ab3503b496b2f489391c6cc76240d8516182a2c1 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Mon, 22 Mar 2010 09:54:06 -0700 Subject: Remove test ordering bug Don't reuse classes with class attributes when testing different use cases of class attributes. --- .../core_ext/class/delegating_attributes_test.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/core_ext/class/delegating_attributes_test.rb b/activesupport/test/core_ext/class/delegating_attributes_test.rb index 636edb8d4b..6d6cb61571 100644 --- a/activesupport/test/core_ext/class/delegating_attributes_test.rb +++ b/activesupport/test/core_ext/class/delegating_attributes_test.rb @@ -11,6 +11,13 @@ module DelegatingFixtures class Mokopuna < Child end + + class PercysMom + superclass_delegating_accessor :superpower + end + + class Percy < PercysMom + end end class DelegatingAttributesTest < Test::Unit::TestCase @@ -70,18 +77,17 @@ class DelegatingAttributesTest < Test::Unit::TestCase end def test_delegation_stops_at_the_right_level - assert_nil Mokopuna.some_attribute - assert_nil Child.some_attribute - Child.some_attribute="1" - assert_equal "1", Mokopuna.some_attribute - ensure - Child.some_attribute=nil + assert_nil Percy.superpower + assert_nil PercysMom.superpower + + PercysMom.superpower = :heatvision + assert_equal :heatvision, Percy.superpower end - + def test_delegation_stops_for_nil Mokopuna.some_attribute = nil Child.some_attribute="1" - + assert_equal "1", Child.some_attribute assert_nil Mokopuna.some_attribute ensure -- cgit v1.2.3 From b92963f9f8c8468134d4f726442bb5aae03ecfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 23 Mar 2010 23:53:38 +0100 Subject: Use latest I18n (0.3.6). --- activesupport/activesupport.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 7486a9a659..bfb1e83002 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.has_rdoc = true - s.add_dependency('i18n', '~> 0.3.6.pre') + s.add_dependency('i18n', '~> 0.3.6') s.add_dependency('tzinfo', '~> 0.3.16') s.add_dependency('builder', '~> 2.1.2') s.add_dependency('memcache-client', '>= 1.7.5') -- cgit v1.2.3 From c7cc9583689d63d342983d739ccf5c4e94233a48 Mon Sep 17 00:00:00 2001 From: Josh Franklin Date: Fri, 26 Mar 2010 12:43:59 +0100 Subject: Add support for a type=binary with an optional encoding=base64. If the encoding attribute is absent, the data is considered unencoded. [#2966 state:resolved] --- activesupport/lib/active_support/core_ext/hash/conversions.rb | 9 +++++++++ activesupport/test/core_ext/hash_ext_test.rb | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 48b185d05e..c882434f78 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -54,6 +54,15 @@ class Hash "string" => Proc.new { |string| string.to_s }, "yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml }, "base64Binary" => Proc.new { |bin| ActiveSupport::Base64.decode64(bin) }, + "binary" => Proc.new do |bin, entity| + case entity['encoding'] + when 'base64' + ActiveSupport::Base64.decode64(bin) + # TODO: Add support for other encodings + else + bin + end + end, "file" => Proc.new do |file, entity| f = StringIO.new(ActiveSupport::Base64.decode64(file)) f.extend(FileLike) diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 5b1d53ac7b..86272a28c1 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -757,6 +757,7 @@ class HashToXmlTest < Test::Unit::TestCase 2007-12-25T12:34:56+0000 YmFiZS5wbmc= + VGhhdCdsbCBkbywgcGlnLg== EOT @@ -766,7 +767,8 @@ class HashToXmlTest < Test::Unit::TestCase :price => BigDecimal("12.50"), :expires_at => Time.utc(2007,12,25,12,34,56), :notes => "", - :illustration => "babe.png" + :illustration => "babe.png", + :caption => "That'll do, pig." }.stringify_keys assert_equal expected_bacon_hash, Hash.from_xml(bacon_xml)["bacon"] -- cgit v1.2.3 From 5231e4e8c51333acd62d2e07a0f73cf0e0169fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 26 Mar 2010 13:24:02 +0100 Subject: Ensure to reference the proper TZInfo namespace [#4268 state:resolved]. --- activesupport/lib/active_support/values/time_zone.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 4db3dd1705..3cb4d89e02 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -305,8 +305,8 @@ module ActiveSupport # TODO: Preload instead of lazy load for thread safety def tzinfo - require 'tzinfo' unless defined?(TZInfo) - @tzinfo ||= TZInfo::Timezone.get(MAPPING[name]) + require 'tzinfo' unless defined?(::TZInfo) + @tzinfo ||= ::TZInfo::Timezone.get(MAPPING[name]) end unless const_defined?(:ZONES) -- cgit v1.2.3 From 395d6648ce7549f71dd0a76dc061e87f608aaaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 26 Mar 2010 18:47:55 +0100 Subject: Move application configuration to the application configuration object, remove railtie_name and engine_name and allow to set the configuration object. --- activesupport/lib/active_support/railtie.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index d2c13e030d..e45d16ee96 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -3,7 +3,7 @@ require "rails" module ActiveSupport class Railtie < Rails::Railtie - railtie_name :active_support + config.active_support = ActiveSupport::OrderedOptions.new # Loads support for "whiny nil" (noisy warnings when methods are invoked # on +nil+ values) if Configuration#whiny_nils is true. @@ -30,9 +30,7 @@ end module I18n class Railtie < Rails::Railtie - railtie_name :i18n - - # Initialize I18n load paths to an array + config.i18n = ActiveSupport::OrderedOptions.new config.i18n.railties_load_path = [] config.i18n.load_path = [] -- cgit v1.2.3