Skip to content

Commit

Permalink
find_by_query support for vdcs collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepea committed Sep 23, 2014
1 parent 6537947 commit a440f3d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/fog/vcloud_director/models/compute/vdcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ module Fog
module Compute
class VcloudDirector
class Vdcs < Collection

include Fog::VcloudDirector::Query

model Fog::Compute::VcloudDirector::Vdc

attribute :organization

def query_type
"orgVdc"
end

private

def get_by_id(item_id)
Expand Down
14 changes: 14 additions & 0 deletions tests/vcloud_director/models/compute/vdcs_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@
tests("#get_by_name").returns(vdc.name) { vdcs.get_by_name(vdc.name).name }
tests("#get").returns(vdc.id) { vdcs.get(vdc.id).id }
end

pending if Fog.mocking?

# We should also be able to find this same vdc via Query API
tests("Compute::VcloudDirector | vdcs", ['find_by_query']) do
tests('we can retrieve :name without lazy loading').returns(vdc.name) do
query_vdc = vdcs.find_by_query(:filter => "name==#{vdc.name}").first
query_vdc.attributes[:name]
end
tests('by name').returns(vdc.name) do
query_vdc = vdcs.find_by_query(:filter => "name==#{vdc.name}").first
query_vdc.name
end
end
end

0 comments on commit a440f3d

Please sign in to comment.