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

Merge pull request #2348 from s-andringa/fix_local_directories_all

Directories#all breaks when :local_root folder is missing for Fog::Storage::Local
This commit is contained in:
Wesley Beary 2013-11-04 06:33:40 -08:00
commit 85076c0db4
2 changed files with 25 additions and 4 deletions

View file

@ -10,11 +10,15 @@ module Fog
model Fog::Storage::Local::Directory model Fog::Storage::Local::Directory
def all def all
data = Dir.entries(service.local_root).select do |entry| data = if ::File.directory?(service.local_root)
Dir.entries(service.local_root).select do |entry|
entry[0...1] != '.' && ::File.directory?(service.path_to(entry)) entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
end.map do |entry| end.map do |entry|
{:key => entry} {:key => entry}
end end
else
[]
end
load(data) load(data)
end end

View file

@ -0,0 +1,17 @@
Shindo.tests('Storage[:local] | directories', ["local"]) do
pending if Fog.mocking?
@options = { :local_root => "/tmp/fogtests" }
@collection = Fog::Storage::Local.new(@options).directories
collection_tests(@collection, {:key => "fogdirtests"}, true)
tests("#all") do
tests("succeeds when :local_root does not exist").succeeds do
FileUtils.rm_rf(@options[:local_root])
@collection.all
end
end
end