From b734a0d1a1d74ab4107aa894d0de2f3bcf1714e2 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Tue, 19 Mar 2019 13:44:40 +0100 Subject: [PATCH 1/2] Fix ConversionHost active_tasks method to use state == 'migrate' --- app/models/conversion_host.rb | 2 +- spec/models/conversion_host_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 1b2c9d07320..47fe6f6d15d 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -5,7 +5,7 @@ class ConversionHost < ApplicationRecord belongs_to :resource, :polymorphic => true has_many :service_template_transformation_plan_tasks, :dependent => :nullify - has_many :active_tasks, -> { where(:state => 'active') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host + has_many :active_tasks, -> { where(:state => 'migrate') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host delegate :ext_management_system, :hostname, :ems_ref, :to => :resource, :allow_nil => true validates :name, :presence => true diff --git a/spec/models/conversion_host_spec.rb b/spec/models/conversion_host_spec.rb index fab5359bd10..ffa89b1554f 100644 --- a/spec/models/conversion_host_spec.rb +++ b/spec/models/conversion_host_spec.rb @@ -9,9 +9,9 @@ let(:vm) { FactoryBot.create(:vm_openstack) } let(:conversion_host_1) { FactoryBot.create(:conversion_host, :resource => host) } let(:conversion_host_2) { FactoryBot.create(:conversion_host, :resource => vm) } - let(:task_1) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'active', :conversion_host => conversion_host_1) } + let(:task_1) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'migrate', :conversion_host => conversion_host_1) } let(:task_2) { FactoryBot.create(:service_template_transformation_plan_task, :conversion_host => conversion_host_1) } - let(:task_3) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'active', :conversion_host => conversion_host_2) } + let(:task_3) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'migrate', :conversion_host => conversion_host_2) } before do allow(conversion_host_1).to receive(:active_tasks).and_return([task_1]) From 693c280cd75541e6fab67bf984db836472674868 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Tue, 19 Mar 2019 13:56:48 +0100 Subject: [PATCH 2/2] Allow 'migrate' or 'active' state --- app/models/conversion_host.rb | 2 +- spec/models/conversion_host_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 47fe6f6d15d..e5d50e715f9 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -5,7 +5,7 @@ class ConversionHost < ApplicationRecord belongs_to :resource, :polymorphic => true has_many :service_template_transformation_plan_tasks, :dependent => :nullify - has_many :active_tasks, -> { where(:state => 'migrate') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host + has_many :active_tasks, -> { where(:state => ['active', 'migrate']) }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host delegate :ext_management_system, :hostname, :ems_ref, :to => :resource, :allow_nil => true validates :name, :presence => true diff --git a/spec/models/conversion_host_spec.rb b/spec/models/conversion_host_spec.rb index ffa89b1554f..37812a23f49 100644 --- a/spec/models/conversion_host_spec.rb +++ b/spec/models/conversion_host_spec.rb @@ -9,7 +9,7 @@ let(:vm) { FactoryBot.create(:vm_openstack) } let(:conversion_host_1) { FactoryBot.create(:conversion_host, :resource => host) } let(:conversion_host_2) { FactoryBot.create(:conversion_host, :resource => vm) } - let(:task_1) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'migrate', :conversion_host => conversion_host_1) } + let(:task_1) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'active', :conversion_host => conversion_host_1) } let(:task_2) { FactoryBot.create(:service_template_transformation_plan_task, :conversion_host => conversion_host_1) } let(:task_3) { FactoryBot.create(:service_template_transformation_plan_task, :state => 'migrate', :conversion_host => conversion_host_2) }