aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-04-30 10:10:42 -0300
committerEmilio Tagua <miloops@gmail.com>2009-04-30 10:10:42 -0300
commit0cf54f9dd8acfb9375f45d5725f94f97c8a3d4dc (patch)
treebe1fc8bffc7395be3243b44cf1756dda2a0a7fd7
parentb0bd4f45fa9180793e3c35590c8a887ddfe43553 (diff)
parent79420e71e0e75d6f81e5284184bac4e7d0b02c30 (diff)
downloadrails-0cf54f9dd8acfb9375f45d5725f94f97c8a3d4dc.tar.gz
rails-0cf54f9dd8acfb9375f45d5725f94f97c8a3d4dc.tar.bz2
rails-0cf54f9dd8acfb9375f45d5725f94f97c8a3d4dc.zip
Merge commit 'rails/master'
-rw-r--r--actionpack/lib/action_dispatch/test/mock.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/integer/even_odd.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/string/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb4
-rw-r--r--activesupport/test/core_ext/duration_test.rb20
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb8
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb2
7 files changed, 21 insertions, 20 deletions
diff --git a/actionpack/lib/action_dispatch/test/mock.rb b/actionpack/lib/action_dispatch/test/mock.rb
index 4042f9fbc8..68e5b108b4 100644
--- a/actionpack/lib/action_dispatch/test/mock.rb
+++ b/actionpack/lib/action_dispatch/test/mock.rb
@@ -42,6 +42,7 @@ module ActionDispatch
opts[:input] = params
end
else
+ params.stringify_keys!
params.update(::Rack::Utils.parse_query(uri.query))
uri.query = requestify(params)
end
diff --git a/activesupport/lib/active_support/core_ext/integer/even_odd.rb b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
index 6d005268a3..8f9a97b44c 100644
--- a/activesupport/lib/active_support/core_ext/integer/even_odd.rb
+++ b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
@@ -7,10 +7,10 @@ class Integer
# Is the integer a multiple of 2?
def even?
multiple_of? 2
- end if RUBY_VERSION < '1.9'
+ end unless method_defined?(:even?)
# Is the integer not a multiple of 2?
def odd?
!even?
- end if RUBY_VERSION < '1.9'
+ end unless method_defined?(:odd?)
end
diff --git a/activesupport/lib/active_support/core_ext/string/conversions.rb b/activesupport/lib/active_support/core_ext/string/conversions.rb
index 3f05db62c3..2b9f8c70f6 100644
--- a/activesupport/lib/active_support/core_ext/string/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/string/conversions.rb
@@ -5,7 +5,7 @@ class String
# 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility.
def ord
self[0]
- end if RUBY_VERSION < '1.9'
+ end unless method_defined?(:ord)
# Form can be either :utc (default) or :local.
def to_time(form = :utc)
diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb
index 18261e139f..94e01597a9 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -63,7 +63,7 @@ class Time
# your_time.to_date # => Tue, 13 Jan 2009
def to_date
::Date.new(year, month, day)
- end
+ end unless method_defined?(:to_date)
# A method to keep Time, Date and DateTime instances interchangeable on conversions.
# In this case, it simply returns +self+.
@@ -80,5 +80,5 @@ class Time
# your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
def to_datetime
::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
- end
+ end unless method_defined?(:to_datetime)
end
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index ea6979bc6b..30d4152729 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -42,23 +42,23 @@ class DurationTest < ActiveSupport::TestCase
end
def test_since_and_ago_with_fractional_days
- Time.stubs(:now).returns Time.local(2000)
+ t = Time.local(2000)
# since
- assert_equal 36.hours.since, 1.5.days.since
- assert_equal((24 * 1.7).hours.since, 1.7.days.since)
+ assert_equal 36.hours.since(t), 1.5.days.since(t)
+ assert_in_delta((24 * 1.7).hours.since(t), 1.7.days.since(t), 1)
# ago
- assert_equal 36.hours.ago, 1.5.days.ago
- assert_equal((24 * 1.7).hours.ago, 1.7.days.ago)
+ assert_equal 36.hours.ago(t), 1.5.days.ago(t)
+ assert_in_delta((24 * 1.7).hours.ago(t), 1.7.days.ago(t), 1)
end
def test_since_and_ago_with_fractional_weeks
- Time.stubs(:now).returns Time.local(2000)
+ t = Time.local(2000)
# since
- assert_equal((7 * 36).hours.since, 1.5.weeks.since)
- assert_equal((7 * 24 * 1.7).hours.since, 1.7.weeks.since)
+ assert_equal((7 * 36).hours.since(t), 1.5.weeks.since(t))
+ assert_in_delta((7 * 24 * 1.7).hours.since(t), 1.7.weeks.since(t), 1)
# ago
- assert_equal((7 * 36).hours.ago, 1.5.weeks.ago)
- assert_equal((7 * 24 * 1.7).hours.ago, 1.7.weeks.ago)
+ assert_equal((7 * 36).hours.ago(t), 1.5.weeks.ago(t))
+ assert_in_delta((7 * 24 * 1.7).hours.ago(t), 1.7.weeks.ago(t), 1)
end
def test_since_and_ago_anchored_to_time_now_when_time_zone_default_not_set
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 3bf7b789ce..e265423f06 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -424,10 +424,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal Time.local(2005,6,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:months => 4)
assert_equal Time.local(2005,3,21,15,15,10), Time.local(2005,2,28,15,15,10).advance(:weeks => 3)
assert_equal Time.local(2005,3,25,3,15,10), Time.local(2005,2,28,15,15,10).advance(:weeks => 3.5)
- assert_equal Time.local(2005,3,26,12,51,10), Time.local(2005,2,28,15,15,10).advance(:weeks => 3.7)
+ assert_in_delta Time.local(2005,3,26,12,51,10), Time.local(2005,2,28,15,15,10).advance(:weeks => 3.7), 1
assert_equal Time.local(2005,3,5,15,15,10), Time.local(2005,2,28,15,15,10).advance(:days => 5)
assert_equal Time.local(2005,3,6,3,15,10), Time.local(2005,2,28,15,15,10).advance(:days => 5.5)
- assert_equal Time.local(2005,3,6,8,3,10), Time.local(2005,2,28,15,15,10).advance(:days => 5.7)
+ assert_in_delta Time.local(2005,3,6,8,3,10), Time.local(2005,2,28,15,15,10).advance(:days => 5.7), 1
assert_equal Time.local(2012,9,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 7)
assert_equal Time.local(2013,10,3,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :days => 5)
assert_equal Time.local(2013,10,17,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
@@ -446,10 +446,10 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:months => 4)
assert_equal Time.utc(2005,3,21,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:weeks => 3)
assert_equal Time.utc(2005,3,25,3,15,10), Time.utc(2005,2,28,15,15,10).advance(:weeks => 3.5)
- assert_equal Time.utc(2005,3,26,12,51,10), Time.utc(2005,2,28,15,15,10).advance(:weeks => 3.7)
+ assert_in_delta Time.utc(2005,3,26,12,51,10), Time.utc(2005,2,28,15,15,10).advance(:weeks => 3.7), 1
assert_equal Time.utc(2005,3,5,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:days => 5)
assert_equal Time.utc(2005,3,6,3,15,10), Time.utc(2005,2,28,15,15,10).advance(:days => 5.5)
- assert_equal Time.utc(2005,3,6,8,3,10), Time.utc(2005,2,28,15,15,10).advance(:days => 5.7)
+ assert_in_delta Time.utc(2005,3,6,8,3,10), Time.utc(2005,2,28,15,15,10).advance(:days => 5.7), 1
assert_equal Time.utc(2012,9,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 7)
assert_equal Time.utc(2013,10,3,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 19, :days => 11)
assert_equal Time.utc(2013,10,17,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 0380c28c17..03ae70d420 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -92,7 +92,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
end
def test_xmlschema_with_fractional_seconds
- @twz += 0.123456 # advance the time by a fraction of a second
+ @twz += 0.1234560001 # advance the time by a fraction of a second
assert_equal "1999-12-31T19:00:00.123-05:00", @twz.xmlschema(3)
assert_equal "1999-12-31T19:00:00.123456-05:00", @twz.xmlschema(6)
assert_equal "1999-12-31T19:00:00.123456-05:00", @twz.xmlschema(12)