From: Nick Lewis <[email protected]>

The attributes Puppet::Resource::Status#changed,
Puppet::Resource::Status#out_of_sync, and
Puppet::Transaction::Event#audited used to only appear in reports when
their state was true.  Now they appear always.

Signed-off-by: Paul Berry <[email protected]>
---
 lib/puppet/resource/status.rb                  |    2 ++
 lib/puppet/transaction/event.rb                |    1 +
 spec/unit/resource/status_spec.rb              |    8 ++++----
 spec/unit/transaction/event_spec.rb            |    8 +++++++-
 spec/unit/transaction/resource_harness_spec.rb |    6 +++---
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/puppet/resource/status.rb b/lib/puppet/resource/status.rb
index 43d3f16..b138c65 100644
--- a/lib/puppet/resource/status.rb
+++ b/lib/puppet/resource/status.rb
@@ -47,6 +47,8 @@ module Puppet
         @resource = resource.to_s
         @change_count = 0
         @out_of_sync_count = 0
+        @changed = false
+        @out_of_sync = false
 
         [:file, :line].each do |attr|
           send(attr.to_s + "=", resource.send(attr))
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb
index e3537bb..b9fa5c3 100644
--- a/lib/puppet/transaction/event.rb
+++ b/lib/puppet/transaction/event.rb
@@ -16,6 +16,7 @@ class Puppet::Transaction::Event
   EVENT_STATUSES = %w{noop success failure audit}
 
   def initialize(*args)
+    @audited = false
     options = args.last.is_a?(Hash) ? args.pop : ATTRIBUTES.inject({}) { 
|hash, attr| hash[attr] = args.pop; hash }
     options.each { |attr, value| send(attr.to_s + "=", value) unless 
value.nil? }
 
diff --git a/spec/unit/resource/status_spec.rb 
b/spec/unit/resource/status_spec.rb
index 22d5fb4..3d9a841 100755
--- a/spec/unit/resource/status_spec.rb
+++ b/spec/unit/resource/status_spec.rb
@@ -112,20 +112,20 @@ describe Puppet::Resource::Status do
   it "should not start with any changes" do
     @status.change_count.should == 0
 
-    @status.changed.should be_false
-    @status.out_of_sync.should be_false
+    @status.changed.should == false
+    @status.out_of_sync.should == false
   end
 
   it "should not treat failure, audit, or noop events as changed" do
     ['failure', 'audit', 'noop'].each do |s| @status << 
Puppet::Transaction::Event.new(:status => s) end
     @status.change_count.should == 0
-    @status.changed.should be_false
+    @status.changed.should == false
   end
 
   it "should not treat audit events as out of sync" do
     @status << Puppet::Transaction::Event.new(:status => 'audit')
     @status.out_of_sync_count.should == 0
-    @status.out_of_sync.should be_false
+    @status.out_of_sync.should == false
   end
 
   ['failure', 'noop', 'success'].each do |event_status|
diff --git a/spec/unit/transaction/event_spec.rb 
b/spec/unit/transaction/event_spec.rb
index 4a3e6ba..2776be8 100755
--- a/spec/unit/transaction/event_spec.rb
+++ b/spec/unit/transaction/event_spec.rb
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require 'puppet/transaction/event'
 
 describe Puppet::Transaction::Event do
-  [:previous_value, :desired_value, :property, :resource, :name, :message, 
:file, :line, :tags].each do |attr|
+  [:previous_value, :desired_value, :property, :resource, :name, :message, 
:file, :line, :tags, :audited].each do |attr|
     it "should support #{attr}" do
       event = Puppet::Transaction::Event.new
       event.send(attr.to_s + "=", "foo")
@@ -46,6 +46,12 @@ describe Puppet::Transaction::Event do
     Puppet::Transaction::Event.new.time.should be_instance_of(Time)
   end
 
+  describe "audit property" do
+    it "should default to false" do
+      Puppet::Transaction::Event.new.audited.should == false
+    end
+  end
+
   describe "when sending logs" do
     before do
       Puppet::Util::Log.stubs(:new)
diff --git a/spec/unit/transaction/resource_harness_spec.rb 
b/spec/unit/transaction/resource_harness_spec.rb
index 387deca6..771c7b4 100755
--- a/spec/unit/transaction/resource_harness_spec.rb
+++ b/spec/unit/transaction/resource_harness_spec.rb
@@ -208,11 +208,11 @@ describe Puppet::Transaction::ResourceHarness do
                       status.out_of_sync_count.should == 
expected_out_of_sync_count
 
                       # Check legacy summary fields
-                      status.changed.should == (expected_change_count == 0 ? 
nil : true)
-                      status.out_of_sync.should == (expected_out_of_sync_count 
== 0 ? nil : true)
+                      status.changed.should == (expected_change_count != 0)
+                      status.out_of_sync.should == (expected_out_of_sync_count 
!= 0)
 
                       # Check the :synced field on state.yml
-                      synced_should_be_set = !noop_mode && status.changed != 
nil
+                      synced_should_be_set = !noop_mode && status.changed
                       (@harness.cached(resource, :synced) != nil).should == 
synced_should_be_set
                     end; end
                   end
-- 
1.7.2

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to