Skip to content
Permalink
Browse files

PR Review based changes

  • Loading branch information...
mkanoor committed Aug 18, 2015
1 parent 1a9e5f6 commit 0a8f392325e00ff1d7d0d95040411437b4463487
@@ -7,13 +7,13 @@ def include_service_template?(parent_svc_task, service_template_id, parent_svc =
st = ServiceTemplate.find(service_template_id)
set_automation_attrs([parent_svc_task.get_user, st, parent_svc, parent_svc_task], attrs)
uri = MiqAeEngine.create_automation_object("REQUEST", attrs, :vmdb_object => parent_svc_task)
automate_result(uri, st.name)
automate_result_include_service_template?(uri, st.name)
end

def automate_result(uri, name)
def automate_result_include_service_template?(uri, name)
ws = MiqAeEngine.resolve_automation_object(uri)
result = ws.root('include_service').nil? ? true : ws.root('include_service')
$log.info("Include Service Template <#{name}> : <#{result}>")
result = ws.root('include_service').presence || true
_log.info("Include Service Template <#{name}> : <#{result}>")
result
end

@@ -22,17 +22,8 @@
# included or excluded
#

def dump_root
$evm.log("info", "Root:<$evm.root> Attributes - Begin")
$evm.root.attributes.each { |k, v| $evm.log("info", " Attribute - #{k}: #{v}") }
$evm.log("info", "Root:<$evm.root> Attributes - End")
$evm.log("info", "")
end

$evm.root['include_service'] = false

# dump_root

service_template = $evm.root['service_template']
raise "service_template missing" unless service_template

@@ -2,7 +2,7 @@
include ServiceTemplateHelper

describe "FilterByDialogParameters Automate Method" do
before(:each) do
before do
@allowed_service_templates = %w(top)
user_helper
build_small_environment
@@ -49,15 +49,15 @@ def root_service_template_task
ws = run_automate_method(ServiceTemplate.find_by_name("top"),
root_service_template_task,
FactoryGirl.create(:service))
ws.root['include_service'].should be_true
expect(ws.root['include_service']).to be_true
end

it "with vm_serice" do
post_create(:dialog => {'dialog_environment' => "vm_service"})
ws = run_automate_method(ServiceTemplate.find_by_name("vm_service"),
root_service_template_task,
FactoryGirl.create(:service))
ws.root['include_service'].should be_true
expect(ws.root['include_service']).to be_true
end

it "with missing dialog_environment" do
@@ -73,7 +73,7 @@ def root_service_template_task
ws = run_automate_method(ServiceTemplate.find_by_name("vm_service"),
root_service_template_task,
FactoryGirl.create(:service))
ws.root['include_service'].should be_false
expect(ws.root['include_service']).to be_false
end
end
end
@@ -2,7 +2,7 @@
include ServiceTemplateHelper

describe "Service Filter" do
before(:each) do
before do
@allowed_service_templates = []
user_helper
build_small_environment
@@ -84,7 +84,7 @@ def build_small_environment
end

def service_template_stubs
ServiceTemplate.stub(:automate_result) do |_uri, name|
ServiceTemplate.stub(:automate_result_include_service_template?) do |_uri, name|
@allowed_service_templates.include?(name)
end
end

0 comments on commit 0a8f392

Please sign in to comment.
You can’t perform that action at this time.