Skip to content

Commit

Permalink
[aws|cdn] fix up failing mocked tests around invalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Oct 2, 2012
1 parent 18803ff commit 1b38993
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/fog/aws/models/cdn/invalidation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Invalidation < Fog::Model
attribute :paths, :aliases => 'Paths'

def initialize(new_attributes={})
new_attributes[:caller_reference] ||= Time.now.utc.to_i.to_s
super(invalidation_to_attributes(new_attributes))
end

Expand All @@ -29,7 +30,7 @@ def ready?
def save
requires :paths, :caller_reference
raise "Submitted invalidation cannot be submitted again" if identity
response = connection.post_invalidation(distribution.identity, paths, caller_reference || Time.now.to_i.to_s)
response = connection.post_invalidation(distribution.identity, paths, caller_reference)
merge_attributes(invalidation_to_attributes(response.body))
true
end
Expand All @@ -47,8 +48,12 @@ def distribution=(dist)

def invalidation_to_attributes(new_attributes={})
invalidation_batch = new_attributes.delete('InvalidationBatch') || {}
new_attributes['Paths'] = invalidation_batch['Path']
new_attributes['CallerReference'] = invalidation_batch['CallerReference']
if invalidation_batch['Path']
new_attributes[:paths] = invalidation_batch['Path']
end
if invalidation_batch['CallerReference']
new_attributes[:caller_reference] = invalidation_batch['CallerReference']
end
new_attributes
end

Expand Down

0 comments on commit 1b38993

Please sign in to comment.