[PATCH conductor] BZ 796800 - Disallow Environment actions if Environment has no Pools

Matt Wagner matt.wagner at redhat.com
Mon Feb 27 22:37:03 UTC 2012


Attempting to import an image into an Environment which has no Pool
will only cause errors, so disallow it. For now, this functions only
by disabling the links to those functions.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=796800
---
 src/app/views/images/_list.html.haml               |    5 +++--
 src/app/views/pool_families/_list.html.haml        |    8 ++++++--
 src/features/pool_family.feature                   |    4 ++--
 src/features/step_definitions/pool_family_steps.rb |    5 +++++
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/app/views/images/_list.html.haml b/src/app/views/images/_list.html.haml
index 635297f..14bd5f5 100644
--- a/src/app/views/images/_list.html.haml
+++ b/src/app/views/images/_list.html.haml
@@ -1,8 +1,9 @@
 - content_for :form_header do
   - if @pool_family and check_privilege(Privilege::USE, @pool_family)
     %li= restful_submit_tag t("delete"), "destroy", multi_destroy_images_path, 'DELETE', :id => 'delete_button', :class => 'button danger'
-    %li= link_to t('images.import.import_image'), new_image_path(:tab => 'import', :environment => @pool_family), { :class => 'button primary', :id => 'import_image_button'}
-    %li= link_to t('images.index.new'), new_image_path(:environment => @pool_family), { :class => 'button primary', :id => 'import_image_button'}
+    - if @pool_family.pools.any?
+      %li= link_to t('images.import.import_image'), new_image_path(:tab => 'import', :environment => @pool_family), { :class => 'button primary', :id => 'import_image_button'}
+      %li= link_to t('images.index.new'), new_image_path(:environment => @pool_family), { :class => 'button primary', :id => 'import_image_button'}
 
 = filter_table(@header, @images) do |image|
   - if @pool_family.nil? and image.environment
diff --git a/src/app/views/pool_families/_list.html.haml b/src/app/views/pool_families/_list.html.haml
index 0e89af0..4538929 100644
--- a/src/app/views/pool_families/_list.html.haml
+++ b/src/app/views/pool_families/_list.html.haml
@@ -13,11 +13,15 @@
         .caption_content
           %header
             %h2
-              = link_to pool_family.name, pool_family
+              - if pool_family.pools.any?
+                = link_to pool_family.name, pool_family
+              - else
+                = pool_family.name
             .section-controls
               #obj_actions
                 = link_to t("pools.new_pool"), new_pool_path(:pool_family_id => pool_family.id), :class => 'pool_family_button'
-                = link_to t("images.new.new_image"), new_image_path( :environment => pool_family.id), :class => 'new_image_button'
+                - if pool_family.pools.any?
+                  = link_to t("images.new.new_image"), new_image_path( :environment => pool_family.id), :class => 'new_image_button'
       - unless pool_family.pools.blank?
         %tr
           %th= t("pool_families.index.pool_name")
diff --git a/src/features/pool_family.feature b/src/features/pool_family.feature
index a7589e2..78200d5 100644
--- a/src/features/pool_family.feature
+++ b/src/features/pool_family.feature
@@ -30,7 +30,7 @@ Feature: Pool Families
   Scenario: Show pool family details
     Given I am an authorised user
     And I am logged in
-    And there is a pool family named "testpoolfamily"
+    And there is a pool family named "testpoolfamily" with a pool named "bob"
     And I am on the pool families page
     When I follow "testpoolfamily"
     Then I should be on the page for the pool family "testpoolfamily"
@@ -54,7 +54,7 @@ Feature: Pool Families
     Given I am an authorised user
     And I am logged in
     And I am on the homepage
-    And there is a pool family named "poolfamily1"
+    And there is a pool family named "poolfamily1" with a pool named "carl"
     When I go to the pool families page
     And I follow "poolfamily1"
     And I press "delete_pool_family_button"
diff --git a/src/features/step_definitions/pool_family_steps.rb b/src/features/step_definitions/pool_family_steps.rb
index b2239dd..c2d3a34 100644
--- a/src/features/step_definitions/pool_family_steps.rb
+++ b/src/features/step_definitions/pool_family_steps.rb
@@ -28,6 +28,11 @@ Given /^there is a pool family named "([^\"]*)"$/ do |name|
   @pool_family = FactoryGirl.create(:pool_family, :name => name)
 end
 
+Given /^there is a pool family named "([^\"]*)" with a pool named "([^\"]*)"$/ do |pool_family, pool|
+  @pool_family = FactoryGirl.create(:pool_family, :name => pool_family)
+  @pool = FactoryGirl.create(:pool, :name => pool, :pool_family => @pool_family)
+end
+
 Given /^there is not a pool family named "([^"]*)"$/ do |name|
   pool_family = PoolFamily.find_by_name(name)
   if pool_family then pool_family.destroy end
-- 
1.7.6.5




More information about the aeolus-devel mailing list