diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-07 00:40:26 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-07 00:40:26 -0300 |
commit | 292f6c99229f34ab216ddc9103e219143e637d85 (patch) | |
tree | 24b4d8e07b9735aff8daf1e36029473ed880ce3a | |
parent | ba886f73a2b4a06f3400f0698290c54566639b6a (diff) | |
parent | bcbce4e9ffc2f5a2f86d3a977a0e07e2b2aab19e (diff) | |
download | rails-292f6c99229f34ab216ddc9103e219143e637d85.tar.gz rails-292f6c99229f34ab216ddc9103e219143e637d85.tar.bz2 rails-292f6c99229f34ab216ddc9103e219143e637d85.zip |
Merge pull request #18306 from tmm1/rm-3-2-with-ruby-2-1-plus
3-2-stable: ruby 2.2 compatibility
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/test_case.rb | 1 | ||||
-rw-r--r-- | actionpack/test/controller/localized_templates_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/dispatch/mime_type_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/template_test.rb | 3 | ||||
-rw-r--r-- | actionpack/test/template/test_case_test.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 8 | ||||
-rw-r--r-- | activesupport/activesupport.gemspec | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/big_decimal/conversions.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/attribute.rb | 8 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 8 | ||||
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 2 |
13 files changed, 39 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml index e130252522..8e7f7842e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 + - 2.1 + - 2.2 env: - "GEM=railties" - "GEM=ap,am,amo,ares,as" @@ -17,6 +17,8 @@ else gem 'journey' end +gem 'i18n', '~> 0.6.11' + # This needs to be with require false to avoid # it being automatically loaded by sprockets gem 'uglifier', '>= 1.0.3', :require => false diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 658a503f7f..ade0980e71 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -193,6 +193,7 @@ module ActionView @_result @_routes @controller + @internal_data @layouts @locals @method_name diff --git a/actionpack/test/controller/localized_templates_test.rb b/actionpack/test/controller/localized_templates_test.rb index a5fc3f614a..da0c21ed3f 100644 --- a/actionpack/test/controller/localized_templates_test.rb +++ b/actionpack/test/controller/localized_templates_test.rb @@ -8,6 +8,14 @@ end class LocalizedTemplatesTest < ActionController::TestCase tests LocalizedController + def setup + @i18n_locale = I18n.locale + end + + def teardown + I18n.locale = @i18n_locale + end + def test_localized_template_is_used I18n.locale = :de get :hello_world diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index a1a7ceff03..1869325d21 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -7,7 +7,7 @@ class MimeTypeTest < ActiveSupport::TestCase test "parse single" do Mime::LOOKUP.keys.each do |mime_type| unless mime_type == 'image/*' - assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type) + assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type.to_s) end end end diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index b7f785fe3a..f73024fc54 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -179,10 +179,11 @@ class TestERBTemplate < ActiveSupport::TestCase end def test_error_when_template_isnt_valid_utf8 - assert_raises(ActionView::Template::Error, /\xFC/) do + exception = assert_raise(ActionView::Template::Error) do @template = new_template("hello \xFCmlat", :virtual_path => nil) render end + assert_match(/\xFC/, exception.message) end def with_external_encoding(encoding) diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index 13a2b7fb6f..4f73a4cdba 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -311,9 +311,10 @@ module ActionView test "supports specifying locals (failing)" do controller.controller_path = "test" render(:template => "test/calling_partial_with_layout") - assert_raise ActiveSupport::TestCase::Assertion, /Somebody else.*David/m do + exception = assert_raise ActiveSupport::TestCase::Assertion do assert_template :partial => "_partial_for_use_in_layout", :locals => { :name => "Somebody Else" } end + assert_match(/Somebody Else.*David/m, exception.message) end end diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 290f81479d..4ea39681e2 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -50,15 +50,15 @@ module ActiveRecord [options[:limit], count].compact.min end - def has_cached_counter?(reflection = reflection) + def has_cached_counter?(reflection = self.reflection) owner.attribute_present?(cached_counter_attribute_name(reflection)) end - def cached_counter_attribute_name(reflection = reflection) + def cached_counter_attribute_name(reflection = self.reflection) "#{reflection.name}_count" end - def update_counter(difference, reflection = reflection) + def update_counter(difference, reflection = self.reflection) if has_cached_counter?(reflection) counter = cached_counter_attribute_name(reflection) owner.class.update_counters(owner.id, counter => difference) @@ -77,7 +77,7 @@ module ActiveRecord # it will be decremented twice. # # Hence this method. - def inverse_updates_counter_cache?(reflection = reflection) + def inverse_updates_counter_cache?(reflection = self.reflection) counter_name = cached_counter_attribute_name(reflection) reflection.klass.reflect_on_all_associations(:belongs_to).any? { |inverse_reflection| inverse_reflection.counter_cache_column == counter_name diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index e131ca7d68..f3c22871e5 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -22,4 +22,5 @@ Gem::Specification.new do |s| s.add_dependency('i18n', '~> 0.6', '>= 0.6.4') s.add_dependency('multi_json', '~> 1.0') + s.add_dependency('test-unit', '~> 3.0') end diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb index 391bdc925d..d2039fcc1e 100644 --- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb +++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb @@ -16,7 +16,9 @@ class BigDecimal # # Note that reconstituting YAML floats to native floats may lose precision. def to_yaml(opts = {}) - return super if defined?(YAML::ENGINE) && !YAML::ENGINE.syck? + return super if + (defined?(YAML::ENGINE) && !YAML::ENGINE.syck?) || + (defined?(Psych) && YAML == Psych) YAML.quick_emit(nil, opts) do |out| string = to_s diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index cd7877fce4..14adc426d8 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -109,7 +109,9 @@ class Class end private - def singleton_class? - ancestors.first != self - end + unless respond_to?(:singleton_class?) + def singleton_class? + ancestors.first != self + end + end end diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index 0481bd2195..0ff36eeb6d 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -138,6 +138,12 @@ class DateTime # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime def <=>(other) - super other.kind_of?(Infinity) ? other : other.to_datetime + if other.kind_of?(Infinity) + super + elsif other.respond_to? :to_datetime + super other.to_datetime + else + nil + end end end diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index f935180036..01aea0984b 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -267,7 +267,7 @@ module ActiveSupport # # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 - def parse(str, now=now) + def parse(str, now=self.now) parts = Date._parse(str, false) return if parts.empty? |