<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,10 +31,14 @@ class CollExpr &lt; AST::Branch
             when &quot;and&quot;; code1.call(resource) and code2.call(resource)
             when &quot;or&quot;; code1.call(resource) or code2.call(resource)
             when &quot;==&quot;
-                if resource[str1].is_a?(Array)
-                    resource[str1].include?(str2)
+                if str1 == &quot;tag&quot;
+                    resource.tagged?(str2)
                 else
-                    resource[str1] == str2
+                    if resource[str1].is_a?(Array)
+                        resource[str1].include?(str2)
+                    else
+                        resource[str1] == str2
+                    end
                 end
             when &quot;!=&quot;; resource[str1] != str2
             end
@@ -58,8 +62,11 @@ class CollExpr &lt; AST::Branch
 
         if oper == &quot;=&quot; or oper == &quot;!=&quot;
             # Add the rails association info where necessary
-            if str1 == &quot;title&quot;
+            case str1
+            when &quot;title&quot;
                 str = &quot;title #{oper} '#{str2}'&quot;
+            when &quot;tag&quot;
+                str = &quot;puppet_tags.name #{oper} '#{str2}'&quot;
             else
                 str = &quot;param_values.value #{oper} '#{str2}' and &quot; +
                     &quot;param_names.name = '#{str1}'&quot;</diff>
      <filename>lib/puppet/parser/ast/collexpr.rb</filename>
    </modified>
    <modified>
      <diff>@@ -102,7 +102,7 @@ class Puppet::Parser::Collector
         raise Puppet::DevError, &quot;Cannot collect resources for a nil host&quot; unless @scope.host
         host = Puppet::Rails::Host.find_by_name(@scope.host)
 
-        query = {:include =&gt; {:param_values =&gt; :param_name}}
+        query = {:include =&gt; {:param_values =&gt; :param_name, :puppet_tags =&gt; :resource_tags}}
 
         search = &quot;(exported=? AND restype=?)&quot;
         values = [true, @type]</diff>
      <filename>lib/puppet/parser/collector.rb</filename>
    </modified>
    <modified>
      <diff>@@ -74,6 +74,27 @@ describe Puppet::Parser::AST::CollExpr do
         end
     end
 
+    describe &quot;when evaluating with tags&quot; do
+        before :each do
+            @tag = stub 'tag', :safeevaluate =&gt; 'tag'
+            @value = stub 'value', :safeevaluate =&gt; 'value'
+
+            @resource = stub 'resource'
+            @resource.stubs(:tagged?).with(&quot;value&quot;).returns(true)
+        end
+
+        it &quot;should produce a textual representation of the expression&quot; do
+            collexpr = ast::CollExpr.new(:test1 =&gt; @tag, :test2 =&gt; @value, :oper=&gt;&quot;==&quot;)
+            result = collexpr.evaluate(@scope)
+            result[0].should == &quot;puppet_tags.name = 'value'&quot;
+        end
+
+        it &quot;should inspect resource tags if the query term is on tags&quot; do
+            collexpr = ast::CollExpr.new(:test1 =&gt; @tag, :test2 =&gt; @value, :oper =&gt; &quot;==&quot;)
+            collexpr.evaluate(@scope)[1].call(@resource).should be_true
+        end
+    end
+
     [:exported,:virtual].each do |mode|
     it &quot;should check for array member equality if resource parameter is an array for == in mode #{mode}&quot; do
         array = mock 'array', :safeevaluate =&gt; &quot;array&quot;</diff>
      <filename>spec/unit/parser/ast/collexpr.rb</filename>
    </modified>
    <modified>
      <diff>@@ -502,10 +502,10 @@ describe Puppet::Parser::Collector, &quot;when building its ActiveRecord query for co
         @collector.evaluate
     end
 
-    it &quot;should return parameter names and parameter values when querying ActiveRecord&quot; do
+    it &quot;should return parameter names, parameter values and tags when querying ActiveRecord&quot; do
         Puppet::Rails::Resource.stubs(:find).with { |*arguments|
             options = arguments[3]
-            options[:include] == {:param_values =&gt; :param_name}
+            options[:include] == {:param_values =&gt; :param_name, :puppet_tags =&gt; :resource_tags}
         }.returns([])
 
         @collector.evaluate</diff>
      <filename>spec/unit/parser/collector.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b5855ec1a5af2bec6c4ac35f8e6a885999b09bf9</id>
    </parent>
  </parents>
  <author>
    <name>Brice Figureau</name>
    <email>brice-puppet@daysofwonder.com</email>
  </author>
  <url>http://github.com/lak/puppet/commit/f9516d49a02facb43e2856766b6439673450fdd1</url>
  <id>f9516d49a02facb43e2856766b6439673450fdd1</id>
  <committed-date>2009-06-05T16:52:53-07:00</committed-date>
  <authored-date>2009-06-03T12:10:36-07:00</authored-date>
  <message>Make sure virtual and rails query use tags when tag are searched

Up to now, when trying to match with tags:
File&lt;&lt;| tag == 'value' |&gt;&gt;
in fact we were querying parameters. Hopefully all the user tags
are stored in parameters so it was working.
But it wasn't possible to search on auto-tags (like class name).
This patch makes sure searching by tag is done on tags both on the
rails side and the resource side.

Signed-off-by: Brice Figureau &lt;brice-puppet@daysofwonder.com&gt;</message>
  <tree>06df981d0a51f55d8a749706ae7d349e6b5401ec</tree>
  <committer>
    <name>James Turnbull</name>
    <email>james@lovedthanlost.net</email>
  </committer>
</commit>
