deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 16/16] Core: Fixed 'render_cdata' helper to die properly when string is nil
Date Thu, 19 Jul 2012 13:02:49 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/helpers/deltacloud_helper.rb |    2 +-
 server/tests/deltacloud/deltacloud_helper_test.rb  |    1 +
 server/views/blobs/show.xml.haml                   |    3 +--
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 047e1b2..799478e 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -152,7 +152,7 @@ module Deltacloud::Helpers
     end
 
     def render_cdata(text)
-      "<![CDATA[#{text.strip}]]>"
+      "<![CDATA[#{text.strip}]]>" unless text.nil?
     end
 
     def link_to_action(action, url, method)
diff --git a/server/tests/deltacloud/deltacloud_helper_test.rb b/server/tests/deltacloud/deltacloud_helper_test.rb
index 67d4af6..9096db0 100644
--- a/server/tests/deltacloud/deltacloud_helper_test.rb
+++ b/server/tests/deltacloud/deltacloud_helper_test.rb
@@ -42,6 +42,7 @@ describe Deltacloud::Helpers::Application do
     @helper.render_cdata('test').must_equal '<![CDATA[test]]>'
     @helper.render_cdata('').must_equal '<![CDATA[]]>'
     @helper.render_cdata('test   ').must_equal '<![CDATA[test]]>'
+    @helper.render_cdata(nil).must_be_nil
   end
 
   it 'provide helper to access driver entrypoints' do
diff --git a/server/views/blobs/show.xml.haml b/server/views/blobs/show.xml.haml
index 79bb8e6..4687720 100644
--- a/server/views/blobs/show.xml.haml
+++ b/server/views/blobs/show.xml.haml
@@ -9,6 +9,5 @@
   %user_metadata
     - if @blob.user_metadata.respond_to? :each
       - @blob.user_metadata.each do |k, v|
-        %entry{:key => k}
-          #{cdata v}
+        %entry{:key => k}=render_cdata(v)
   %content{:href => bucket_url(@blob.bucket) + '/' + @blob.id + '/content', :rel =>
'blob_content'}
-- 
1.7.10.2


Mime
View raw message