On 07/20/2011 01:59 PM, jtomasek(a)redhat.com wrote:
From: Jiri Tomasek<jtomasek(a)redhat.com>
If pool has instances with other state than stopped or create_failed,
the pool can't be deleted.
---
src/app/models/pool.rb | 2 +-
src/features/pool.feature | 9 +++++++++
src/features/step_definitions/deployment_steps.rb | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb
index 6776a19..028465c 100644
--- a/src/app/models/pool.rb
+++ b/src/app/models/pool.rb
@@ -58,7 +58,7 @@ class Pool< ActiveRecord::Base
:include => [:role],
:order => "permissions.id ASC"
- has_many :deployments
+ has_many :deployments, :dependent => :destroy
before_destroy :destroyable?
diff --git a/src/features/pool.feature b/src/features/pool.feature
index 9be0c38..667a6bc 100644
--- a/src/features/pool.feature
+++ b/src/features/pool.feature
@@ -110,6 +110,15 @@ Feature: Manage Pools
Then I should see "The default pool cannot be deleted"
And I should see "pool_default"
+ Scenario: Cannot delete pool with running instances
+ Given I am on the pools page
+ And a pool "Amazon Startrek Pool" exists with deployment
"testdeployment"
+ And the deployment "testdeployment" has an instance named
"testinstance"
+ When I follow link with ID "filter_view"
+ And I check "Amazon Startrek Pool" pool
+ And I press "delete_button"
+ Then I should see "was not deleted"
+
Scenario: View all pools in JSON format
Given there are 2 pools
And I accept JSON
diff --git a/src/features/step_definitions/deployment_steps.rb
b/src/features/step_definitions/deployment_steps.rb
index a505e53..90524b2 100644
--- a/src/features/step_definitions/deployment_steps.rb
+++ b/src/features/step_definitions/deployment_steps.rb
@@ -28,7 +28,7 @@ end
Given /^the deployment "([^"]*)" has an instance named
"([^"]*)"$/ do |d_name, i_name|
deployment = Deployment.find_by_name(d_name)
- deployment.instances<< Factory(:instance, :name => i_name)
+ deployment.instances<< Factory(:instance, :name => i_name, :pool =>
deployment.pool)
end
When /^I am viewing the deployment "([^"]*)"$/ do |arg1|
ACK & pushed.
Thomas
--
No trees were killed to send this message, but a large number of
electrons were terribly inconvenienced.