From 72d05d2b545bdcdbf0df2f364f0175ec243e4315 Mon Sep 17 00:00:00 2001 From: freeformz Date: Thu, 1 Jul 2010 01:48:53 +0800 Subject: [PATCH] [Vcloud] Internet Service mock did not initialize its :nodes when added --- .../terremark/ecloud/requests/add_internet_service.rb | 8 ++++++-- .../ecloud/requests/add_internet_service_spec.rb | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb b/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb index db683ce46..80aa1e5ff 100644 --- a/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +++ b/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb @@ -64,9 +64,13 @@ module Fog validate_internet_service_data(service_data) internet_services_uri = ensure_unparsed(internet_services_uri) - + if ip = ip_from_uri(internet_services_uri) - new_service = service_data.merge!( { :href => Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href( { :id => rand(1000) } ), :timeout => 2 } ) + id = rand(1000) + new_service = service_data.merge!( { :href => Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href( { :id => id } ), + :id => id.to_s, + :timeout => 2, + :nodes => [] } ) ip[:services] << new_service xml = generate_internet_service_response( service_data, ip ) diff --git a/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb b/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb index f49a617b0..ea69c3d9d 100644 --- a/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +++ b/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb @@ -48,6 +48,14 @@ if Fog.mocking? specify { public_ip[:Name].should == @public_ip.name } specify { public_ip[:Id].should == @public_ip.id } + it "should update the mock object properly" do + subject + ip, service = @vcloud.mock_ip_and_service_from_service_url(body[:Href]) + service[:href].should == body[:Href] + service[:id].should == body[:Id] + service[:nodes].should == [] + end + end context "with a public_ips_uri that doesn't exist" do