diff --git a/app/models/miq_ae_method.rb b/app/models/miq_ae_method.rb index a219f598465..961af040c40 100644 --- a/app/models/miq_ae_method.rb +++ b/app/models/miq_ae_method.rb @@ -16,7 +16,7 @@ class MiqAeMethod < ApplicationRecord AVAILABLE_LANGUAGES = ["ruby", "perl"] # someday, add sh, perl, python, tcl and any other scripting language validates_inclusion_of :language, :in => AVAILABLE_LANGUAGES - AVAILABLE_LOCATIONS = ["builtin", "inline", "uri"] + AVAILABLE_LOCATIONS = %w(builtin inline uri expression).freeze validates_inclusion_of :location, :in => AVAILABLE_LOCATIONS AVAILABLE_SCOPES = ["class", "instance"] validates_inclusion_of :scope, :in => AVAILABLE_SCOPES @@ -33,6 +33,10 @@ def self.available_scopes AVAILABLE_SCOPES end + def self.available_expression_objects + MiqExpression.base_tables + end + # Validate the syntax of the passed in inline ruby code def self.validate_syntax(code_text) result = MiqSyntaxChecker.check(code_text) diff --git a/spec/support/automation_helper.rb b/spec/support/automation_helper.rb index dc02eb7ca61..ae9b8f6e8c4 100644 --- a/spec/support/automation_helper.rb +++ b/spec/support/automation_helper.rb @@ -35,11 +35,12 @@ def create_ae_model_with_method(attrs = {}) attrs = default_ae_model_attributes(attrs) method_script = attrs.delete(:method_script) method_params = attrs.delete(:method_params) || {} + method_loc = attrs.delete(:method_loc) || "inline" instance_name = attrs.delete(:instance_name) method_name = attrs.delete(:method_name) ae_fields = {'execute' => {:aetype => 'method', :datatype => 'string'}} ae_instances = {instance_name => {'execute' => {:value => method_name}}} - ae_methods = {method_name => {:scope => 'instance', :location => 'inline', + ae_methods = {method_name => {:scope => 'instance', :location => method_loc, :data => method_script, :language => 'ruby', 'params' => method_params}}