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

Don't call methods on a non-enabled CDN.

This commit is contained in:
Ash Wilson 2013-12-17 15:32:33 -05:00
parent 58b3f0d0e0
commit ea1dd6c2e4
3 changed files with 13 additions and 11 deletions

View file

@ -35,6 +35,12 @@ module Fog
"X-Trans-Id"
end
# Returns true if CDN service is enabled
# @return [Boolean]
def enabled?
@enabled
end
def endpoint_uri(service_endpoint_url=nil)
@uri = super(@rackspace_cdn_url || service_endpoint_url, :rackspace_cdn_url)
end
@ -98,6 +104,7 @@ module Fog
def initialize(options={})
@rackspace_username = options[:rackspace_username]
@enabled = false
end
def data
@ -137,12 +144,6 @@ module Fog
end
end
# Returns true if CDN service is enabled
# @return [Boolean]
def enabled?
@enabled
end
# Resets CDN connection
def reload
@cdn_connection.reset

View file

@ -166,8 +166,11 @@ module Fog
def save
requires :key
create_or_update_container
raise Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided") if public? && !cdn_enabled?
if cdn_enabled?
@urls = service.cdn.publish_container(self, public?)
else
raise Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided") if public?
end
true
end

View file

@ -1,8 +1,6 @@
Shindo.tests('Fog::Storage[:rackspace] | object requests', ["rackspace"]) do
unless Fog.mocking?
@directory = Fog::Storage[:rackspace].directories.create(:key => 'fogobjecttests')
end
module RackspaceStorageHelpers
def override_path(path)