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:
commit
85076c0db4
2 changed files with 25 additions and 4 deletions
|
@ -10,10 +10,14 @@ 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)
|
||||||
entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
|
Dir.entries(service.local_root).select do |entry|
|
||||||
end.map do |entry|
|
entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
|
||||||
{:key => entry}
|
end.map do |entry|
|
||||||
|
{:key => entry}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
17
tests/local/models/directories_tests.rb
Normal file
17
tests/local/models/directories_tests.rb
Normal 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
|
Loading…
Add table
Reference in a new issue