[PATCH conductor] BZ773051 disable automatic deployable creation option in images/overview when no catalog exist
jtomasek at redhat.com
jtomasek at redhat.com
Wed Feb 1 13:03:23 UTC 2012
From: Jiri Tomasek <jtomasek at redhat.com>
---
src/app/controllers/images_controller.rb | 10 +++++++++-
src/app/views/images/overview.html.haml | 5 ++++-
src/app/views/pool_families/_pools.html.haml | 2 +-
src/config/locales/en.yml | 1 +
src/features/image.feature | 12 ++++++++++++
src/features/step_definitions/catalog_steps.rb | 4 ++++
src/features/step_definitions/web_steps.rb | 4 ++++
7 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
index 997ab6a..6591c1c 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -229,7 +229,12 @@ class ImagesController < ApplicationController
@xml = xml_source
render :edit_xml and return
end
- render :overview unless params[:edit]
+
+ unless params[:edit]
+ @catalogs = Catalog.list_for_user(current_user, Privilege::VIEW)
+ flash.now[:warning] = t("images.overview.no_catalogs") if @catalogs.blank?
+ render :overview
+ end
end
def overview
@@ -250,6 +255,9 @@ class ImagesController < ApplicationController
flash.now[:error] = errors
render :edit_xml and return
end
+
+ @catalogs = Catalog.list_for_user(current_user, Privilege::VIEW)
+ flash.now[:warning] = t("images.overview.no_catalogs") if @catalogs.blank?
end
def create
diff --git a/src/app/views/images/overview.html.haml b/src/app/views/images/overview.html.haml
index 0167513..13f1008 100644
--- a/src/app/views/images/overview.html.haml
+++ b/src/app/views/images/overview.html.haml
@@ -17,7 +17,10 @@
%p.description= t('.description', :name => @name)
%fieldset.align-center
- = check_box_tag :make_deployable, 1, true
+ - if @catalogs.blank?
+ = check_box_tag :make_deployable, 1, false, :disabled => true
+ - else
+ = check_box_tag :make_deployable, 1, true
= label_tag :make_deployable, t('.make_deployable', :name => @name)
.centered
%fieldset.align-center
diff --git a/src/app/views/pool_families/_pools.html.haml b/src/app/views/pool_families/_pools.html.haml
index 50a8c00..000b87b 100644
--- a/src/app/views/pool_families/_pools.html.haml
+++ b/src/app/views/pool_families/_pools.html.haml
@@ -4,7 +4,7 @@
%td{:class => 'center'}= pool.deployments.count
%td{:class => 'center'}= pool.statistics[:total_instances]
%td{:class => 'center'}= pool.statistics[:instances_pending]
- %td{:class => 'center'}= pool.statistics[:instances_failed]
+ %td{:class => 'center'}= pool.statistics[:instances_failed_count]
%td{:class => 'center'}= pool.statistics[:quota_percent]
%td{:class => 'center'}= pool.statistics[:used_quota]
%td{:class => 'center'}= pool.statistics[:available_quota].nil? ? raw('∞') : pool.statistics[:available_quota]
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 71cdb65..9997e06 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -786,6 +786,7 @@ en:
make_deployable: Automatically make "%{name}" deployable.
back: Back
save_template: Save Template
+ no_catalogs: "It's not possible to automatically create a deployable because no catalogs exist."
not_on_provider: The requested image was not found on the provider.
template_xml:
errors:
diff --git a/src/features/image.feature b/src/features/image.feature
index 4e901d5..c406a32 100644
--- a/src/features/image.feature
+++ b/src/features/image.feature
@@ -27,6 +27,18 @@ Feature: Manage Images
And I press "save_image"
Then I should see "Failed to parse XML."
+ Scenario: Disable deployable creation when no catalog exists
+ Given there is a pool family named "testpoolfamily"
+ And I am on the new image page for "testpoolfamily"
+ And there are no catalogs
+ When I fill in "name" with "my template"
+ And I attach the file "features/upload_files/template.xml" to "image_file"
+ And I uncheck "edit"
+ And I press "file_button"
+ Then I should be on the edit xml images page
+ And I should see "no catalogs exist"
+ And the "make_deployable" checkbox should be disabled
+
#
# FIXME - This test is failing, but fixing it requires fixing a larger bug: we don't
# use VCR the way we think we do when interacting with iwhd... That's a large can of worms.
diff --git a/src/features/step_definitions/catalog_steps.rb b/src/features/step_definitions/catalog_steps.rb
index 3dcb34f..f5bb0b0 100644
--- a/src/features/step_definitions/catalog_steps.rb
+++ b/src/features/step_definitions/catalog_steps.rb
@@ -25,3 +25,7 @@ When /^I check "([^"]*)" catalog$/ do |arg1|
catalog = Catalog.find_by_name(arg1)
check("catalog_checkbox_#{catalog.id}")
end
+
+Then /^there are no catalogs/ do
+ Catalog.destroy_all
+end
diff --git a/src/features/step_definitions/web_steps.rb b/src/features/step_definitions/web_steps.rb
index 236a801..ce5a0b1 100644
--- a/src/features/step_definitions/web_steps.rb
+++ b/src/features/step_definitions/web_steps.rb
@@ -200,6 +200,10 @@ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label
end
end
+Then /^the "([^\"]*)" checkbox should be disabled$/ do |field|
+ find_field(field)[:disabled].should == 'disabled'
+end
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
--
1.7.7.6
More information about the aeolus-devel
mailing list