From: Nick Lewis <[email protected]> Paired-With: Paul Berry
Signed-off-by: Matt Robinson <[email protected]> --- Local-branch: ticket/next/5543 app/models/report.rb | 4 ++-- lib/puppet/report.rb | 4 ++-- spec/lib/puppet/report_spec.rb | 10 +++++----- spec/support/describe_reports.rb | 2 +- spec/support/factories.rb | 2 +- spec/views/statuses/_run_failure.html.haml_spec.rb | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/report.rb b/app/models/report.rb index 5dfd999..49440d7 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -12,7 +12,7 @@ class Report < ActiveRecord::Base delegate :logs, :metric_value, :to => :report delegate :total_resources, :failed_resources, :failed_restarts, :skipped_resources, - :changed_resources, :failed?, :changed?, + :changed_resources, :failed_resources?, :changed_resources?, :to => :report default_scope :order => 'time DESC' @@ -94,7 +94,7 @@ class Report < ActiveRecord::Base end def set_attributes - self.status = failed? ? 'failed' : changed? ? 'changed' : 'unchanged' + self.status = failed_resources? ? 'failed' : changed_resources? ? 'changed' : 'unchanged' self.time = report.time self.host = report.host end diff --git a/lib/puppet/report.rb b/lib/puppet/report.rb index 37ec1de..1483bfa 100644 --- a/lib/puppet/report.rb +++ b/lib/puppet/report.rb @@ -13,8 +13,8 @@ module Puppet #:nodoc: def skipped_resources; metric_value(:resources, :skipped_resources) || 0; end def changed_resources; metric_value(:changes, :total) || 0; end - def failed?; failed_resources > 0 || metrics.empty? end - def changed?; changed_resources > 0 end + def failed_resources?; failed_resources > 0 || metrics.empty? end + def changed_resources?; changed_resources > 0 end # Puppet 0.25.x does not report individual status items def changed_statuses; nil end diff --git a/spec/lib/puppet/report_spec.rb b/spec/lib/puppet/report_spec.rb index afc1f45..7e7cb18 100644 --- a/spec/lib/puppet/report_spec.rb +++ b/spec/lib/puppet/report_spec.rb @@ -42,8 +42,8 @@ describe Puppet::Transaction::Report do it { should == info[:changed] } end - describe_reports "#changed?" do - subject { report.changed? } + describe_reports "#changed_resources?" do + subject { report.changed_resources? } it { should == info[:changed] > 0} end @@ -128,19 +128,19 @@ describe Puppet::Transaction::Report do it "should consider a report with metrics and no failing resources to be a success" do rep = Report.generate rep.report.stubs(:failed_resources).returns(0) - rep.should_not be_failed + rep.failed_resources?.should == false end it "should consider a report with failing resources to be a failure" do rep = Report.generate rep.report.stubs(:failed_resources).returns(1) - rep.should be_failed + rep.failed_resources?.should == true end it "should consider a report with no metrics and no failing resources to be a failure" do rep = Report.generate rep.report.stubs(:failed_resources).returns(0) rep.report.stubs(:metrics).returns({}) - rep.should be_failed + rep.failed_resources?.should == true end end diff --git a/spec/support/describe_reports.rb b/spec/support/describe_reports.rb index 27bf8b9..865e911 100644 --- a/spec/support/describe_reports.rb +++ b/spec/support/describe_reports.rb @@ -8,7 +8,7 @@ module DescribeReports # # Example: # - # describe_reports "#changed?" do subject { report.changed? } it { should + # describe_reports "#changed_resources?" do subject { report.changed_resources? } it { should # == info[:changed] > 0} end # def describe_reports(*args, &block) diff --git a/spec/support/factories.rb b/spec/support/factories.rb index 86443e3..2f51e64 100644 --- a/spec/support/factories.rb +++ b/spec/support/factories.rb @@ -9,7 +9,7 @@ class Report report.node = node report.stubs(:process_report => true) report.stubs( - :failed? => report.status == 'failed', + :failed_resources? => report.status == 'failed', :total_resources => 1, :failed_resources => report.status == 'failed' ? 1 : 0, :failed_restarts => 0, diff --git a/spec/views/statuses/_run_failure.html.haml_spec.rb b/spec/views/statuses/_run_failure.html.haml_spec.rb index 2a86218..e48c745 100644 --- a/spec/views/statuses/_run_failure.html.haml_spec.rb +++ b/spec/views/statuses/_run_failure.html.haml_spec.rb @@ -13,7 +13,7 @@ describe "/statuses/_run_failure.html.haml" do 32.times do |n| report = Puppet::Transaction::Report.new - report.stubs(:failed?).returns(false) + report.stubs(:failed_resources?).returns(false) report.stubs(:time).returns n.days.ago report.stubs(:host).returns "node" -- 1.7.3.1 -- 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.
