On 12/16/2011 10:19 AM, jtomasek(a)redhat.com wrote:
From: Jiri Tomasek<jtomasek(a)redhat.com>
Could you please add BZ link or ID into commit log description?
---
src/app/controllers/deployables_controller.rb | 4 ++--
src/app/models/deployable.rb | 7 +++----
.../views/deployables/_new_from_image.html.haml | 7 +++++--
src/config/locales/en.yml | 1 +
.../controllers/deployables_controller_spec.rb | 2 +-
src/spec/models/deployable_spec.rb | 7 +++----
6 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/app/controllers/deployables_controller.rb
b/src/app/controllers/deployables_controller.rb
index 7271695..32903bd 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -107,7 +107,7 @@ class DeployablesController< ApplicationController
elsif params[:create_from_image].present?
hw_profile = HardwareProfile.frontend.find(params[:hardware_profile])
require_privilege(Privilege::VIEW, hw_profile)
- @deployable.set_from_image(params[:create_from_image], hw_profile)
+ @deployable.set_from_image(params[:create_from_image], params[:deployable][:name],
hw_profile)
end
begin
@@ -132,7 +132,7 @@ class DeployablesController< ApplicationController
load_catalogs
@image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
@hw_profiles = HardwareProfile.frontend.list_for_user(current_user,
Privilege::VIEW)
- @deployable.name = @image.name
+ #(a)deployable.name = @image.name
^ this commented line can be deleted
else
@catalog = @selected_catalogs.first
params.delete(:edit_xml) if params[:edit_xml]
diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
index ebd230c..59c4378 100644
--- a/src/app/models/deployable.rb
+++ b/src/app/models/deployable.rb
@@ -87,10 +87,10 @@ class Deployable< ActiveRecord::Base
end
end
- def set_from_image(image_id, hw_profile)
+ def set_from_image(image_id, name, hw_profile)
image = Aeolus::Image::Warehouse::Image.find(image_id)
doc = Nokogiri::XML ''
- doc.root = doc.create_element('deployable', :name => image.name)
+ doc.root = doc.create_element('deployable', :name => name)
description = doc.create_element('description')
doc.root<< description
assemblies = doc.create_element('assemblies')
@@ -102,8 +102,7 @@ class Deployable< ActiveRecord::Base
self.description = ''
self.xml = doc.to_s
- self.xml_filename = image.name
- self.name = image.name
+ self.xml_filename = name
end
#get details of image for deployable#show
diff --git a/src/app/views/deployables/_new_from_image.html.haml
b/src/app/views/deployables/_new_from_image.html.haml
index 732b9ad..9d9175a 100644
--- a/src/app/views/deployables/_new_from_image.html.haml
+++ b/src/app/views/deployables/_new_from_image.html.haml
@@ -1,5 +1,5 @@
%header.admin-page-header
- %h1.images= t('.catalog_entry_name', :name => @deployable.name)
+ %h1.images= @deployable.name.blank? ? " ".html_safe :
t('.catalog_entry_name', :name => @deployable.name)
%section.admin-content-section
.content
@@ -12,7 +12,10 @@
%p= t('.description', :name => @image.name)
%fieldset
%div
- = form.label :name, t('catalog_entries.new.hw_profile')
+ = form.label :name, t('catalog_entries.new.name')
+ = form.text_field :name
+ %div
+ = form.label :hardware_profile, t('catalog_entries.new.hw_profile')
= select_tag :hardware_profile,
options_from_collection_for_select(@hw_profiles, :id, :name, params[:hardware_profile])
.clear
%div
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index e3eef1c..93aee50 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -603,6 +603,7 @@ en:
choose_option_to_upload: Choose one of the following options to upload deployable
XML file
upload: Upload
from_url: From URL
+ name: Name
hw_profile: Default Hardware Profile
catalog_detail: "%{name} Catalog"
form:
diff --git a/src/spec/controllers/deployables_controller_spec.rb
b/src/spec/controllers/deployables_controller_spec.rb
index d6f8f09..fedb66a 100644
--- a/src/spec/controllers/deployables_controller_spec.rb
+++ b/src/spec/controllers/deployables_controller_spec.rb
@@ -37,7 +37,7 @@ describe DeployablesController do
hw_profile = FactoryGirl.create(:front_hwp1)
catalog = FactoryGirl.create(:catalog)
mock_warden(@admin)
- post(:create, :create_from_image => @image.id, :hardware_profile =>
hw_profile.id, :catalog_id => catalog.id)
+ post(:create, :create_from_image => @image.id, :deployable => {:name =>
@image.name}, :hardware_profile => hw_profile.id, :catalog_id => catalog.id)
response.should redirect_to(catalog_deployables_url(catalog.id))
end
diff --git a/src/spec/models/deployable_spec.rb b/src/spec/models/deployable_spec.rb
index 72f7b26..9f7cbaf 100644
--- a/src/spec/models/deployable_spec.rb
+++ b/src/spec/models/deployable_spec.rb
@@ -22,11 +22,10 @@ describe Deployable do
Aeolus::Image::Warehouse::Image.stub(:find).and_return(image)
hw_profile = FactoryGirl.build(:front_hwp1)
deployable = FactoryGirl.build(:deployable)
- deployable.set_from_image(image, hw_profile)
- deployable.xml_filename.should eql(image.name)
- deployable.name.should eql(image.name)
+ deployable.set_from_image(image, deployable.name, hw_profile)
+ deployable.xml_filename.should eql(deployable.name)
doc = Nokogiri::XML deployable.xml
- doc.at_xpath('/deployable')[:name].should eql(image.name)
+ doc.at_xpath('/deployable')[:name].should eql(deployable.name)
doc.at_xpath('/deployable/assemblies/assembly')[:hwp].should
eql(hw_profile.name)
doc.at_xpath('/deployable/assemblies/assembly')[:name].should
eql(image.name)
doc.at_xpath('/deployable/assemblies/assembly/image')[:id].should
eql(image.uuid)
ACK, only 2 tiny nits inline