Permalink
Browse files

Merge pull request #13055 from dmitriy-kiriyenko/fix-segmentation-fau…

…lt-it-ruby-2.0.0-p353

Fix segmentation fault in Ruby 2.0.0-p353.
  • Loading branch information...
rafaelfranca committed Nov 30, 2013
2 parents a2dad13 + 8033d33 commit cd4d9316591ab61e478f98e1697599cdffc11d8c
Showing with 13 additions and 0 deletions.
  1. +8 −0 activesupport/lib/active_support/duration.rb
  2. +5 −0 activesupport/test/core_ext/duration_test.rb
@@ -99,6 +99,14 @@ def sum(sign, time = ::Time.current) #:nodoc:
private
+ # We define it as a workaround to Ruby 2.0.0-p353 bug.
+ # For more information, check rails/rails#13055.
+ # It should be dropped once a new Ruby patch-level
+ # release after 2.0.0-p353 happens.
+ def ===(other) #:nodoc:
+ value === other
+ end
+
def method_missing(method, *args, &block) #:nodoc:
value.send(method, *args, &block)
end
@@ -158,6 +158,11 @@ def test_to_json
assert_equal '172800', 2.days.to_json
end
+ def test_case_when
+ cased = case 1.day when 1.day then "ok" end
+ assert_equal cased, "ok"
+ end
+
protected
def with_env_tz(new_tz = 'US/Eastern')
old_tz, ENV['TZ'] = ENV['TZ'], new_tz

0 comments on commit cd4d931

Please sign in to comment.