Skip to content

Commit

Permalink
(PUP-7130) Fix handling of DateTime.httpdate(x).to_time
Browse files Browse the repository at this point in the history
In Ruby versions prior <2.4.0, the statement
```
x = DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT').to_time.to_s
```
produces a local time like "2001-02-03 05:05:06 +0100". In 2.4.0 the
timezone is retained. This commit ensures that the time used for the
http_metadata checksum is UTC and that the test expects UTC. That works,
regardless of Ruby version.
  • Loading branch information
thallgren committed Feb 23, 2017
1 parent f4f5ccb commit d472bef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/file_serving/http_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(http_response, path = '/dev/null')

if last_modified = http_response['last-modified']
mtime = DateTime.httpdate(last_modified).to_time
@checksums[:mtime] = "{mtime}#{mtime}"
@checksums[:mtime] = "{mtime}#{mtime.utc}"
end

@ftype = 'file'
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/file_serving/http_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
metadata = described_class.new(http_response)
metadata.collect
expect( metadata.checksum_type ).to eq :mtime
expect( metadata.checksum ).to eq "{mtime}#{time.to_time}"
expect( metadata.checksum ).to eq "{mtime}#{time.to_time.utc}"
end
end

Expand Down

0 comments on commit d472bef

Please sign in to comment.