There was a bug in loading an instance or hw profile so records with id >9 were not showed.
From: Jan Provaznik jprovazn@redhat.com
--- src/features/hardware_profile.feature | 7 +++++++ src/features/instance.feature | 7 +++++++ .../step_definitions/hardware_profile_steps.rb | 12 +++++++++++- src/features/step_definitions/instance_steps.rb | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/src/features/hardware_profile.feature b/src/features/hardware_profile.feature index b727772..db88dcc 100644 --- a/src/features/hardware_profile.feature +++ b/src/features/hardware_profile.feature @@ -77,6 +77,13 @@ Feature: Manage Pools And I should not see "m1-large" And I should not see "m1-xlarge"
+ Scenario: Frontend HWP with correct id is displayed when id is greater than 10 + Given there are 10 hardware profiles + And there is a "mock1" hardware profile + And I am on the the hardware profiles page + When I follow "mock1" + Then I should see "mock1(Front End)" + # Scenario: Create a new Hardware Profile # Given I am an authorised user # And I am on the hardware profiles page diff --git a/src/features/instance.feature b/src/features/instance.feature index 583ee49..4b3b827 100644 --- a/src/features/instance.feature +++ b/src/features/instance.feature @@ -109,3 +109,10 @@ Feature: Mange Instances Then I should not see "mock" And I should see "test" And I should not see "other" + + Scenario: Instance with correct id is displayed when id is greater than 10 + Given there are 10 instances + And there is a "mock1" instance + And I am on the the instances page + When I follow "mock1" + Then I should see "Properties for mock1" diff --git a/src/features/step_definitions/hardware_profile_steps.rb b/src/features/step_definitions/hardware_profile_steps.rb index a7a17bf..0360192 100644 --- a/src/features/step_definitions/hardware_profile_steps.rb +++ b/src/features/step_definitions/hardware_profile_steps.rb @@ -13,6 +13,10 @@ Given /^the Hardare Profile "([^"]*)" has the following Provider Hardware Profil front_end_hwp.save! end
+Given /^there is a "([^"]*)" hardware profile$/ do |arg1| + Factory(:mock_hwp1, :name => arg1) +end + def create_hwp(hash, provider=nil) memory = Factory(:mock_hwp1_memory, :value => hash[:memory]) storage = Factory(:mock_hwp1_storage, :value => hash[:storage]) @@ -36,4 +40,10 @@ Given /^there are the following provider hardware profiles:$/ do |table| table.hashes.each do |hash| create_hwp(hash, provider) end -end \ No newline at end of file +end + +Given /^there are (\d+) hardware profiles$/ do |count| + count.to_i.times.each do |i| + Factory(:mock_hwp1, :name => "hwprofile#{i}") + end +end diff --git a/src/features/step_definitions/instance_steps.rb b/src/features/step_definitions/instance_steps.rb index 956d3de..b8e04e1 100644 --- a/src/features/step_definitions/instance_steps.rb +++ b/src/features/step_definitions/instance_steps.rb @@ -78,3 +78,9 @@ Given /^there are the following instances:$/ do |table| :private_addresses => hash['private_addresses']) end end + +Given /^there are (\d+) instances$/ do |count| + count.to_i.times.each do |i| + Factory :mock_running_instance, :name => "inst#{i}" + end +end
Ack with comments:
In ruby 1.8.6 this the following code causes an error, in 1.8.7 it works fine, but it would be wise to make it compatible with the earlier version:
count.to_i.times.each do |i|
Replace this with:
count.to_i.times do |i|
Works fine, please change this in hardware_profile.steps and instance.steps before pushing,
Thanks
Martyn
----- Original Message ----- From: jprovazn@redhat.com To: aeolus-devel@lists.fedorahosted.org Sent: Monday, 7 February, 2011 4:21:47 PM Subject: [PATCH conductor 1/2] Cuke tests for loading instance and hardware profile with correct id
From: Jan Provaznik jprovazn@redhat.com
--- src/features/hardware_profile.feature | 7 +++++++ src/features/instance.feature | 7 +++++++ .../step_definitions/hardware_profile_steps.rb | 12 +++++++++++- src/features/step_definitions/instance_steps.rb | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/src/features/hardware_profile.feature b/src/features/hardware_profile.feature index b727772..db88dcc 100644 --- a/src/features/hardware_profile.feature +++ b/src/features/hardware_profile.feature @@ -77,6 +77,13 @@ Feature: Manage Pools And I should not see "m1-large" And I should not see "m1-xlarge"
+ Scenario: Frontend HWP with correct id is displayed when id is greater than 10 + Given there are 10 hardware profiles + And there is a "mock1" hardware profile + And I am on the the hardware profiles page + When I follow "mock1" + Then I should see "mock1(Front End)" + # Scenario: Create a new Hardware Profile # Given I am an authorised user # And I am on the hardware profiles page diff --git a/src/features/instance.feature b/src/features/instance.feature index 583ee49..4b3b827 100644 --- a/src/features/instance.feature +++ b/src/features/instance.feature @@ -109,3 +109,10 @@ Feature: Mange Instances Then I should not see "mock" And I should see "test" And I should not see "other" + + Scenario: Instance with correct id is displayed when id is greater than 10 + Given there are 10 instances + And there is a "mock1" instance + And I am on the the instances page + When I follow "mock1" + Then I should see "Properties for mock1" diff --git a/src/features/step_definitions/hardware_profile_steps.rb b/src/features/step_definitions/hardware_profile_steps.rb index a7a17bf..0360192 100644 --- a/src/features/step_definitions/hardware_profile_steps.rb +++ b/src/features/step_definitions/hardware_profile_steps.rb @@ -13,6 +13,10 @@ Given /^the Hardare Profile "([^"]*)" has the following Provider Hardware Profil front_end_hwp.save! end
+Given /^there is a "([^"]*)" hardware profile$/ do |arg1| + Factory(:mock_hwp1, :name => arg1) +end + def create_hwp(hash, provider=nil) memory = Factory(:mock_hwp1_memory, :value => hash[:memory]) storage = Factory(:mock_hwp1_storage, :value => hash[:storage]) @@ -36,4 +40,10 @@ Given /^there are the following provider hardware profiles:$/ do |table| table.hashes.each do |hash| create_hwp(hash, provider) end -end \ No newline at end of file +end + +Given /^there are (\d+) hardware profiles$/ do |count| + count.to_i.times.each do |i| + Factory(:mock_hwp1, :name => "hwprofile#{i}") + end +end diff --git a/src/features/step_definitions/instance_steps.rb b/src/features/step_definitions/instance_steps.rb index 956d3de..b8e04e1 100644 --- a/src/features/step_definitions/instance_steps.rb +++ b/src/features/step_definitions/instance_steps.rb @@ -78,3 +78,9 @@ Given /^there are the following instances:$/ do |table| :private_addresses => hash['private_addresses']) end end + +Given /^there are (\d+) instances$/ do |count| + count.to_i.times.each do |i| + Factory :mock_running_instance, :name => "inst#{i}" + end +end
From: Jan Provaznik jprovazn@redhat.com
When instance or hwp with id >9 was fetched, wrong id was used (only first number of ID was used because of calling 'first' on String object instead on Array. --- .../admin/hardware_profiles_controller.rb | 4 ++-- .../controllers/resources/instances_controller.rb | 2 +- src/app/views/resources/instances/_properties.haml | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/app/controllers/admin/hardware_profiles_controller.rb b/src/app/controllers/admin/hardware_profiles_controller.rb index 4ce9ccb..dcd9b67 100644 --- a/src/app/controllers/admin/hardware_profiles_controller.rb +++ b/src/app/controllers/admin/hardware_profiles_controller.rb @@ -22,7 +22,7 @@ class Admin::HardwareProfilesController < ApplicationController end
def show - @hardware_profile = HardwareProfile.find((params[:id] || []).first) + @hardware_profile = HardwareProfile.find(params[:id].to_a.first) @tab_captions = ['Properties', 'History', 'Matching Provider Hardware Profiles'] @details_tab = params[:details_tab].blank? ? 'properties' : params[:details_tab] case @details_tab @@ -218,4 +218,4 @@ class Admin::HardwareProfilesController < ApplicationController hardwareProfileProperty end
-end \ No newline at end of file +end diff --git a/src/app/controllers/resources/instances_controller.rb b/src/app/controllers/resources/instances_controller.rb index d1be6a5..910c2c1 100644 --- a/src/app/controllers/resources/instances_controller.rb +++ b/src/app/controllers/resources/instances_controller.rb @@ -163,7 +163,7 @@ class Resources::InstancesController < ApplicationController private
def load_instance - @instance = Instance.find((params[:id] || []).first) + @instance = Instance.find(params[:id].to_a.first) require_privilege(Privilege::USE,@instance) end
diff --git a/src/app/views/resources/instances/_properties.haml b/src/app/views/resources/instances/_properties.haml index 5283e20..ebf7cc4 100644 --- a/src/app/views/resources/instances/_properties.haml +++ b/src/app/views/resources/instances/_properties.haml @@ -1,3 +1,6 @@ +%h3 + Properties for + = @instance.name %ul %li = label_tag :name, 'Name'
aeolus-devel@lists.fedorahosted.org