From: Tomas Sedovic tsedovic@redhat.com
--- src/features/pool.feature | 3 ++- src/spec/models/pool_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/src/features/pool.feature b/src/features/pool.feature index 7f1a00b..6a12f19 100644 --- a/src/features/pool.feature +++ b/src/features/pool.feature @@ -51,7 +51,8 @@ Feature: Manage Pools And I press "Destroy" Then there should only be 1 pools And I should be on the resources pools page - And I should not see "Redhat Voyager Pool" + When I go to the resources pools page + Then I should not see "Redhat Voyager Pool" And I should not see "Amazon Startrek Pool"
Scenario: Create multiple pools diff --git a/src/spec/models/pool_spec.rb b/src/spec/models/pool_spec.rb index ca754fa..58ddec4 100644 --- a/src/spec/models/pool_spec.rb +++ b/src/spec/models/pool_spec.rb @@ -22,4 +22,30 @@ describe Pool do u.errors[:name].should =~ /^is too long.*/ end
+ it "should not be destroyable when it has running instances" do + pool = Factory.create(:pool) + Pool.find(pool.id).should be_destroyable + + instance = Factory.create(:instance, :pool_id => pool.id) + Pool.find(pool.id).should_not be_destroyable + + instance.state = Instance::STATE_STOPPED + instance.save! + Pool.find(pool.id).should be_destroyable + end + + it "should not be destroyable when it has stopped stateful instances" do + pool = Factory.build(:pool) + pool.should be_destroyable + + instance = Factory.build(:instance, :pool_id => pool.id) + instance.stub!(:restartable?).and_return(true) + pool.instances << instance + pool.should_not be_destroyable + + instance.state = Instance::STATE_STOPPED + instance.stub!(:restartable?).and_return(true) + pool.should_not be_destroyable + end + end