https://bugzilla.redhat.com/show_bug.cgi?id=684088
---
src/app/controllers/resources/pools_controller.rb | 2 +-
src/features/pool.feature | 14 +++++++++++---
src/features/step_definitions/pool_steps.rb | 10 ++++++----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/src/app/controllers/resources/pools_controller.rb
b/src/app/controllers/resources/pools_controller.rb
index 3a927f1..337a1b8 100644
--- a/src/app/controllers/resources/pools_controller.rb
+++ b/src/app/controllers/resources/pools_controller.rb
@@ -77,7 +77,7 @@ class Resources::PoolsController < ApplicationController
# FIXME: remove this check when pools can be assigned to new users
# default_pool cannot be deleted because metadata object has it tied
# to id of 1 and deleting it prevents new users from being created
- if pool.name == "default_pool"
+ if pool.id == MetadataObject.lookup("self_service_default_pool").id
flash[:notice] = "The default pool cannot be deleted"
else
pool.destroy if check_privilege(Privilege::MODIFY, pool)
diff --git a/src/features/pool.feature b/src/features/pool.feature
index 864357b..75cb1c3 100644
--- a/src/features/pool.feature
+++ b/src/features/pool.feature
@@ -42,15 +42,15 @@ Feature: Manage Pools
Then I should see "Name must only contain: numbers, letters, spaces, '_'
and '-'"
Scenario: Delete pools
- Given there are no pools
+ Given I am on the pools page
And a pool "Amazon Startrek Pool" exists
And a pool "Redhat Voyager Pool" exists
And I am on the resources pools page
- And there are 2 pools
+ And there are 3 pools
When I check "Redhat Voyager Pool" pool
And I check "Amazon Startrek Pool" pool
And I press "Destroy"
- Then there should only be 0 pools
+ Then there should only be 1 pools
And I should be on the resources pools page
And I should not see "Redhat Voyager Pool"
And I should not see "Amazon Startrek Pool"
@@ -86,3 +86,11 @@ Feature: Manage Pools
And I press "Destroy"
Then I should see "The default pool cannot be deleted"
And I should see "default_pool"
+
+ Scenario: Cannot delete default_pool by renaming it
+ Given I renamed default_pool to pool_default
+ Given I am on the pools page
+ When I check "pool_default" pool
+ And I press "Destroy"
+ Then I should see "The default pool cannot be deleted"
+ And I should see "pool_default"
diff --git a/src/features/step_definitions/pool_steps.rb
b/src/features/step_definitions/pool_steps.rb
index 689bd47..5fd48c1 100644
--- a/src/features/step_definitions/pool_steps.rb
+++ b/src/features/step_definitions/pool_steps.rb
@@ -8,10 +8,6 @@ Given /^I have Pool Creator permissions on a pool named
"([^\"]*)"$/ do |name|
Factory(:pool_creator_permission, :user => @user, :permission_object => @pool)
end
-Given /^there are no pools$/ do
- Pool.delete_all
-end
-
Given /^there are (\d+) pools$/ do |number|
Pool.count.should == number.to_i
end
@@ -59,3 +55,9 @@ Given /^the "([^\"]*)" Pool has a quota with following
capacities:$/ do |name,ta
@pool.quota_id = @quota.id
@pool.save
end
+
+Given /^I renamed default_pool to pool_default$/ do
+ p = Pool.find_by_name("default_pool")
+ p.name = "pool_default"
+ p.save
+end
--
1.7.4