mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|cdn] fix up failing mocked tests around invalidations
This commit is contained in:
parent
18803ff91b
commit
1b389931b5
1 changed files with 8 additions and 3 deletions
|
@ -14,6 +14,7 @@ module Fog
|
||||||
attribute :paths, :aliases => 'Paths'
|
attribute :paths, :aliases => 'Paths'
|
||||||
|
|
||||||
def initialize(new_attributes={})
|
def initialize(new_attributes={})
|
||||||
|
new_attributes[:caller_reference] ||= Time.now.utc.to_i.to_s
|
||||||
super(invalidation_to_attributes(new_attributes))
|
super(invalidation_to_attributes(new_attributes))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ module Fog
|
||||||
def save
|
def save
|
||||||
requires :paths, :caller_reference
|
requires :paths, :caller_reference
|
||||||
raise "Submitted invalidation cannot be submitted again" if identity
|
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))
|
merge_attributes(invalidation_to_attributes(response.body))
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -47,8 +48,12 @@ module Fog
|
||||||
|
|
||||||
def invalidation_to_attributes(new_attributes={})
|
def invalidation_to_attributes(new_attributes={})
|
||||||
invalidation_batch = new_attributes.delete('InvalidationBatch') || {}
|
invalidation_batch = new_attributes.delete('InvalidationBatch') || {}
|
||||||
new_attributes['Paths'] = invalidation_batch['Path']
|
if invalidation_batch['Path']
|
||||||
new_attributes['CallerReference'] = invalidation_batch['CallerReference']
|
new_attributes[:paths] = invalidation_batch['Path']
|
||||||
|
end
|
||||||
|
if invalidation_batch['CallerReference']
|
||||||
|
new_attributes[:caller_reference] = invalidation_batch['CallerReference']
|
||||||
|
end
|
||||||
new_attributes
|
new_attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue