Hi Martyn,
Overall it looks good, but I've noticed a few problems. The first one is
with editing the created HWPs:
1. Click New Hardware Profile
2. Enter fixed values for Name, Memory and CPU
3. Enter "i386" as a value for Architecture
4. Enter "i386, x64" into the Enum Entries for Architecture
5. Press Save
6. Select the HWP you just created
7. Press Edit
8. Don't change anything, press Save
Expected: the operation succeeds, followed by a redirect to the HWP show
page.
Actual: the following error message is displayed:
undefined method `delete!' for #
The same thing happens when you do change the attributes.
There are two more inline.
Thanks,
Thomas
On 01/17/2011 03:08 PM, [email protected] wrote:
> From: Martyn Taylor<[email protected]>
>
> This patch allows users to create Hardware Profiles based on the new matching
> model.
>
> N.B. Building the Hardware Profile in the HardwareProfile controller, is not
> very RESTy. This was a decision made to simplify the UI slightly, and create
> HardareProfile with breaking any validation.
Please wrap git comments to 80 lines or so. It makes it hard to read
`git log` in shell otherwise.
> ---
> .../admin/hardware_profiles_controller.rb | 135
> +++++++++++++++++++-
> src/app/models/hardware_profile.rb | 13 ++-
> src/app/models/hardware_profile_property.rb | 2 +-
> src/app/models/property_enum_entry.rb | 3 +
> src/app/stylesheets/newui.scss | 5 +
> src/app/views/admin/hardware_profiles/_form.haml | 28 ++++
> src/app/views/admin/hardware_profiles/_list.haml | 35 +++---
> .../_matching_provider_hardware_profiles.haml | 8 +-
> .../views/admin/hardware_profiles/_properties.haml | 1 +
> src/app/views/admin/hardware_profiles/create.haml | 6 +
> src/app/views/admin/hardware_profiles/edit.haml | 7 +
> src/app/views/admin/hardware_profiles/new.haml | 7 +
> src/app/views/admin/provider_accounts/new.haml | 2 +-
> src/config/routes.rb | 2 +
> .../20090804135630_create_hardware_profiles.rb | 2 +-
> src/features/hardware_profile.feature | 60 +++++++++
> .../step_definitions/hardware_profile_steps.rb | 17 +++
> src/features/support/paths.rb | 6 +
> 18 files changed, 310 insertions(+), 29 deletions(-)
> create mode 100644 src/app/views/admin/hardware_profiles/_form.haml
> create mode 100644 src/app/views/admin/hardware_profiles/create.haml
> create mode 100644 src/app/views/admin/hardware_profiles/edit.haml
> create mode 100644 src/app/views/admin/hardware_profiles/new.haml
>
> diff --git a/src/app/controllers/admin/hardware_profiles_controller.rb
> b/src/app/controllers/admin/hardware_profiles_controller.rb
> index 92edab0..f2b7e0f 100644
> --- a/src/app/controllers/admin/hardware_profiles_controller.rb
> +++ b/src/app/controllers/admin/hardware_profiles_controller.rb
> @@ -1,7 +1,10 @@
> class Admin::HardwareProfilesController< ApplicationController
> before_filter :require_user
> before_filter :set_params_and_header, :only => [:index, :show]
> - before_filter :load_hardware_profiles, :only => [:show]
> + before_filter :load_hardware_profiles, :only => [:index, :show]
> + before_filter :load_hardware_profile, :only => [:show]
> + before_filter :setup_new_hardware_profile, :only => [:new]
> + before_filter :setup_hardware_profile, :only => [:new, :create, :edit,
> :update]
>
> def index
> @params = params
> @@ -39,7 +42,77 @@ class Admin::HardwareProfilesController<
> ApplicationController
> end
> end
>
> + def new
> + end
> +
> + def create
> + build_hardware_profile(params[:hardware_profile])
> + if params[:commit] == 'Save'
> + if @hardware_profile.save!
> + redirect_to admin_hardware_profiles_path
> + else
> + params.delete :commit
> + render :action => 'create'
> + end
> + else
> + matching_provider_hardware_profiles
> + render :action => 'new'
> + end
> + end
> +
> + def delete
> + end
> +
> + def edit
> + unless @hardware_profile
> + @hardware_profile = HardwareProfile.find(params[:id])
> + end
> + matching_provider_hardware_profiles
> + end
> +
> + def update
> + if params[:commit] == "Reset"
> + redirect_to edit_admin_hardware_profile_url(@hardware_profile) and
> return
> + end
> +
> + if params[:id]
> + @hardware_profile = HardwareProfile.find(params[:id])
> + build_hardware_profile(params[:hardware_profile])
> + end
> +
> + if params[:commit] == "Check Matches"
> + matching_provider_hardware_profiles
> + render :edit and return
> + end
> +
> + unless @hardware_profile.save!
> + render :action => 'edit' and return
> + else
> + flash[:notice] = "Hardware Profile updated!"
> + redirect_to admin_hardware_profiles_path
> + end
> + end
> +
> + def multi_destroy
> + HardwareProfile.destroy(params[:hardware_profile_selected])
> + redirect_to admin_hardware_profiles_path
> + end
> +
> private
> + def setup_new_hardware_profile
> + if params[:hardware_profile]
> + begin
> + @hardware_profile =
> HardwareProfile.new(remove_irrelevant_params(params[:hardware_profile]))
> + end
> + else
> + @hardware_profile = HardwareProfile.new(:memory =>
> HardwareProfileProperty.new(:name => "memory", :unit => "MB"),
> + :cpu =>
> HardwareProfileProperty.new(:name => "cpu", :unit => "count"),
> + :storage =>
> HardwareProfileProperty.new(:name => "storage", :unit => "GB"),
> + :architecture =>
> HardwareProfileProperty.new(:name => "architecture", :unit => "label"))
> + end
> + matching_provider_hardware_profiles
> + end
> +
> def properties
> @properties_header = [
> { :name => "Name", :sort_attr => :name},
> @@ -63,8 +136,26 @@ class Admin::HardwareProfilesController<
> ApplicationController
> { :name => "Storage", :sort_attr => :storage },
> { :name => "Virtual CPU", :sort_attr => :cpus}
> ]
> - @matching_hwps = HardwareProfile.all(:include =>
> "aggregator_hardware_profiles",
> - :conditions =>
> {:hardware_profile_map => { :aggregator_hardware_profile_id => params[:id]
> }})
> +
> + begin
> + @matching_hwps = HardwareProfile.matching_hwps(@hardware_profile).map
> { |hwp| hwp[:hardware_profile] }
> + rescue
> + @matching_hwps = []
> + end
> + end
> +
> + def setup_hardware_profile
> + @tab_captions = ['Matched Provider Hardware Profiles']
> + @details_tab = 'matching_provider_hardware_profiles'
> + @url_params = params
> + @header = [
> + { :name => "Name", :sort_attr => :name},
> + { :name => "Unit", :sort_attr => :unit},
> + { :name => "Kind", :sort_attr => :kind },
> + { :name => "Value (Default)", :sort_attr => :value},
> + { :name => "Enum Entries", :sort_attr => :false },
> + { :name => "Range First", :sort_attr => :range_first},
> + { :name => "Range Last", :sort_attr => :range_last }]
> end
>
> def set_params_and_header
> @@ -81,4 +172,42 @@ class Admin::HardwareProfilesController<
> ApplicationController
> def load_hardware_profiles
> @hardware_profiles = HardwareProfile.all(:conditions => 'provider_id
> IS NULL')
> end
> +
> + def load_hardware_profile
> + @hardware_profile = HardwareProfile.find(params[:id])
> + end
> +
> + def build_hardware_profile(params)
> + hwpps = [:memory_attributes, :cpu_attributes, :storage_attributes,
> :architecture_attributes]
> + enum_values = {}
> + hwpps.each do |attr|
> + unless params[attr][:kind] == "range"
> + params[attr].delete(:range_first)
> + params[attr].delete(:range_last)
> + end
> +
> + unless params[attr][:kind] == "enum"
> + params[attr].delete(:enum)
> + else
> + enum_values[params[attr][:name]] =
> params[attr][:property_enum_entries].split(%r{,\s*})
> + end
> + params[attr].delete(:property_enum_entries)
> + end
> +
> + @hardware_profile.nil? ? @hardware_profile = HardwareProfile.new(params)
> : @hardware_profile.update_attributes(params)
> + @hardware_profile.save!
> +
> + # Set Property Enum Entries on enum types
> + begin
> + [@hardware_profile.memory, @hardware_profile.cpu,
> @hardware_profile.architecture, @hardware_profile.storage].each do |hwpp|
> + if hwpp.kind == "enum"
> + hwpp.property_enum_entries = enum_values[hwpp.name].map { |value|
> PropertyEnumEntry.new(:value => value) }
> + end
> + end
> + @hardware_profile.save!
> + rescue => e
> + @hardware_profile.delete!
> + raise e
> + end
> + end
> end
> diff --git a/src/app/models/hardware_profile.rb
> b/src/app/models/hardware_profile.rb
> index 5e6e9e8..22dc5c4 100644
> --- a/src/app/models/hardware_profile.rb
> +++ b/src/app/models/hardware_profile.rb
> @@ -41,13 +41,18 @@ class HardwareProfile< ActiveRecord::Base
>
> belongs_to :memory, :class_name => "HardwareProfileProperty",
> :dependent => :destroy
> +
> belongs_to :storage, :class_name => "HardwareProfileProperty",
> :dependent => :destroy
> +
> belongs_to :cpu, :class_name => "HardwareProfileProperty",
> :dependent => :destroy
> +
> belongs_to :architecture, :class_name => "HardwareProfileProperty",
> :dependent => :destroy
>
> + accepts_nested_attributes_for :memory, :cpu, :storage, :architecture
> +
> has_and_belongs_to_many :aggregator_hardware_profiles,
> :class_name => "HardwareProfile",
> :join_table => "hardware_profile_map",
> @@ -60,8 +65,8 @@ class HardwareProfile< ActiveRecord::Base
> :foreign_key => "aggregator_hardware_profile_id",
> :association_foreign_key =>
> "provider_hardware_profile_id"
>
> - validates_presence_of :external_key
> - validates_uniqueness_of :external_key, :scope => [:provider_id]
> + #validates_presence_of :external_key
> + #validates_uniqueness_of :external_key, :scope => [:provider_id]
>
> validates_presence_of :name
> validates_uniqueness_of :name, :scope => [:provider_id]
> @@ -79,8 +84,8 @@ class HardwareProfile< ActiveRecord::Base
> def validate
> if provider.nil?
> if !aggregator_hardware_profiles.empty?
> - errors.add(:aggregator_hardware_profiles,
> - "Aggregator profiles only allowed for provider profiles")
> + #errors.add(:aggregator_hardware_profiles,
> + #"Aggregator profiles only allowed for provider profiles")
> end
> else
> if !provider_hardware_profiles.empty?
> diff --git a/src/app/models/hardware_profile_property.rb
> b/src/app/models/hardware_profile_property.rb
> index 46e4b8e..3f6bdfe 100644
> --- a/src/app/models/hardware_profile_property.rb
> +++ b/src/app/models/hardware_profile_property.rb
> @@ -101,7 +101,7 @@ class HardwareProfileProperty< ActiveRecord::Base
> def to_s
> case kind
> when FIXED
> - value
> + value.to_s
> when RANGE
> range_first.to_s + " - " + range_last.to_s
> when ENUM
> diff --git a/src/app/models/property_enum_entry.rb
> b/src/app/models/property_enum_entry.rb
> index ff497ef..81bb67e 100644
> --- a/src/app/models/property_enum_entry.rb
> +++ b/src/app/models/property_enum_entry.rb
> @@ -32,4 +32,7 @@ class PropertyEnumEntry< ActiveRecord::Base
> HardwareProfileProperty::STORAGE or
> p.hardware_profile_property.name ==
> HardwareProfileProperty::CPU }
> + def to_s
> + value.to_s + ", "
> + end
> end
> diff --git a/src/app/stylesheets/newui.scss b/src/app/stylesheets/newui.scss
> index 513d510..d0fbcc9 100644
> --- a/src/app/stylesheets/newui.scss
> +++ b/src/app/stylesheets/newui.scss
> @@ -1371,6 +1371,11 @@ $content-left: 180px;
> float: left;
> }
>
> +#list {
> + float: left;
> + width: 100%;
> +}
> +
> #details-view {
> border: 1px solid;
> position: absolute;
> diff --git a/src/app/views/admin/hardware_profiles/_form.haml
> b/src/app/views/admin/hardware_profiles/_form.haml
> new file mode 100644
> index 0000000..65278f2
> --- /dev/null
> +++ b/src/app/views/admin/hardware_profiles/_form.haml
> @@ -0,0 +1,28 @@
> +=hwp_form.label :name
> +=hwp_form.text_field :name
> +%table
> + = sortable_table_header @header
> + - [:memory, :cpu, :storage, :architecture].each do |type|
> + - hwp_form.fields_for type do |hwpp_form|
> + %tr
> + %td
> + =hwpp_form.text_field(:name, :readonly => "readonly")
> + %td
> + =hwpp_form.text_field(:unit, :size => 5, :readonly => "readonly")
> + %td
> + -unless type == :architecture
> + =hwpp_form.select("kind", ["fixed", "range", "enum"], {})
> + -else
> + =hwpp_form.select("kind", ["fixed", "enum"], {})
> + %td
> + =hwpp_form.text_field(:value)
> + %td
> + =hwpp_form.text_field(:property_enum_entries)
> + %td
> + -unless type == :architecture
> + =hwpp_form.text_field(:range_first)
> + %td
> + -unless type == :architecture
> + =hwpp_form.text_field(:range_last)
> += hwp_form.submit 'Check Matches', :class => "submit formbutton"
> += hwp_form.submit 'Save', :class => 'submit formbutton'
> \ No newline at end of file
> diff --git a/src/app/views/admin/hardware_profiles/_list.haml
> b/src/app/views/admin/hardware_profiles/_list.haml
> index 1001db3..e2f344e 100644
> --- a/src/app/views/admin/hardware_profiles/_list.haml
> +++ b/src/app/views/admin/hardware_profiles/_list.haml
> @@ -1,5 +1,7 @@
> - form_tag do
> #object-actions
> + = link_to "New Hardware Profile", new_admin_hardware_profile_path,
> :class => 'button'
> + = restful_submit_tag "Delete", "destroy",
> multi_destroy_admin_hardware_profiles_path, "DELETE", :id => 'delete_button'
>
> #selections
> %p
> @@ -8,19 +10,20 @@
> %span> ,
> = link_to "None", @url_params.merge(:select => 'none')
>
> -%table
> - = sortable_table_header @header
> - - @hardware_profiles.each do |hwp|
> - %tr
> - %td
> - - selected = @url_params[:select] == 'all'
> - = check_box(:pool, "selected[#{hwp.id}]", :checked => selected)
> - = link_to hwp.name, admin_hardware_profile_path(hwp)
> - %td
> - =hwp.architecture.to_s
> - %td
> - =hwp.memory.to_s
> - %td
> - =hwp.storage.to_s
> - %td
> - =hwp.cpu.to_s
> + #list
> + %table
> + = sortable_table_header @header
> + - @hardware_profiles.each do |hwp|
> + %tr
> + %td
> + - selected = @url_params[:select] == 'all'
> + %input{:name => "hardware_profile_selected[]", :type =>
> "checkbox", :value => hwp.id, :id => "hardware_profile_checkbox_#{hwp.id}",
> :checked => selected }
> + = link_to hwp.name, admin_hardware_profile_path(hwp)
> + %td
> + =hwp.architecture.to_s
> + %td
> + =hwp.memory.to_s
> + %td
> + =hwp.storage.to_s
> + %td
> + =hwp.cpu.to_s
> diff --git
> a/src/app/views/admin/hardware_profiles/_matching_provider_hardware_profiles.haml
>
> b/src/app/views/admin/hardware_profiles/_matching_provider_hardware_profiles.haml
> index cfbb856..0f4ba7b 100644
> ---
> a/src/app/views/admin/hardware_profiles/_matching_provider_hardware_profiles.haml
> +++
> b/src/app/views/admin/hardware_profiles/_matching_provider_hardware_profiles.haml
> @@ -1,11 +1,13 @@
> -%h3
> - = @hardware_profile.name
> +- if @hardware_profile
> + %h3
> + =@hardware_profile.name
> %table
> = sortable_table_header @provider_hwps_header
> - @matching_hwps.each do |hwp|
> %tr
> %td
> - = link_to hwp.provider.name, admin_provider_path(hwp.provider)
> + - if hwp.provider
> + = link_to hwp.provider.name, admin_provider_path(hwp.provider)
> %td
> = link_to hwp.name, admin_hardware_profile_path(hwp)
> %td
> diff --git a/src/app/views/admin/hardware_profiles/_properties.haml
> b/src/app/views/admin/hardware_profiles/_properties.haml
> index 590edc5..bc91219 100644
> --- a/src/app/views/admin/hardware_profiles/_properties.haml
> +++ b/src/app/views/admin/hardware_profiles/_properties.haml
> @@ -1,5 +1,6 @@
> %h3
> = @hardware_profile.name + "(" + (@hardware_profile.provider_id.nil? ?
> "Front End" : "Provider" ) + ")"
> += link_to 'Edit', edit_admin_hardware_profile_path(@hardware_profile),
> :class => 'button'
> %table
> = sortable_table_header @properties_header
> - @hwp_properties.each do |hwpp|
> diff --git a/src/app/views/admin/hardware_profiles/create.haml
> b/src/app/views/admin/hardware_profiles/create.haml
> new file mode 100644
> index 0000000..c26bbe9
> --- /dev/null
> +++ b/src/app/views/admin/hardware_profiles/create.haml
> @@ -0,0 +1,6 @@
> +%h3
> + Check Matching Hardware Profiles
> +- content_for :list do
> + = render :partial => "form"
> +- content_for :details do
> + = render :partial => 'layouts/details_pane'
> \ No newline at end of file
> diff --git a/src/app/views/admin/hardware_profiles/edit.haml
> b/src/app/views/admin/hardware_profiles/edit.haml
> new file mode 100644
> index 0000000..e32eebd
> --- /dev/null
> +++ b/src/app/views/admin/hardware_profiles/edit.haml
> @@ -0,0 +1,7 @@
> +- content_for :list do
> + %h3
> + Edit Hardware Profile
> + -form_for @hardware_profile, :url =>
> admin_hardware_profile_path(@hardware_profile), :html => { :multipart =>
> true } do |hwp_form|
> + = render :partial => "form", :locals => { :hwp_form => hwp_form }
> +- content_for :details do
> + = render :partial => 'layouts/details_pane'
> diff --git a/src/app/views/admin/hardware_profiles/new.haml
> b/src/app/views/admin/hardware_profiles/new.haml
> new file mode 100644
> index 0000000..3355c87
> --- /dev/null
> +++ b/src/app/views/admin/hardware_profiles/new.haml
> @@ -0,0 +1,7 @@
> +- content_for :list do
> + %h3
> + New Hardware Profile
> + -form_for @hardware_profile, :url => admin_hardware_profiles_path, :html
> => { :multipart => true } do |hwp_form|
> + = render :partial => "form", :locals => { :hwp_form => hwp_form }
> +- content_for :details do
> + = render :partial => 'layouts/details_pane'
> \ No newline at end of file
> diff --git a/src/app/views/admin/provider_accounts/new.haml
> b/src/app/views/admin/provider_accounts/new.haml
> index e567bce..55e469c 100644
> --- a/src/app/views/admin/provider_accounts/new.haml
> +++ b/src/app/views/admin/provider_accounts/new.haml
> @@ -13,4 +13,4 @@
> %p.requirement
> %span.required *
> \-
> - = t('cloud_accounts.new.required_field')
> + = t('cloud_accounts.new.required_field')
> \ No newline at end of file
> diff --git a/src/config/routes.rb b/src/config/routes.rb
> index ad9fb67..ba5109e 100644
> --- a/src/config/routes.rb
> +++ b/src/config/routes.rb
> @@ -49,6 +49,8 @@ ActionController::Routing::Routes.draw do |map|
>
> map.namespace 'admin' do |r|
> r.resources :hardware_profiles, :realms
Remove hardware_profiles frome this line. You have them mapped below.
Keeping HWP here actually prevents the multi_destroy route from working.
> + r.resources :hardware_profiles, :collection => { :multi_destroy =>
> :delete }
> + r.resources :pool_families, :realms
Remove this ^^^ line. Realms are mapped above and pool_families below.
> r.resources :providers, :collection => { :multi_destroy => :delete }
> r.resources :users, :collection => { :multi_destroy => :delete }
> r.resources :provider_accounts, :collection => { :multi_destroy =>
> :delete }
> diff --git a/src/db/migrate/20090804135630_create_hardware_profiles.rb
> b/src/db/migrate/20090804135630_create_hardware_profiles.rb
> index 5ad0435..ec4a50f 100644
> --- a/src/db/migrate/20090804135630_create_hardware_profiles.rb
> +++ b/src/db/migrate/20090804135630_create_hardware_profiles.rb
> @@ -40,7 +40,7 @@ class CreateHardwareProfiles< ActiveRecord::Migration
> end
>
> create_table :hardware_profiles do |t|
> - t.string :external_key, :null => false
> + t.string :external_key
> t.string :name, :null => false, :limit => 1024
> t.integer :memory_id
> t.integer :storage_id
> diff --git a/src/features/hardware_profile.feature
> b/src/features/hardware_profile.feature
> index 5f63c96..9c0572d 100644
> --- a/src/features/hardware_profile.feature
> +++ b/src/features/hardware_profile.feature
> @@ -77,3 +77,63 @@ Feature: Manage Pools
> Then I should see "m1-small"
> And I should not see "m1-large"
> And I should not see "m1-xlarge"
> +
> + Scenario: Create a new Hardware Profile
> + Given I am an authorised user
> + And I am on the hardware profiles page
> + When I follow "New Hardware Profile"
> + Then I should be on the new hardware profile page
> + When I fill in "name" with "Test Hardware Profile"
> + And I enter the following details for the Hardware Profile Properties
> + | name | kind | range_first | range_last |
> property_enum_entries | value | unit |
> + | memory | fixed | | |
> | 1740 | MB |
> + | cpu | range | 1 | 4 |
> | 2 | count |
> + | storage | range | 250 | 500 |
> | 300 | GB |
> + | architecture | enum | | | i386, x86_64
> | i386 | label |
> + And I press "Save"
> + Then I should be on the hardware profiles page
> + And I should see the following:
> + | Test Hardware Profile | 1740 | 1 - 4 | 250 - 500 | i386, x86_64 |
> +
> + Scenario: Check New Hardware Profile matching Provider Hardware Profiles
> + Given I am an authorised user
> + And there are the following provider hardware profiles:
> + | name | memory | cpu |storage | architecture |
> + | m1-small | 1740 | 1 | 250 | i386 |
> + | m1-medium | 1740 | 2 | 500 | i386 |
> + | m1-large | 2048 | 4 | 850 | x86_64 |
> + And I am on the new hardware profile page
> + When I fill in "name" with "Test Hardware Profile"
> + And I enter the following details for the Hardware Profile Properties
> + | name | kind | range_first | range_last |
> property_enum_entries | value | unit |
> + | memory | fixed | | |
> | 1740 | MB |
> + | cpu | range | 1 | 4 |
> | 2 | count |
> + | storage | range | 250 | 500 |
> | 300 | GB |
> + | architecture | enum | | | i386, x86_64
> | i386 | label |
> + And I press "Check Matches"
> + Then I should see the following:
> + | Name | Memory | CPU | Storage | Architecture |
> + | m1-small | 1740 | 1 | 250 | i386 |
> + | m1-medium | 1740 | 2 | 500 | i386 |
> +
> + Scenario: Update a HardwareProfile
> + Given I am an authorised user
> + And there are the following aggregator hardware profiles:
> + | name | memory | cpu |storage | architecture |
> + | m1-small | 1740 | 2 | 160 | i386 |
> + And I am on the hardware profiles page
> + When I follow "m1-small"
> + Then I should see "Properties"
> + When I follow "edit"
> + Then I should be on the edit hardware profiles page
> + When I enter the following details for the Hardware Profile Properties
> + | name | kind | range_first | range_last |
> property_enum_entries | value |
> + | memory | fixed | | |
> | 1740 |
> + | cpu | range | 1 | 4 |
> | 1 |
> + | storage | range | 250 | 500 |
> | 300 |
> + | architecture | enum | | | i386, x86_64
> | i386 |
> + And I press "Save"
> + Then I should be on the hardware profiles page
> + Then I should see the following:
> + | Name | Memory | CPU | Storage | Architecture |
> + | m1-small | 1740 | 1 - 4 | 250 - 500 | i386, x86_64 |
> diff --git a/src/features/step_definitions/hardware_profile_steps.rb
> b/src/features/step_definitions/hardware_profile_steps.rb
> index d29d136..9a8ecbf 100644
> --- a/src/features/step_definitions/hardware_profile_steps.rb
> +++ b/src/features/step_definitions/hardware_profile_steps.rb
> @@ -19,4 +19,21 @@ def create_hwp(hash, provider=nil)
> cpu = Factory(:mock_hwp1_cpu, :value => hash[:cpu])
> arch = Factory(:mock_hwp1_arch, :value => hash[:architecture])
> Factory(:mock_hwp1, :name => hash[:name], :memory => memory, :cpu =>
> cpu, :storage => storage, :architecture => arch, :provider => provider)
> +end
> +
> +When /^I enter the following details for the Hardware Profile Properties$/
> do |table|
> + table.hashes.each do |hash|
> + hash.each_pair do |key, value|
> + unless (hash[:name] == "architecture"&& (key == "range_first" || key
> == "range_last")) || key == "name"
> + When "I fill in \"#{"hardware_profile_" + hash[:name] +
> "_attributes_" + key}\" with \"#{value}\""
> + end
> + end
> + end
> +end
> +
> +Given /^there are the following provider hardware profiles:$/ do |table|
> + provider = Factory :mock_provider
> + table.hashes.each do |hash|
> + create_hwp(hash, provider)
> + end
> end
> \ No newline at end of file
> diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
> index c0c77dc..4bc7ba4 100644
> --- a/src/features/support/paths.rb
> +++ b/src/features/support/paths.rb
> @@ -98,6 +98,12 @@ module NavigationHelpers
> when /the hardware profiles page/
> url_for admin_hardware_profiles_path
>
> + when /the new hardware profile page/
> + url_for new_admin_hardware_profile_path
> +
> + when /the edit hardware profiles page/
> + url_for :action => 'edit', :controller => 'hardware_profiles',
> :only_path => true
> +
> when /^(.*)'s provider account page$/
> admin_provider_account_path(CloudAccount.find_by_label($1))
>
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel