[ARVADOS] created: c7df9c8c14d78ba99d30eb90f1d49ebc04735224

Git user git at public.curoverse.com
Fri Feb 24 04:19:15 EST 2017


        at  c7df9c8c14d78ba99d30eb90f1d49ebc04735224 (commit)


commit c7df9c8c14d78ba99d30eb90f1d49ebc04735224
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Feb 24 04:17:06 2017 -0500

    6347: Use RFC3339Nano to render timestamps loaded from serialized fields.
    
    Psych (YAML) serializes timestamps as ISO8601-with-space-separators,
    and safe_load deserializes them to Time even with
    whitelist_classes=[].
    
    Psych.dump(Time.now.utc)
    => "--- 2017-02-22 21:33:22.845133778 Z\n...\n"
    
    Psych.safe_load('2017-02-22 21:33:22.845133778 Z').class
    => Time
    
    Psych.safe_load('2017-02-31 21:33:22.845133778 Z').class
    => String
    
    Before:
    
    Psych.safe_load('2017-02-22 21:33:22.845133778 Z').as_json
    => "2017-02-22T21:33:22Z"
    
    After:
    
    Psych.safe_load('2017-02-22 21:33:22.845133778 Z').as_json
    => "2017-02-22T21:33:22.845133778Z"

diff --git a/services/api/config/initializers/time_format.rb b/services/api/config/initializers/time_format.rb
index d476781..ee7c91f 100644
--- a/services/api/config/initializers/time_format.rb
+++ b/services/api/config/initializers/time_format.rb
@@ -3,3 +3,9 @@ class ActiveSupport::TimeWithZone
     strftime "%Y-%m-%dT%H:%M:%S.%NZ"
   end
 end
+
+class Time
+  def as_json *args
+    strftime "%Y-%m-%dT%H:%M:%S.%NZ"
+  end
+end
diff --git a/services/api/test/unit/log_test.rb b/services/api/test/unit/log_test.rb
index 92976e0..9158889 100644
--- a/services/api/test/unit/log_test.rb
+++ b/services/api/test/unit/log_test.rb
@@ -51,6 +51,11 @@ class LogTest < ActiveSupport::TestCase
                       'old_etag', 'old_attributes')
     assert_properties(new_props_test, event_type, props,
                       'new_etag', 'new_attributes')
+    ['old_attributes', 'new_attributes'].each do |logattr|
+      next if !props[logattr]
+      t = props[logattr]['created_at']
+      assert_match /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{9}Z/, t
+    end
     yield props if block_given?
   end
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list