From 3f002783173a5c78c34a01f99d8a71488152d09e Mon Sep 17 00:00:00 2001 From: Glenn Rempe Date: Tue, 29 Jun 2010 11:47:23 -0700 Subject: [PATCH] Allow detach_volume to take :force param as string or Boolean. Closes #22. --- lib/AWS/EC2/volumes.rb | 2 +- test/test_EC2_volumes.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/AWS/EC2/volumes.rb b/lib/AWS/EC2/volumes.rb index 5bcb2a3..dfdbece 100644 --- a/lib/AWS/EC2/volumes.rb +++ b/lib/AWS/EC2/volumes.rb @@ -88,7 +88,7 @@ def detach_volume( options = {} ) "VolumeId" => options[:volume_id], "InstanceId" => options[:instance_id], "Device" => options[:device], - "Force" => options[:force] + "Force" => options[:force].to_s } return response_generator(:action => "DetachVolume", :params => params) end diff --git a/test/test_EC2_volumes.rb b/test/test_EC2_volumes.rb index 601a7c6..c118ca1 100644 --- a/test/test_EC2_volumes.rb +++ b/test/test_EC2_volumes.rb @@ -139,4 +139,20 @@ response.status.should.equal "detaching" end + specify "should be able to be force detached with a string" do + @ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>"true"}). + returns stub(:body => @detach_volume_response_body, :is_a? => true) + + response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :force => 'true' ) + response.volumeId.should.equal "vol-4d826724" + end + + specify "should be able to be force detached with a Boolean" do + @ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>"true"}). + returns stub(:body => @detach_volume_response_body, :is_a? => true) + + response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :force => true ) + response.volumeId.should.equal "vol-4d826724" + end + end