aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2008-03-23 04:44:50 +0000
committerRick Olson <technoweenie@gmail.com>2008-03-23 04:44:50 +0000
commite1790efb85010c5e6f39eef029abf7b71ae3b9a6 (patch)
treea9600d7e8f83bcab5cbcbda25074a12c2095594d /activesupport
parent038139870825ad843b0683e5273dc4d11cb684b3 (diff)
downloadrails-e1790efb85010c5e6f39eef029abf7b71ae3b9a6.tar.gz
rails-e1790efb85010c5e6f39eef029abf7b71ae3b9a6.tar.bz2
rails-e1790efb85010c5e6f39eef029abf7b71ae3b9a6.zip
Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9081 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb6
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index cb04c4d234..96c9011838 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]
+
* Ensure correct TimeWithZone#to_date [Geoff Buesing]
* Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing]
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 7b9b121a17..56c4f40f32 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -80,7 +80,11 @@ module ActiveSupport
end
def to_yaml(options = {})
- time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z'))
+ if options.kind_of?(YAML::Emitter)
+ utc.to_yaml(options)
+ else
+ time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z'))
+ end
end
def httpdate
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index fc4f61dd37..70b3d90bd6 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -106,6 +106,12 @@ uses_tzinfo 'TimeWithZoneTest' do
end
end
+ def test_ruby_to_yaml
+ silence_warnings do
+ assert_equal "--- \n:twz: 2000-01-01 00:00:00 Z\n", {:twz => @twz}.to_yaml
+ end
+ end
+
def test_httpdate
silence_warnings do # silence warnings raised by tzinfo gem
assert_equal 'Sat, 01 Jan 2000 00:00:00 GMT', @twz.httpdate