incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Minor fixes which make API work under Ruby 1.9.2
Date Thu, 30 Sep 2010 15:45:39 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/config.ru                       |    2 ++
 server/server.rb                       |    2 ++
 server/tests/api_test.rb               |    3 ++-
 server/tests/common.rb                 |    2 ++
 server/tests/hardware_profiles_test.rb |    4 ++--
 server/tests/images_test.rb            |    2 +-
 server/tests/instance_states_test.rb   |    4 ++--
 server/tests/instances_test.rb         |    8 ++++----
 server/tests/realms_test.rb            |    2 +-
 server/views/images/show.html.haml     |    2 +-
 10 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/server/config.ru b/server/config.ru
index 691c238..cb38ca8 100644
--- a/server/config.ru
+++ b/server/config.ru
@@ -1,5 +1,7 @@
 require 'rubygems'
 require 'sinatra'
 
+$:.unshift File.join(File.dirname(__FILE__), '.')
+
 require 'server.rb'
 run Sinatra::Application
diff --git a/server/server.rb b/server/server.rb
index a64e79d..bf476f6 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -14,6 +14,8 @@ require 'lib/deltacloud/helpers/blob_stream'
 configure do
   set :raise_errors => false
   set :show_exceptions, false
+  set :views, File.dirname(__FILE__) + '/views'
+  set :public, File.dirname(__FILE__) + '/public'
 end
 
 configure :development do
diff --git a/server/tests/api_test.rb b/server/tests/api_test.rb
index cbab5bf..9fbf04f 100644
--- a/server/tests/api_test.rb
+++ b/server/tests/api_test.rb
@@ -1,3 +1,4 @@
+$:.unshift File.join(File.dirname(__FILE__), '..')
 require 'tests/common'
 
 module DeltacloudUnitTest
@@ -10,7 +11,7 @@ module DeltacloudUnitTest
 
     def test_it_returns_entry_points
       do_xml_request '/api'
-      (last_xml_response/'/api/link').map.size.should > 0
+      (last_xml_response/'/api/link').to_a.size.should > 0
     end
 
     def test_it_has_correct_attributes_set
diff --git a/server/tests/common.rb b/server/tests/common.rb
index d848e3b..a214dde 100644
--- a/server/tests/common.rb
+++ b/server/tests/common.rb
@@ -1,3 +1,5 @@
+$:.unshift File.join(File.dirname(__FILE__), '..')
+
 require 'rubygems'
 require 'base64'
 require 'test/unit'
diff --git a/server/tests/hardware_profiles_test.rb b/server/tests/hardware_profiles_test.rb
index 28805a3..4a8f1d7 100644
--- a/server/tests/hardware_profiles_test.rb
+++ b/server/tests/hardware_profiles_test.rb
@@ -10,7 +10,7 @@ module DeltacloudUnitTest
 
     def test_it_returns_hardware_profiles
       do_xml_request '/api/hardware_profiles'
-      (last_xml_response/'hardware_profiles/hardware_profile').map.size.should > 0
+      (last_xml_response/'hardware_profiles/hardware_profile').to_a.size.should > 0
     end
 
     def test_it_has_correct_attributes_set
@@ -109,7 +109,7 @@ module DeltacloudUnitTest
       (profile/'property[@name="storage"]').first['kind'].should == 'enum'
       (profile/'property[@name="storage"]').first['unit'].should == 'GB'
       (profile/'property[@name="storage"]/enum').size.should == 1
-      (profile/'property[@name="storage"]/enum/entry').map.size.should == 3
+      (profile/'property[@name="storage"]/enum/entry').to_a.size.should == 3
       (profile/'property[@name="storage"]/enum/entry').each do |entry|
         entry.attributes.keys.should == [ 'value' ]
         entry['value'].should_not == nil
