From: Tomas Sedovic tsedovic@redhat.com
This fixes redmine #412
The new template page now has an option to automatically create a new deployable containing the template. --- .../image_factory/templates_controller.rb | 3 +++ src/app/views/image_factory/templates/new.haml | 2 ++ src/features/template.feature | 13 +++++++++++++ 3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb index 06469e9..00dbf55 100644 --- a/src/app/controllers/image_factory/templates_controller.rb +++ b/src/app/controllers/image_factory/templates_controller.rb @@ -77,6 +77,9 @@ class ImageFactory::TemplatesController < ApplicationController @tpl.assign_owner_roles(current_user) flash[:notice] = "Template saved." @tpl.set_complete + if params[:create_deployable] + @tpl.assemblies.first.deployables.create!({ :name => @tpl.name }) + end redirect_to image_factory_templates_path else @repository_manager = RepositoryManager.new(:repositories => params[:repository] || @tpl.platform) diff --git a/src/app/views/image_factory/templates/new.haml b/src/app/views/image_factory/templates/new.haml index 9ba76fa..2dbac5b 100644 --- a/src/app/views/image_factory/templates/new.haml +++ b/src/app/views/image_factory/templates/new.haml @@ -4,5 +4,7 @@ /- form_for @tpl, :url => image_factory_templates_path do |f| - form_tag do = render :partial => 'form' + = check_box_tag :create_deployable + = label_tag :create_deployable, "Create Deployable for this template" = restful_submit_tag "Save", 'create', image_factory_templates_path, 'POST', :class => "formbutton" = link_to 'Cancel', image_factory_templates_path, :class => 'button formbutton' diff --git a/src/features/template.feature b/src/features/template.feature index 3ffea33..fa6b56d 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -213,3 +213,16 @@ Feature: Manage Templates And I press "Delete" Then I should be on the image factory templates page And I should see "Other" + + Scenario: Create Assembly and Deployable + Given I am on the new image factory template page + When I fill in the following: + | tpl_name | mocktemplate | + | tpl_platform | fedora13 | + | tpl_summary | mockdesc | + And I check "create_deployable" + And I press "Save" + Then I should be on the image factory templates page + And I should see "mocktemplate" + When I go to the image factory deployables page + And I should see "mocktemplate"
ACK with one inline note.
On 04/21/2011 01:22 PM, tsedovic@redhat.com wrote:
From: Tomas Sedovictsedovic@redhat.com
This fixes redmine #412
The new template page now has an option to automatically create a new deployable containing the template.
.../image_factory/templates_controller.rb | 3 +++ src/app/views/image_factory/templates/new.haml | 2 ++ src/features/template.feature | 13 +++++++++++++ 3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/image_factory/templates_controller.rb b/src/app/controllers/image_factory/templates_controller.rb index 06469e9..00dbf55 100644 --- a/src/app/controllers/image_factory/templates_controller.rb +++ b/src/app/controllers/image_factory/templates_controller.rb @@ -77,6 +77,9 @@ class ImageFactory::TemplatesController< ApplicationController @tpl.assign_owner_roles(current_user) flash[:notice] = "Template saved." @tpl.set_complete
if params[:create_deployable]
@tpl.assemblies.first.deployables.create!({ :name => @tpl.name })
It's better to use: Deployable.create!(:name => @tpl.name, :assemblies => @tpl.assemblies)
then no need to edit this piece of code when we drop "one template in assembly" restriction or "autocreated assembly" restriction
end redirect_to image_factory_templates_path else @repository_manager = RepositoryManager.new(:repositories => params[:repository] || @tpl.platform)
diff --git a/src/app/views/image_factory/templates/new.haml b/src/app/views/image_factory/templates/new.haml index 9ba76fa..2dbac5b 100644 --- a/src/app/views/image_factory/templates/new.haml +++ b/src/app/views/image_factory/templates/new.haml @@ -4,5 +4,7 @@ /- form_for @tpl, :url => image_factory_templates_path do |f| - form_tag do = render :partial => 'form'
- = check_box_tag :create_deployable
- = label_tag :create_deployable, "Create Deployable for this template" = restful_submit_tag "Save", 'create', image_factory_templates_path, 'POST', :class => "formbutton" = link_to 'Cancel', image_factory_templates_path, :class => 'button formbutton'
diff --git a/src/features/template.feature b/src/features/template.feature index 3ffea33..fa6b56d 100644 --- a/src/features/template.feature +++ b/src/features/template.feature @@ -213,3 +213,16 @@ Feature: Manage Templates And I press "Delete" Then I should be on the image factory templates page And I should see "Other"
- Scenario: Create Assembly and Deployable
Given I am on the new image factory template page
When I fill in the following:
| tpl_name | mocktemplate |
| tpl_platform | fedora13 |
| tpl_summary | mockdesc |
And I check "create_deployable"
And I press "Save"
Then I should be on the image factory templates page
And I should see "mocktemplate"
When I go to the image factory deployables page
And I should see "mocktemplate"
aeolus-devel@lists.fedorahosted.org