On Thu, 2010-09-16 at 15:57 +0200, [email protected] wrote:
> From: Jan Provaznik <[email protected]>
> 
> ---
> src/app/models/template.rb | 6 +-
> src/features/step_definitions/template_steps.rb | 43 +++++++
> src/features/support/custom.rb | 10 ++
> src/features/support/paths.rb | 9 ++
> src/features/template.feature | 37 ++++++
> src/spec/controllers/templates_controller_spec.rb | 46 ++++----
> src/spec/factories/image.rb | 10 +-
> src/spec/factories/instance.rb | 2 +-
> src/spec/factories/template.rb | 21 ++++
> src/spec/fixtures/packagegroups.json | 54 +++++++++
> src/spec/fixtures/packages.json | 128 +++++++++++++++++++++
> src/spec/fixtures/repositories.json | 19 +++
> src/spec/models/image_spec.rb | 52 ++-------
> src/spec/models/instance_spec.rb | 6 +-
> src/spec/models/template_spec.rb | 19 +++
> src/spec/utils/repository_manager.rb | 45 +++++++
> 16 files changed, 426 insertions(+), 81 deletions(-)
> create mode 100644 src/features/step_definitions/template_steps.rb
> create mode 100644 src/features/template.feature
> create mode 100644 src/spec/factories/template.rb
> create mode 100644 src/spec/fixtures/packagegroups.json
> create mode 100644 src/spec/fixtures/packages.json
> create mode 100644 src/spec/fixtures/repositories.json
> create mode 100644 src/spec/models/template_spec.rb
> create mode 100644 src/spec/utils/repository_manager.rb
> 
> diff --git a/src/app/models/template.rb b/src/app/models/template.rb
> index 6469b04..3336081 100644
> --- a/src/app/models/template.rb
> +++ b/src/app/models/template.rb
> @@ -3,13 +3,13 @@ require 'typhoeus'
> 
> class Template < ActiveRecord::Base
> has_many :images, :dependent => :destroy
> - before_validation :update_attrs
> + before_save :update_attrs
> 
> WAREHOUSE_CONFIG =
> YAML.load_file("#{RAILS_ROOT}/config/image_warehouse.yml")
> 
> - validates_presence_of :uuid
> + #validates_presence_of :uuid
> #validates_presence_of :name
> - validates_uniqueness_of :uuid
> + #validates_uniqueness_of :uuid

Why are these two ^ commented out?  I think we need these don't we?

> 
> def update_xml_attributes!(opts = {})
> doc = xml
> diff --git a/src/features/step_definitions/template_steps.rb
> b/src/features/step_definitions/template_steps.rb
> new file mode 100644
> index 0000000..c708fce
> --- /dev/null
> +++ b/src/features/step_definitions/template_steps.rb
> @@ -0,0 +1,43 @@
> +Given /^There is a mock pulp repository$/ do
> + dir = File.join(Rails.root, 'spec', 'fixtures')
> + hydra = Typhoeus::Hydra.hydra
> + hydra.stub(:get, "http://pulptest/repositories/";).and_return(
> + Typhoeus::Response.new(:code => 200,
> + :body => File.read(File.join(dir, 'repositories.json'))))
> + hydra.stub(:get,
> "http://pulptest/repositories/jboss/packagegroups/";).and_return(
> + Typhoeus::Response.new(:code => 200,
> + :body => File.read(File.join(dir, 'packagegroups.json'))))
> + hydra.stub(:get,
> "http://pulptest/repositories/jboss/packages/";).and_return(
> + Typhoeus::Response.new(:code => 200,
> + :body => File.read(File.join(dir, 'packages.json'))))
> +
> +end
> +
> +Given /^There is a "([^"]*)" template$/ do |name|
> + @template = Template.new
> + @template.xml.name = name
> + @template.save_xml!
> +end
> +
> +Given /^there is a package group$/ do
> + RepositoryManager.new.all_groups.should have_at_least(1).item
> +end
> +
> +Given /^no package is selected$/ do
> + @template.xml.packages = []
> +end
> +
> +Given /^there is one selected package$/ do
> + pkg = RepositoryManager.new.all_packages.first
> + @template.xml.packages = []
> + @template.xml.add_package(pkg['name'], nil)
> + @template.save_xml!
> +end
> +
> +Given /^I jump on the "([^"]*)" template software page$/ do |name|

s/jump/am ^

> + visit url_for :action => 'software', :controller => 'templates', :id
> => @template
> +end
> +
> +Then /^I should have a template named "([^"]*)"$/ do |name|
> + Template.first(:order => 'created_at DESC').xml.name.should
> eql(name)
> +end
> diff --git a/src/features/support/custom.rb
> b/src/features/support/custom.rb
> index 73a6300..3adbea3 100644
> --- a/src/features/support/custom.rb
> +++ b/src/features/support/custom.rb
> @@ -44,3 +44,13 @@ CloudAccount.class_eval do
> @key 
> end
> end
> +
> +RepositoryManager.class_eval do
> + def config
> + [{
> + 'baseurl' => 'http://pulptest',
> + 'yumurl' => 'http://pulptest',
> + 'type' => 'pulp',
> + }]
> + end
> +end
> diff --git a/src/features/support/paths.rb
> b/src/features/support/paths.rb
> index 537dd31..6b45674 100644
> --- a/src/features/support/paths.rb
> +++ b/src/features/support/paths.rb
> @@ -65,6 +65,15 @@ module NavigationHelpers
> when /the new permission page/
> url_for :action => 'new', :controller => 'permissions', :only_path =>
> true
> 
> + when /the new template page/
> + url_for :action => 'new', :controller => 'templates', :only_path =>
> true
> +
> + when /the template services page/
> + url_for :action => 'services', :controller =>
> 'templates', :only_path => true
> +
> + when /the template software page/
> + url_for :action => 'software', :controller =>
> 'templates', :only_path => true
> +
> # Add more mappings here.
> # Here is an example that pulls values out of the Regexp:
> #
> diff --git a/src/features/template.feature
> b/src/features/template.feature
> new file mode 100644
> index 0000000..ed4cd68
> --- /dev/null
> +++ b/src/features/template.feature
> @@ -0,0 +1,37 @@
> +Feature: Manage Templates
> + In order to manage my cloud infrastructure
> + As a user
> + I want to manage templates
> +
> + Background:
> + Given I am an authorised user

authorized ^

> + And I am logged in
> + And There is a mock pulp repository
> +
> + Scenario: Add basic info to a new Template
> + Given I am on the homepage
> + When I follow "Create a Template"
> + Then I should be on the new template page
> + And I should see "Create a New Template"
> + When I fill in the following:
> + | xml_name | mocktemplate |
> + | xml_platform | rhel |
> + | xml_description | mockdesc |
> + And I press "Next"
> + Then I should be on the template services page
> + And I should have a template named "mocktemplate"
> +
> + Scenario: Add a package to the template
> + Given There is a "mocktemplate" template
> + And I am on the template software page
> + And there is a package group
> + And no package is selected
> + When I follow "Select" within ".selection_list"
> + Then I should see "Remove" within "#selected_packages"
> +
> + Scenario: Remove a package from the template
> + Given There is a "mocktemplate" template
> + And there is one selected package
> + And I jump on the "mocktemplate" template software page

s/jump/am ^

<snip>


_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to