---
src/spec/models/deployment_spec.rb | 29 +++++++++++++++++++++++++++++
src/spec/models/instance_spec.rb | 30 ++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/spec/models/deployment_spec.rb b/src/spec/models/deployment_spec.rb
index 457c2f4..b8688b9 100644
--- a/src/spec/models/deployment_spec.rb
+++ b/src/spec/models/deployment_spec.rb
@@ -123,6 +123,35 @@ describe Deployment do
inst1.tasks.last.action.should == 'stop'
inst3.tasks.last.action.should == 'stop'
end
+
+ it "should allow for a soft delete" do
+ second_deployment = Factory.build(:deployment,
+ :pool_id => @deployment.pool_id,
+ :name => "soft delete deployment")
+ second_deployment.save!
+ second_deployment_id = second_deployment.id
+
+ lambda { Deployment.find(second_deployment_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Deployment.only_deleted.find(second_deployment_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ Deployment.unscoped.find(second_deployment_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+
+ expect { second_deployment.destroy }.to change(Deployment, :count).by(-1)
+
+ copy_second_deployment = Factory.build(:deployment,
+ :pool_id => @deployment.pool_id,
+ :name => "soft delete deployment")
+ copy_second_deployment.should be_valid
+
+ lambda { Deployment.find(second_deployment_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Deployment.only_deleted.find(second_deployment_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ second_deployment = Deployment.unscoped.find(second_deployment_id)
}.should_not raise_error(ActiveRecord::RecordNotFound)
+
+ second_deployment.destroy!
+
+ lambda { Deployment.find(second_deployment_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Deployment.only_deleted.find(second_deployment_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ Deployment.unscoped.find(second_deployment_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ end
end
describe ".provider" do
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
index 11a1a62..1bb4ed8 100644
--- a/src/spec/models/instance_spec.rb
+++ b/src/spec/models/instance_spec.rb
@@ -73,6 +73,36 @@ describe Instance do
end
end
+ it "should allow for a soft delete" do
+ second_instance = Factory.build(:instance,
+ :pool_id => @instance.pool_id,
+ :name => "soft delete instance",
+ :state => Instance::STATE_CREATE_FAILED)
+ second_instance.save!
+ second_instance_id = second_instance.id
+
+ lambda { Instance.find(second_instance_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Instance.only_deleted.find(second_instance_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ Instance.unscoped.find(second_instance_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+
+ expect { second_instance.destroy }.to change(Instance, :count).by(-1)
+
+ copy_second_instance = Factory.build(:instance,
+ :pool_id => @instance.pool_id,
+ :name => "soft delete instance",
+ :state => Instance::STATE_CREATE_FAILED)
+ copy_second_instance.should be_valid
+
+ lambda { Instance.find(second_instance_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Instance.only_deleted.find(second_instance_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ second_instance = Instance.unscoped.find(second_instance_id) }.should_not
raise_error(ActiveRecord::RecordNotFound)
+
+ second_instance.destroy!
+
+ lambda { Instance.find(second_instance_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda { Instance.only_deleted.find(second_instance_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ lambda{ Instance.unscoped.find(second_instance_id) }.should
raise_error(ActiveRecord::RecordNotFound)
+ end
it "should tell apart valid and invalid actions" do
@instance.stub!(:get_action_list).and_return(@actions)
--
1.7.6.5