Skip to content

Commit

Permalink
Merge pull request #19951 from gmcculloug/service_order_constant_problem
Browse files Browse the repository at this point in the history
Change SERVICE_ORDER_CLASS to a string
  • Loading branch information
carbonin authored Mar 11, 2020
2 parents 6826efd + acfdfad commit fbcce99
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/models/service_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def clear

def self.add_to_cart(request, requester)
_log.info("Service Order add_to_cart for Request: #{request.id} Requester: #{requester.userid}")
service_order = request.class::SERVICE_ORDER_CLASS.find_or_create_by(
service_order = request.class::SERVICE_ORDER_CLASS.safe_constantize.find_or_create_by(
:state => STATE_CART,
:user => requester,
:tenant => requester.current_tenant
Expand All @@ -98,7 +98,7 @@ def self.remove_from_cart(request, requester)
end

def self.order_immediately(request, requester)
request.class::SERVICE_ORDER_CLASS.create(
request.class::SERVICE_ORDER_CLASS.safe_constantize.create(
:state => STATE_ORDERED,
:user => requester,
:miq_requests => [request],
Expand Down
2 changes: 1 addition & 1 deletion app/models/service_template_provision_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class ServiceTemplateProvisionRequest < MiqRequest
TASK_DESCRIPTION = 'Service_Template_Provisioning'
SOURCE_CLASS_NAME = 'ServiceTemplate'
ACTIVE_STATES = %w( migrated ) + base_class::ACTIVE_STATES
SERVICE_ORDER_CLASS = ::ServiceOrderCart
SERVICE_ORDER_CLASS = '::ServiceOrderCart'.freeze

validates_inclusion_of :request_state, :in => %w( pending finished ) + ACTIVE_STATES, :message => "should be pending, #{ACTIVE_STATES.join(", ")} or finished"
validate :must_have_user
Expand Down
2 changes: 1 addition & 1 deletion app/models/service_template_transformation_plan_request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ServiceTemplateTransformationPlanRequest < ServiceTemplateProvisionRequest
TASK_DESCRIPTION = 'VM Transformations'.freeze
SERVICE_ORDER_CLASS = ::ServiceOrderV2V
SERVICE_ORDER_CLASS = '::ServiceOrderV2V'.freeze

delegate :transformation_mapping, :vm_resources, :to => :source

Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_template_provision_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let(:admin) { FactoryBot.create(:user_admin) }

describe 'SERVICE_ORDER_CLASS' do
it { expect(described_class::SERVICE_ORDER_CLASS).to eq(ServiceOrderCart) }
it { expect(described_class::SERVICE_ORDER_CLASS.safe_constantize).to eq(ServiceOrderCart) }
end

context "with multiple tasks" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
end

describe 'SERVICE_ORDER_CLASS' do
it { expect(described_class::SERVICE_ORDER_CLASS).to eq(ServiceOrderV2V) }
it { expect(described_class::SERVICE_ORDER_CLASS.safe_constantize).to eq(ServiceOrderV2V) }
end

describe '#validate_conversion_hosts' do
Expand Down

0 comments on commit fbcce99

Please sign in to comment.