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:
parent
58b3f0d0e0
commit
ea1dd6c2e4
3 changed files with 13 additions and 11 deletions
|
@ -35,6 +35,12 @@ module Fog
|
||||||
"X-Trans-Id"
|
"X-Trans-Id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns true if CDN service is enabled
|
||||||
|
# @return [Boolean]
|
||||||
|
def enabled?
|
||||||
|
@enabled
|
||||||
|
end
|
||||||
|
|
||||||
def endpoint_uri(service_endpoint_url=nil)
|
def endpoint_uri(service_endpoint_url=nil)
|
||||||
@uri = super(@rackspace_cdn_url || service_endpoint_url, :rackspace_cdn_url)
|
@uri = super(@rackspace_cdn_url || service_endpoint_url, :rackspace_cdn_url)
|
||||||
end
|
end
|
||||||
|
@ -98,6 +104,7 @@ module Fog
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
@rackspace_username = options[:rackspace_username]
|
@rackspace_username = options[:rackspace_username]
|
||||||
|
@enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
|
@ -137,12 +144,6 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if CDN service is enabled
|
|
||||||
# @return [Boolean]
|
|
||||||
def enabled?
|
|
||||||
@enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
# Resets CDN connection
|
# Resets CDN connection
|
||||||
def reload
|
def reload
|
||||||
@cdn_connection.reset
|
@cdn_connection.reset
|
||||||
|
|
|
@ -166,8 +166,11 @@ module Fog
|
||||||
def save
|
def save
|
||||||
requires :key
|
requires :key
|
||||||
create_or_update_container
|
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?)
|
@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
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
Shindo.tests('Fog::Storage[:rackspace] | object requests', ["rackspace"]) do
|
Shindo.tests('Fog::Storage[:rackspace] | object requests', ["rackspace"]) do
|
||||||
|
|
||||||
unless Fog.mocking?
|
|
||||||
@directory = Fog::Storage[:rackspace].directories.create(:key => 'fogobjecttests')
|
@directory = Fog::Storage[:rackspace].directories.create(:key => 'fogobjecttests')
|
||||||
end
|
|
||||||
|
|
||||||
module RackspaceStorageHelpers
|
module RackspaceStorageHelpers
|
||||||
def override_path(path)
|
def override_path(path)
|
||||||
|
|
Loading…
Reference in a new issue