Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ruby 1.9 compat: add #raise to AS::BasicObject, fixup Duration argume…

…nt error. Closes #10594.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8523 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit ff47ba9adb39976723752abfd6fbb72d7a55eaf1 1 parent e21c48b
Jeremy Kemper jeremy authored
2  activesupport/CHANGELOG
View
@@ -6,7 +6,7 @@
* Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee]
-* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink]
+* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10594, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink, fxn]
* TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow]
5 activesupport/lib/active_support/basic_object.rb
View
@@ -6,6 +6,11 @@ module ActiveSupport
class BasicObject < ::BasicObject
undef_method :==
undef_method :equal?
+
+ # Let ActiveSupport::BasicObject at least raise exceptions.
+ def raise(*args)
+ ::Object.send(:raise, *args)
+ end
end
else
require 'blankslate'
2  activesupport/lib/active_support/duration.rb
View
@@ -82,7 +82,7 @@ def sum(sign, time = ::Time.now) #:nodoc:
t.advance(type => sign * number)
end
else
- raise ArgumentError, "expected a time or date, got #{time.inspect}"
+ raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
end
end
end
11 activesupport/test/core_ext/duration_test.rb
View
@@ -18,4 +18,15 @@ def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
def test_plus_with_time
assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration"
end
+
+ def test_argument_error
+ begin
+ 1.second.ago('')
+ flunk("no exception was raised")
+ rescue ArgumentError => e
+ assert_equal 'expected a time or date, got ""', e.message, "ensure ArgumentError is not being raised by dependencies.rb"
+ rescue Exception
+ flunk("ArgumentError should be raised, but we got #{$!.class} instead")
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.