diff --git a/app/models/condition.rb b/app/models/condition.rb
index f636b55e999..97d8800e6e4 100644
--- a/app/models/condition.rb
+++ b/app/models/condition.rb
@@ -221,7 +221,7 @@ def self.options2hash(opts, rec)
attr, val = o.split("=")
ohash[attr.strip.downcase.to_sym] = val.strip.downcase
end
- if ohash[:ref] != rec.class.to_s.downcase
+ if ohash[:ref] != rec.class.to_s.downcase && !exclude_from_object_ref_substitution(ohash[:ref], rec)
ref = rec.send(val) if val && rec.respond_to?(val)
end
@@ -233,6 +233,13 @@ def self.options2hash(opts, rec)
return ohash, ref, object
end
+ def self.exclude_from_object_ref_substitution(reference, rec)
+ case reference
+ when "service"
+ rec.kind_of?(Service)
+ end
+ end
+
def self.registry_data(ref, name, ohash)
# HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders\Common AppData == 'C:\Documents and Settings\All Users\Application Data'
# HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders : Common AppData == 'C:\Documents and Settings\All Users\Application Data'
diff --git a/spec/models/condition_spec.rb b/spec/models/condition_spec.rb
index 47082de439e..a1a63c05cf8 100644
--- a/spec/models/condition_spec.rb
+++ b/spec/models/condition_spec.rb
@@ -151,4 +151,12 @@
expect(Condition.subst_matches?(expr, vm1)).not_to be_truthy
end
end
+
+ describe ".options2hash" do
+ it 'returns the same record if it is descendant from Service class and passed reference is "service" ' do
+ record = ServiceContainerTemplate.new
+ _, result_record, _ = described_class.options2hash("ref=service", record)
+ expect(result_record).to be(record)
+ end
+ end
end