aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
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