1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #1823 from rackspace/utc_fix

[Rackspace|Storage] last_modified= work around
This commit is contained in:
Kyle Rames 2013-05-22 06:12:56 -07:00
commit ed2d3aa3aa
2 changed files with 48 additions and 0 deletions

View file

@ -132,6 +132,24 @@ module Fog
end
end
# Set last modified
# @param [String, Fog::Time] timestamp
def last_modified=(obj)
if obj.nil? || obj == "" || obj.is_a?(Time)
attributes[:last_modified] = obj
return obj
end
# This is a work around for swift bug that has existed for 4+ years. The is that fixing the swift bug would cause more problems than its worth.
# For more information refer to https://github.com/fog/fog/pull/1811
d = Date._strptime(obj,"%Y-%m-%dT%H:%M:%S")
if d
attributes[:last_modified] = Time.utc(d[:year], d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:leftover], d[:zone])
else
attributes[:last_modified] = Time.parse(obj)
end
end
# Is file published to CDN
# @return [Boolean] return true if published to CDN
# @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404

View file

@ -1,5 +1,35 @@
require 'fog/rackspace/models/storage/file'
Shindo.tests('Fog::Rackspace::Storage | file', ['rackspace']) do
tests("last_modified=") do
tests("no timezone") do
file = Fog::Storage::Rackspace::File.new
file.last_modified = "2013-05-09T22:20:59.287990"
returns(Fog::Time.utc(2013, 5, 9, 22, 20, 59, 287990, nil) == file.last_modified) { true }
end
tests("with timezone") do
file = Fog::Storage::Rackspace::File.new
file.last_modified = "Thu, 09 May 2015 22:20:59 GMT"
returns(Fog::Time.utc(2015, 5, 9, 22, 20, 59, 0, nil).to_i == file.last_modified.to_i) { true }
end
tests("with time") do
file = Fog::Storage::Rackspace::File.new
file.last_modified = Fog::Time.utc(2015, 5, 9, 22, 20, 59, 0, nil)
returns(Fog::Time.utc(2015, 5, 9, 22, 20, 59, 0, nil) == file.last_modified) { true }
end
tests("nil") do
file = Fog::Storage::Rackspace::File.new
file.last_modified = nil
returns(nil) { file.last_modified }
end
tests("empty string") do
file = Fog::Storage::Rackspace::File.new
file.last_modified = ""
returns("") { file.last_modified }
end
end
pending if Fog.mocking?
def object_attributes(file=@instance)