aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDmitriy Kiriyenko <dmitriy.kiriyenko@anahoret.com>2013-11-26 17:03:25 +0200
committerDmitriy Kiriyenko <dmitriy.kiryienko@gmail.com>2013-11-30 15:12:12 +0200
commit8033d3370c56d8d69673c000182922228504706c (patch)
tree1121aab1b2c1292a44f1b64c5e899fc760eab466 /activesupport/test
parent61ad8d5c32422c523293428d25277be1759b597c (diff)
downloadrails-8033d3370c56d8d69673c000182922228504706c.tar.gz
rails-8033d3370c56d8d69673c000182922228504706c.tar.bz2
rails-8033d3370c56d8d69673c000182922228504706c.zip
Fix segmentation fault in Ruby 2.0.0-p353.
In Ruby 2.0.0-p353 there was a [commit](https://github.com/ruby/ruby/commit/66915c507777c5e3a978fa73de25db763efd9206) that switched case matching from actual sending `===` method to magic lookup, that does not see it in `method_missing`. It's hard to predict how exactly and when exactly this bug will be solved so here I suggest a solution of defining it in Duration directly. In Ruby 2.0.0-p353 without the added fix added test crashes to segmentation fault.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/duration_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index 47257debe4..8eae8c832c 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -158,6 +158,11 @@ class DurationTest < ActiveSupport::TestCase
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