Skip to content

Commit

Permalink
Merge pull request #17415 from romanblanco/ci_processing_cleanup_2
Browse files Browse the repository at this point in the history
Moved method for testing feature support
  • Loading branch information
martinpovolny authored Jun 1, 2018
2 parents 8b5c3e7 + d1ddc75 commit fe9cd96
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 36 deletions.
3 changes: 3 additions & 0 deletions app/models/orchestration_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class OrchestrationStack < ApplicationRecord
include RetirementMixin
include TenantIdentityMixin
include CustomActionsMixin
include SupportsFeatureMixin

acts_as_miq_taggable

Expand Down Expand Up @@ -52,6 +53,8 @@ class OrchestrationStack < ApplicationRecord
alias_method :orchestration_stack_outputs, :outputs
alias_method :orchestration_stack_resources, :resources

supports :retire

def orchestration_stacks
children
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class Service < ApplicationRecord
unsupported_reason_add(:reconfigure, _("Reconfigure unsupported")) unless validate_reconfigure
end

supports :retire

alias parent_service parent
alias_attribute :service, :parent
virtual_belongs_to :service
Expand Down
10 changes: 0 additions & 10 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1692,16 +1692,6 @@ def self.includes_template?(ids)

supports_not :snapshots

def self.batch_operation_supported?(operation, ids)
VmOrTemplate.where(:id => ids).all? do |vm_or_template|
if vm_or_template.respond_to?("supports_#{operation}?")
vm_or_template.public_send("supports_#{operation}?")
else
vm_or_template.public_send("validate_#{operation}")[:available]
end
end
end

# Stop showing Reconfigure VM task unless the subclass allows
def reconfigurable?
false
Expand Down
26 changes: 0 additions & 26 deletions spec/models/vm_or_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,32 +564,6 @@
end
end

context "#self.batch_operation_supported?" do
let(:ems) { FactoryGirl.create(:ext_management_system) }
let(:storage) { FactoryGirl.create(:storage) }
let(:host) { FactoryGirl.create(:host) }

it "when the vm_or_template supports migrate, returns false" do
vm1 = FactoryGirl.create(:vm_microsoft)
vm2 = FactoryGirl.create(:vm_vmware)
expect(VmOrTemplate.batch_operation_supported?(:migrate, [vm1.id, vm2.id])).to eq(false)
end

it "when the vm_or_template exists and can be migrated, returns true" do
vm1 = FactoryGirl.create(:vm_vmware, :storage => storage, :ext_management_system => ems)
vm2 = FactoryGirl.create(:vm_vmware, :storage => storage, :ext_management_system => ems)
expect(VmOrTemplate.batch_operation_supported?(:migrate, [vm1.id, vm2.id])).to eq(true)
end

it "when the vm_or_template supports terminate, returns true" do
ems_vmware = FactoryGirl.create(:ems_vmware)
ems_ms = FactoryGirl.create(:ems_microsoft)
vm1 = FactoryGirl.create(:vm_microsoft, :host => host, :ext_management_system => ems_ms)
vm2 = FactoryGirl.create(:vm_vmware, :host => host, :ext_management_system => ems_vmware)
expect(VmOrTemplate.batch_operation_supported?(:terminate, [vm1.id, vm2.id])).to eq(true)
end
end

context ".set_tenant_from_group" do
before { Tenant.seed }
let(:tenant1) { FactoryGirl.create(:tenant) }
Expand Down

0 comments on commit fe9cd96

Please sign in to comment.