deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Core: Fixed instance_action method to do proper redirect when :action method does not return the valid Instance object (DTACLOUD-237)
Date Thu, 14 Jun 2012 14:22:22 GMT
Updated Branches:
  refs/heads/master 64148f35c -> 20519d94f


Core: Fixed instance_action method to do proper redirect when :action method does not return
the valid Instance object (DTACLOUD-237)


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/20519d94
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/20519d94
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/20519d94

Branch: refs/heads/master
Commit: 20519d94f6b3964687c1105e56a3a7cad25c428b
Parents: 64148f3
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Jun 14 16:22:40 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Jun 14 16:22:40 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/helpers/deltacloud_helper.rb |   26 +++++++--------
 1 files changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/20519d94/server/lib/deltacloud/helpers/deltacloud_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 6d8cb9b..de28590 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -110,25 +110,23 @@ module Deltacloud::Helpers
       end
 
       headers['X-Backend-Runtime'] = @benchmark.real.to_s
-      status 202
 
       if name == :destroy
-        respond_to do |format|
-          format.xml { return 204 }
-          format.json { return 204 }
-          format.html { return redirect(instances_url) }
+        response = respond_to do |format|
+          format.html { redirect(instances_url) }
         end
+        halt 204, response
       end
 
-      if @instance.class != Instance
-        response['Location'] = instance_url(params[:id])
-        halt
-      end
-
-      respond_to do |format|
-        format.xml { haml :"instances/show" }
-        format.html { haml :"instances/show" }
-        format.json {convert_to_json(:instance, @instance) }
+      unless @instance.class == Instance
+        redirect instance_url(params[:id])
+      else
+        response = respond_to do |format|
+          format.xml { haml :"instances/show" }
+          format.html { haml :"instances/show" }
+          format.json { xml_to_json("instances/show") }
+        end
+        halt 202, response
       end
     end
 


Mime
View raw message