diff --git a/server/tests/images_test.rb b/server/tests/images_test.rb
index 63c6907..7649d2d 100644
--- a/server/tests/images_test.rb
+++ b/server/tests/images_test.rb
@@ -14,7 +14,7 @@ module DeltacloudUnitTest
 
     def test_it_returns_images
       do_xml_request '/api/images', {}, true
-      (last_xml_response/'images/image').map.size.should > 0
+      (last_xml_response/'images/image').to_a.size.should > 0
     end
 
     def test_it_has_correct_attributes_set
diff --git a/server/tests/instance_states_test.rb b/server/tests/instance_states_test.rb
index e931dc5..4c0d0e0 100644
--- a/server/tests/instance_states_test.rb
+++ b/server/tests/instance_states_test.rb
@@ -14,14 +14,14 @@ module DeltacloudUnitTest
 
     def test_it_returns_instance_states
       do_xml_request '/api/instance_states', {}, true
-      (last_xml_response/'states/state').map.size.should > 0
+      (last_xml_response/'states/state').to_a.size.should > 0
     end
 
     def test_each_state_has_transition
       do_xml_request '/api/instance_states', {}, true
       (last_xml_response/'states/state').each do |state|
         next if state['name'].eql?('finish') # Finnish state doesn't have transitions
-        (state/'transition').map.size.should > 0
+        (state/'transition').to_a.size.should > 0
         (state/'transition').each do |transition|
           transition['to'].should_not == nil
         end
diff --git a/server/tests/instances_test.rb b/server/tests/instances_test.rb
index b1a4404..0af94fd 100644
--- a/server/tests/instances_test.rb
+++ b/server/tests/instances_test.rb
@@ -14,7 +14,7 @@ module DeltacloudUnitTest
 
     def test_it_returns_instances
       do_xml_request '/api/instances', {}, true
-      (last_xml_response/'instances/instance').map.size.should > 0
+      (last_xml_response/'instances/instance').to_a.size.should > 0
     end
 
     def test_it_has_correct_attributes_set
@@ -181,14 +181,14 @@ module DeltacloudUnitTest
       ['RUNNING', 'STOPPED'].include?((instance/'state').text).should == true
 
       (instance/'public_addreses').should_not == nil
-      (instance/'public_addresses/address').map.size.should > 0
+      (instance/'public_addresses/address').to_a.size.should > 0
       (instance/'public_addresses/address').first.text.should_not == ""
 
       (instance/'private_addresses').should_not == nil
-      (instance/'private_addresses/address').map.size.should > 0
+      (instance/'private_addresses/address').to_a.size.should > 0
       (instance/'private_addresses/address').first.text.should_not == ""
 
-      (instance/'actions/link').map.size.should > 0
+      (instance/'actions/link').to_a.size.should > 0
       (instance/'actions/link').each do |link|
         link['href'].should_not == ""
         link['rel'].should_not == ""
diff --git a/server/tests/realms_test.rb b/server/tests/realms_test.rb
index 97d539f..d6161c8 100644
--- a/server/tests/realms_test.rb
+++ b/server/tests/realms_test.rb
@@ -14,7 +14,7 @@ module DeltacloudUnitTest
 
     def test_it_returns_realms
       do_xml_request '/api/realms', {}, true
-      (last_xml_response/'realms/realm').map.size.should > 0
+      (last_xml_response/'realms/realm').to_a.size.should > 0
     end
 
     def test_it_has_correct_attributes_set
diff --git a/server/views/images/show.html.haml b/server/views/images/show.html.haml
index ea96ea4..93a9a7d 100644
--- a/server/views/images/show.html.haml
+++ b/server/views/images/show.html.haml
@@ -9,7 +9,7 @@
       = @image.name
     %dt Owner
     %dd
-      = link_to @image.owner_id, images_url( :owner_id => @image.owner_id )
+      = link_to @image.owner_id, image_url( :owner_id => @image.owner_id )
     %dt Architecture
     %dd
       = @image.architecture
-- 
1.7.2.3


Mime
View raw message