From 8bb3e60aea4fc99262f19b445255f19e6c7dd989 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 4 Mar 2013 18:54:18 +0100 Subject: [PATCH] [openstack|compute] images collection should not return nil for #all Fog::Compute[:openstack].images.all returns nil without the patch. The patch should bring the images collection behaviour in-line with other collections I think. The added test should expose the issue. --- lib/fog/openstack/models/compute/images.rb | 3 ++- tests/openstack/models/compute/images_tests.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/openstack/models/compute/images_tests.rb diff --git a/lib/fog/openstack/models/compute/images.rb b/lib/fog/openstack/models/compute/images.rb index a5815c734..e560ba55f 100644 --- a/lib/fog/openstack/models/compute/images.rb +++ b/lib/fog/openstack/models/compute/images.rb @@ -13,10 +13,11 @@ module Fog def all data = service.list_images_detail.body['images'] - load(data) + images = load(data) if server self.replace(self.select {|image| image.server_id == server.id}) end + images end def get(image_id) diff --git a/tests/openstack/models/compute/images_tests.rb b/tests/openstack/models/compute/images_tests.rb new file mode 100644 index 000000000..b2dd3712f --- /dev/null +++ b/tests/openstack/models/compute/images_tests.rb @@ -0,0 +1,14 @@ +Shindo.tests("Fog::Compute[:openstack] | images collection", ['openstack']) do + + tests('success') do + + tests('#all').succeeds do + fog = Fog::Compute[:openstack] + test 'not nil' do + fog.images.all.is_a? Array + end + end + + end +end +