Skip to content

Commit

Permalink
Merge pull request #34 from fdupont-redhat/bz1447754
Browse files Browse the repository at this point in the history
Move create_service_provision_request into MiqAeServiceMethods for consistency
  • Loading branch information
gmcculloug authored Jun 12, 2017
2 parents f4bc749 + 2fd5605 commit f650a66
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ def instantiate(uri)
return nil
end

def create_service_provision_request(svc_template, options = nil)
result = ar_object(svc_template).provision_request(@workspace.ae_user, options)
MiqAeServiceModelBase.wrap_results(result)
end

def object(path = nil)
obj = @workspace.get_obj_from_path(path)
return nil if obj.nil?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def self.create_automation_request(options, userid = "admin", auto_approve = fal
MiqAeServiceModelBase.wrap_results(AutomationRequest.create_request(options, user, auto_approve))
end

def self.create_service_provision_request(svc_template, options = nil)
result = svc_template.object_send(:provision_request, User.current_user, options)
MiqAeServiceModelBase.wrap_results(result)
end

def self.drb_undumped(klass)
_log.info "Entered: klass=#{klass.name}"
klass.include(DRbUndumped) unless klass.ancestors.include?(DRbUndumped)
Expand Down
27 changes: 27 additions & 0 deletions spec/engine/miq_ae_method_service/miq_ae_service_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,32 @@ def category_create_script
ct.reload
expect(ct.entries.collect(&:name).include?('fred')).to be_truthy
end

context "#create_service_provision_request" do
let(:options) { {:fred => :flintstone} }
let(:svc_options) { {:dialog_style => "medium"} }
let(:user) { FactoryGirl.create(:user_with_group) }
let(:template) { FactoryGirl.create(:service_template_ansible_playbook) }
let(:miq_request) { FactoryGirl.create(:service_template_provision_request) }
let(:svc_template) do
MiqAeMethodService::MiqAeServiceServiceTemplate.find(template.id)
end
let(:workspace) do
double("MiqAeEngine::MiqAeWorkspaceRuntime",
:root => options,
:persist_state_hash => {},
:ae_user => user)
end
let(:miq_ae_service) { MiqAeMethodService::MiqAeService.new(workspace) }

it "create service request" do
allow(workspace).to receive(:disable_rbac)
allow(ServiceTemplate).to receive(:find).with(template.id).and_return(template)
expect(template).to receive(:provision_request).with(user, svc_options).and_return(miq_request)

result = miq_ae_service.execute(:create_service_provision_request, svc_template, svc_options)
expect(result).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest)
end
end
end
end
27 changes: 0 additions & 27 deletions spec/miq_ae_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,5 @@ module MiqAeServiceSpec
end
end
end

context "#create_service_provision_request" do
let(:options) { {:fred => :flintstone} }
let(:svc_options) { {:dialog_style => "medium"} }
let(:user) { FactoryGirl.create(:user_with_group) }
let(:template) { FactoryGirl.create(:service_template_ansible_playbook) }
let(:miq_request) { FactoryGirl.create(:service_template_provision_request) }
let(:svc_template) do
MiqAeMethodService::MiqAeServiceServiceTemplate.find(template.id)
end
let(:workspace) do
double("MiqAeEngine::MiqAeWorkspaceRuntime",
:root => options,
:persist_state_hash => {},
:ae_user => user)
end
let(:miq_ae_service) { MiqAeService.new(workspace) }

it "create service request" do
allow(workspace).to receive(:disable_rbac)
expect(svc_template).to receive(:instance_variable_get).with('@object').and_return(template)
expect(template).to receive(:provision_request).with(user, svc_options).and_return(miq_request)

result = miq_ae_service.create_service_provision_request(svc_template, svc_options)
expect(result).to be_kind_of(MiqAeMethodService::MiqAeServiceMiqRequest)
end
end
end
end

0 comments on commit f650a66

Please sign in to comment.