From 14329f8907edd9d47cf355c081f7fd80fa53c669 Mon Sep 17 00:00:00 2001 From: Spencer McElmurry Date: Wed, 11 Jul 2018 09:40:16 -0700 Subject: [PATCH] Change datetime to RFC3339 for start_time and end_time --- lib/vmpooler/api/v1.rb | 4 ++-- spec/integration/api/v1/vm_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vmpooler/api/v1.rb b/lib/vmpooler/api/v1.rb index e7f6729..9915a60 100644 --- a/lib/vmpooler/api/v1.rb +++ b/lib/vmpooler/api/v1.rb @@ -646,8 +646,8 @@ module Vmpooler elsif rdata['checkout'] result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2) result[params[:hostname]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2) - result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout']) - result[params[:hostname]]['end_time'] = Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 + result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout']).to_datetime.rfc3339 + result[params[:hostname]]['end_time'] = (Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60).to_datetime.rfc3339 result[params[:hostname]]['state'] = 'running' elsif rdata['check'] result[params[:hostname]]['state'] = 'ready' diff --git a/spec/integration/api/v1/vm_spec.rb b/spec/integration/api/v1/vm_spec.rb index 8134cba..5399370 100644 --- a/spec/integration/api/v1/vm_spec.rb +++ b/spec/integration/api/v1/vm_spec.rb @@ -50,8 +50,8 @@ describe Vmpooler::API::V1 do expect(response_body["lifetime"]).to eq(0) expect(response_body["running"]).to be >= 0 expect(response_body["remaining"]).to be <= 0 - expect(response_body["start_time"]).to eq("#{current_time}") - expect(response_body["end_time"]).to eq("#{current_time}") + expect(response_body["start_time"]).to eq(current_time.to_datetime.rfc3339) + expect(response_body["end_time"]).to eq(current_time.to_datetime.rfc3339) expect(response_body["state"]).to eq("running") expect(response_body["ip"]).to eq("") end