This commit overhauls the sidebar to be consistent with the data views in the new tabs on the homepage. The homepage itself has been reorganized to put the status summary graph on top, followed by the stacked bar chart of report statuses, and the recently reported nodes chart at the bottom has been replaced by a tabbed chart displaying nodes and their resource status counts in the order they have reported.
While implementing these changes, we came across lots of duplicated and questionable code that has been removed. CSV export links within the tabbed chart on the homepage and on node list pages should all work. Pagination has also been implemented for the tabbed chart. Paired-with: Matt Robinson <[email protected]> Signed-off-by: Max Martin <[email protected]> --- Local-branch: ticket/master/7840-consistency app/controllers/nodes_controller.rb | 21 +------- app/controllers/pages_controller.rb | 19 +++---- app/helpers/nodes_helper.rb | 3 +- app/helpers/pages_helper.rb | 2 +- app/models/node.rb | 60 +--------------------- app/models/status.rb | 3 +- app/views/nodes/_nodes.html.haml | 33 +++++++++--- app/views/nodes/index.html.haml | 5 +-- app/views/pages/_resource_summary.html.haml | 30 ----------- app/views/pages/home.html.haml | 50 ++++++------------ app/views/shared/_node_manager_sidebar.html.haml | 16 ++---- config/routes.rb | 18 ++++--- spec/controllers/nodes_controller_spec.rb | 46 ----------------- spec/controllers/pages_controller_spec.rb | 13 ++--- spec/helpers/pages_helper_spec.rb | 8 ++-- spec/models/node_spec.rb | 49 +----------------- 16 files changed, 86 insertions(+), 290 deletions(-) delete mode 100644 app/views/pages/_resource_summary.html.haml diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index ea79b72..843f395 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -12,20 +12,8 @@ class NodesController < InheritedResources::Base scoped_index :unhidden end - def successful - redirect_to nodes_path(:current => true.to_s, :successful => true.to_s) - end - - def failed - redirect_to nodes_path(:current => true.to_s, :successful => false.to_s) - end - - def unreported - scoped_index :unhidden, :unreported - end - - def no_longer_reporting - scoped_index :unhidden, :no_longer_reporting + [:unreported, :failed, :unresponsive, :pending, :changed, :unchanged].each do |action| + define_method(action) {scoped_index :unhidden, action} end def hidden @@ -116,16 +104,13 @@ class NodesController < InheritedResources::Base scope_names.each do |scope_name| scope = scope.send(scope_name) end - if params[:current].present? or params[:successful].present? - scope = scope.by_currentness_and_successfulness(params[:current] == "true", params[:successful] == "true") - end set_collection_ivar(scope.with_last_report.by_report_date) format.html { render :index } format.yaml { render :text => collection.to_yaml, :content_type => 'application/x-yaml' } format.csv do response["Content-Type"] = 'text/comma-separated-values;' - response["Content-Disposition"] = 'filename="nodes.csv";' + response["Content-Disposition"] = "filename=#{scope_names.join("-")}-nodes.csv;" render :text => proc { |response,output| collection.to_csv do |line| diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e18ff2d..8c04dda 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,17 +1,14 @@ class PagesController < ApplicationController def home - @nodes = Node.unhidden + @all_nodes = Node.unhidden.by_report_date - @currently_failing_nodes = @nodes.by_currentness_and_successfulness(true, false) - @unreported_nodes = @nodes.unreported - @no_longer_reporting_nodes = @nodes.no_longer_reporting - @recently_reported_nodes = @nodes.reported.by_report_date.all(:limit => 10) - - @unresponsive_nodes = @nodes.unresponsive - @failed_nodes = @nodes.failed - @pending_nodes = @nodes.pending - @changed_nodes = @nodes.changed - @unchanged_nodes = @nodes.unchanged + @unreported_nodes = @all_nodes.unreported + @recently_reported_nodes = @all_nodes + @unresponsive_nodes = @all_nodes.unresponsive + @failed_nodes = @all_nodes.failed + @pending_nodes = @all_nodes.pending + @changed_nodes = @all_nodes.changed + @unchanged_nodes = @all_nodes.unchanged end def release_notes diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index fd13f45..b198a91 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb @@ -5,7 +5,8 @@ module NodesHelper end def node_title_text(node) - returning node.status_class.titleize do |str| + return "No reports" unless node.status + returning node.status.titleize do |str| str << " " << time_ago_in_words(node.reported_at) << " ago" if node.reported_at end end diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb index 0de5b40..610272d 100644 --- a/app/helpers/pages_helper.rb +++ b/app/helpers/pages_helper.rb @@ -1,5 +1,5 @@ module PagesHelper def percentage(nodes) - (100 * nodes.length / @nodes.length.to_f).round(2) + (100 * nodes.length / @all_nodes.length.to_f).round(2) end end diff --git a/app/models/node.rb b/app/models/node.rb index 43af3ef..ce1a535 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -36,77 +36,26 @@ class Node < ActiveRecord::Base named_scope :unresponsive, lambda {{ :conditions => [ - "last_apply_report_id IS NULL OR reported_at < ?", - SETTINGS.no_longer_reporting_cutoff.seconds.ago - ] - }} - named_scope :responsive, lambda {{ - :conditions => [ - "last_apply_report_id IS NOT NULL AND reported_at >= ?", + "last_apply_report_id IS NOT NULL AND reported_at < ?", SETTINGS.no_longer_reporting_cutoff.seconds.ago ] }} - # Return nodes based on their currentness and successfulness. - # - # The terms are: - # * currentness: +true+ uses the latest report (current) and +false+ uses any report. - # * successfulness: +true+ means a successful report, +false+ a failing report. - # - # Thus: - # * current and successful: Return only nodes that are currently successful. - # * current and failing: Return only nodes that are currently failing. - # * non-current and successful: Return any nodes that ever had a successful report. - # * non-current and failing: Return any nodes that ever had a failing report. - named_scope :by_currentness_and_successfulness, lambda {|currentness, successfulness| - op = successfulness ? '!=' : '=' - if currentness - { - :conditions => [ "nodes.status #{op} 'failed' AND nodes.last_apply_report_id is not NULL" ] - } - else - { - :conditions => [ "reports.kind = 'apply' AND reports.status #{op} 'failed'" ], - :joins => :reports, - :group => 'nodes.id', - } - end - } - [:failed, :pending, :changed, :unchanged].each do |node_status| - # what I really want is composite scopes so that I can say it has to be responsive without - # duplicating the logic for responsive named_scope node_status, lambda {{ :conditions => [ - "last_apply_report_id IS NOT NULL AND reported_at >= ? AND status = '#{node_status}'", + "last_apply_report_id IS NOT NULL AND reported_at >= ? AND nodes.status = '#{node_status}'", SETTINGS.no_longer_reporting_cutoff.seconds.ago ] }} end - named_scope :reported, :conditions => ["reported_at IS NOT NULL"] named_scope :unreported, :conditions => {:reported_at => nil} - named_scope :no_longer_reporting, lambda { - { - :conditions => ['reported_at < ?', SETTINGS.no_longer_reporting_cutoff.seconds.ago] - } - } - named_scope :hidden, :conditions => {:hidden => true} named_scope :unhidden, :conditions => {:hidden => false} - def self.label_for_currentness_and_successfulness(current, successful) - scope = { true => 'Currently', false => 'Ever' } - tense = if current then - { true => 'successful', false => 'failing' } - else - { true => 'succeeded', false => 'failed' } - end - return "#{scope[current]} #{tense[successful]}" - end - def self.find_by_id_or_name!(identifier) find_by_id(identifier) or find_by_name!(identifier) end @@ -193,11 +142,6 @@ class Node < ActiveRecord::Base 'production' end - def status_class - return 'no reports' unless last_apply_report - last_apply_report.status - end - attr_accessor :node_class_names attr_accessor :node_class_ids before_validation :assign_node_classes diff --git a/app/models/status.rb b/app/models/status.rb index 7d2ed42..de3aaba 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -15,7 +15,8 @@ class Status # * :node => Node to return Statuses for. # * :nodes => Nodes to return Statuses for. def self.within_daily_run_history(options={}) - return [] if options[:nodes] && options[:nodes].empty? + #require 'ruby-debug';debugger;1 + #return [] if options[:nodes] && options[:nodes].empty? last_day = Time.zone.now + 1.day # Last full day to include (ignores time). limit = SETTINGS.daily_run_history_length # Limit the number of days to return (includes "last_day"). diff --git a/app/views/nodes/_nodes.html.haml b/app/views/nodes/_nodes.html.haml index 6efce09..cc5f128 100644 --- a/app/views/nodes/_nodes.html.haml +++ b/app/views/nodes/_nodes.html.haml @@ -1,10 +1,15 @@ -- nodes = paginate_scope(local_assigns[:nodes]) -- more_link = local_assigns[:more_link] -- container = local_assigns[:container] +- nodes = paginate_scope(local_assigns[:nodes]) +- container = local_assigns[:container] +- selected_status = local_assigns[:selected_status] +- more_link = local_assigns[:more_link] %table.main %thead %tr + %th(colspan="3") + %th(colspan="5") + Resources + %tr %th.status %th.hostname Hostname @@ -12,12 +17,22 @@ %th Source %th.latest_report.desc ↓ Latest report + %th + All + %th + Failed + %th + Pending + %th + Changed + %th + Unchanged %tbody - if nodes.present? - - nodes.sort {|a,b| (b.reported_at || Time.at(0)) <=> (a.reported_at || Time.at(0))}.each do |node| + - nodes.each do |node| - sources = container.nodes_with_sources[node] unless container.nil? %tr[node]{:class => "#{'active' if node == @node}"} - %td.status{:class => node.status_class} + %td.status{:class => node.status} %span{:title => node_title_text(node)} = node_status_icon(node) %td.hostname @@ -30,11 +45,15 @@ = sources.map{|s| link_to(s.name,s)}.join(", ") %td.latest_report = node.last_apply_report ? node.last_apply_report.time : "Has not reported" + - ["total", "failed", "pending", "changed", "unchanged"].each do |status| + %td + = node.last_apply_report.metric_value("resources", status).to_i if node.last_apply_report - else - %td.empty{:colspan => container.nil? ? 3 : 4} + %td.empty{:colspan => container.nil? ? 8 : 9} = describe_no_matches_for :nodes - if nodes.present? %tfoot %tr - %td{:colspan => container.nil? ? 3 : 4 } + %td{:colspan => container.nil? ? 8 : 9 } = pagination_for nodes, more_link += link_to "Export nodes as CSV", url_for(:controller => "nodes", :action => selected_status == "all" ? :index : selected_status, :format => 'csv') diff --git a/app/views/nodes/index.html.haml b/app/views/nodes/index.html.haml index d5407cd..92741bf 100644 --- a/app/views/nodes/index.html.haml +++ b/app/views/nodes/index.html.haml @@ -6,9 +6,6 @@ - if action_name != 'index' = action_name.titleize.capitalize nodes - - elsif params[:current] or params[:successful] - = Node.label_for_currentness_and_successfulness(params[:current] == "true", params[:successful] == "true").capitalize - nodes - else Nodes = describe_search_if_present @@ -20,4 +17,4 @@ = render 'statuses/run_failure', :nodes => @nodes .section %h3 Nodes - = render 'nodes', :nodes => @nodes + = render 'nodes', :nodes => @nodes, :selected_status => action_name diff --git a/app/views/pages/_resource_summary.html.haml b/app/views/pages/_resource_summary.html.haml deleted file mode 100644 index e039913..0000000 --- a/app/views/pages/_resource_summary.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -- nodes = paginate_scope(local_assigns[:nodes], {:per_page => 10}) -- if nodes.length > 0 then - %table.main - %thead - %tr - %th - %th(colspan="5") - Resources - %tr - %th - %th - All - %th - Failed - %th - Pending - %th - Changed - %th - Unchanged - %tbody - - nodes.each do |node| - %tr - %th - = link_to h(node.name), node - - ["total", "failed", "pending", "changed", "unchanged"].each do |status| - %th - = node.last_apply_report.metric_value("resources", status).to_i if node.last_apply_report -- else - — No nodes matching — diff --git a/app/views/pages/home.html.haml b/app/views/pages/home.html.haml index 816196f..1fade7f 100644 --- a/app/views/pages/home.html.haml +++ b/app/views/pages/home.html.haml @@ -1,35 +1,10 @@ +- tab_statuses = %w{all failed pending unresponsive changed unchanged} #sidebar= render 'shared/node_manager_sidebar' #main .header %h2 Dashboard .item - %ul#home-tabs - %li(id="all-tab") - All - %li(id="failed-tab") - Failed - %li(id="pending-tab") - Pending - %li(id="unresponsive-tab") - Unresponsive - %li(id="changed-tab") - Changed - %li(id="unchanged-tab") - Unchanged - %div.panel(id="all") - = render 'resource_summary', :nodes => @nodes - %div.panel(id="failed") - = render 'resource_summary', :nodes => @failed_nodes - %div.panel(id="pending") - = render 'resource_summary', :nodes => @pending_nodes - %div.panel(id="unresponsive") - = render 'resource_summary', :nodes => @unresponsive_nodes - %div.panel(id="changed") - = render 'resource_summary', :nodes => @changed_nodes - %div.panel(id="unchanged") - = render 'resource_summary', :nodes => @unchanged_nodes - .item - - if @nodes.empty? + - if @all_nodes.empty? .section %p There are no nodes known by Dashboard. - else @@ -40,12 +15,19 @@ { :title => 'Pending', :nodes => @pending_nodes }, { :title => 'Compliant (Changed)', :nodes => @changed_nodes, :class_name => 'changed' }, { :title => 'Compliant (Unchanged)', :nodes => @unchanged_nodes, :class_name => 'unchanged' }, - { :title => 'Total Nodes', :nodes => @nodes } ].each do |section| + { :title => 'Total Nodes', :nodes => @all_nodes } ].each do |section| = render 'node_summary_row', section .section - = render 'statuses/run_failure', :nodes => @nodes - .section - %h3 Recently-reported nodes - = render 'nodes/nodes', :nodes => @recently_reported_nodes, :more_link => nodes_path(:page => 2) - .section - = link_to 'Export all nodes as CSV', nodes_path(:format => 'csv') + = render 'statuses/run_failure', :nodes => @all_nodes + .item + %ul#home-tabs + - tab_statuses.each do |tab_status| + %li(id="#{tab_status}-tab") + = tab_status.humanize + - tab_statuses.each do |tab_status| + %div.panel(id=tab_status) + = render 'nodes/nodes', + :nodes => instance_variable_get("@#{tab_status}_nodes"), + :selected_status => tab_status, + :more_link => url_for(:controller => "nodes", :action => tab_status == "all" ? :index : tab_status, :page => 2) + diff --git a/app/views/shared/_node_manager_sidebar.html.haml b/app/views/shared/_node_manager_sidebar.html.haml index c1cb2b1..c963454 100644 --- a/app/views/shared/_node_manager_sidebar.html.haml +++ b/app/views/shared/_node_manager_sidebar.html.haml @@ -2,21 +2,15 @@ %h3{:class => active_if(controller_name == "nodes" && action_name == "index")}= link_to "Nodes", nodes_path %span.count= Node.unhidden.count %ul - - for currentness in [true, false] - - for successfulness in [true, false] - %li{:class => active_if(controller_name == 'nodes' && params[:current] && (params[:current] == "true") == currentness && params[:successful] && (params[:successful] == "true") == successfulness && parent.nil?)} - - label = Node.label_for_currentness_and_successfulness(currentness, successfulness) - = link_to label, nodes_path(:current => currentness.to_s, :successful => successfulness.to_s) - - count = Node.unhidden.by_currentness_and_successfulness(currentness, successfulness).length - %span.count{:class => counter_class(count, currentness && !successfulness)}= count + - ["changed", "unchanged", "failed", "pending", "unresponsive"].each do |status| + %li{:class => active_if(controller_name == 'nodes' && action_name == status && parent.nil?)} + = link_to status.capitalize, eval("#{status}_nodes_path") + - count = Node.send(status).unhidden.count + %span.count{:class => counter_class(count, true)}= count %li{:class => active_if(controller_name == 'nodes' && action_name == 'unreported' && parent.nil?)} = link_to "Never reported", unreported_nodes_path - count = Node.unreported.unhidden.count %span.count{:class => counter_class(count, true)}= count - %li{:class => active_if(controller_name == 'nodes' && action_name == 'no_longer_reporting' && parent.nil?)} - = link_to "Not currently reporting", no_longer_reporting_nodes_path - - count = Node.no_longer_reporting.unhidden.count - %span.count{:class => counter_class(count, true)}= count %li{:class => active_if(controller_name == 'nodes' && action_name == 'hidden' && parent.nil?)} = link_to "Hidden", hidden_nodes_path - count = Node.hidden.count diff --git a/config/routes.rb b/config/routes.rb index 02337da..220fb5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,15 +11,19 @@ ActionController::Routing::Routes.draw do |map| map.resources :nodes, :member => { - :hide => :put, - :unhide => :put, - :facts => :get, + :hide => :put, + :unhide => :put, + :facts => :get, :reports => :get}, :collection => { - :unreported => :get, - :no_longer_reporting => :get, - :hidden => :get, - :search => :get}, + :unreported => :get, + :failed => :get, + :pending => :get, + :unresponsive => :get, + :changed => :get, + :unchanged => :get, + :hidden => :get, + :search => :get}, :requirements => {:id => /[^\/]+/} map.resources :reports, diff --git a/spec/controllers/nodes_controller_spec.rb b/spec/controllers/nodes_controller_spec.rb index 3a90f73..e401796 100644 --- a/spec/controllers/nodes_controller_spec.rb +++ b/spec/controllers/nodes_controller_spec.rb @@ -505,22 +505,6 @@ describe NodesController do end end - describe "#successful" do - it "should redirect to current and successful" do - get :successful - - response.should redirect_to(nodes_path(:current => true.to_s, :successful => true.to_s)) - end - end - - describe "#failed" do - it "should redirect to current and failed" do - get :failed - - response.should redirect_to(nodes_path(:current => true.to_s, :successful => false.to_s)) - end - end - describe "#unreported" do before :each do @node = Node.generate!(:name => "foo") @@ -533,21 +517,6 @@ describe NodesController do it_should_behave_like "a scoped_index action" end - describe "#no_longer_reporting" do - before :each do - SETTINGS.stubs(:no_longer_reporting_cutoff).returns(60) - @node = Node.generate!(:name => "foo") - @hidden_node = Node.generate!(:name => "bar", :hidden => true) - Report.generate!(:time => 1.hour.ago, :host => @node.name, :status => "failed") - Report.generate!(:time => 1.hour.ago, :host => @hidden_node.name, :status => "failed") - end - - let(:action) { "no_longer_reporting" } - let(:action_params) { {} } - - it_should_behave_like "a scoped_index action" - end - describe "#hidden" do before :each do @node = Node.generate!(:name => "foo", :hidden => true) @@ -559,20 +528,5 @@ describe NodesController do it_should_behave_like "a scoped_index action" end - - describe "current and successful" do - before :each do - SETTINGS.stubs(:no_longer_reporting_cutoff).returns(3600) - @node = Node.generate!(:name => "foo") - @hidden_node = Node.generate!(:name => "bar", :hidden => true) - Report.generate!(:host => @node.name, :time => 5.minutes.ago, :status => "unchanged") - Report.generate!(:host => @hidden_node.name, :time => 5.minutes.ago, :status => "unchanged") - end - - let(:action) { "index" } - let(:action_params) { {:current => "true", :successful => "true"} } - - it_should_behave_like "a scoped_index action" - end end end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 2ea2805..42acec6 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -8,7 +8,7 @@ describe PagesController do [true, false].each do |hidden| prefix = hidden ? 'hidden:' : '' Factory(:node, :hidden => hidden, :name => prefix + 'unreported') - [:reported, :unresponsive, :responsive, :failing, :pending, :changed, :unchanged].each do |node_status| + [:unresponsive, :responsive, :failing, :pending, :changed, :unchanged].each do |node_status| Factory("#{node_status}_node".to_sym, :hidden => hidden, :name => prefix + node_status.to_s) end end @@ -16,15 +16,10 @@ describe PagesController do it "should properly categorize nodes" do get :home + assigns[:all_nodes].map(&:name).should =~ %w[ unreported unresponsive responsive failing changed pending unchanged ] - assigns[:currently_failing_nodes].map(&:name).should =~ %w[ reported unresponsive responsive failing ] - assigns[:unreported_nodes].map(&:name).should =~ %w[ unreported ] - assigns[:no_longer_reporting_nodes].map(&:name).should =~ %w[ reported unresponsive ] - assigns[:recently_reported_nodes].map(&:name).should =~ %w[ reported unresponsive responsive failing changed pending unchanged ] - - assigns[:nodes].map(&:name).should =~ %w[ unreported reported unresponsive responsive failing changed pending unchanged ] - - assigns[:unresponsive_nodes].map(&:name).should =~ %w[ unreported reported unresponsive ] + assigns[:unreported_nodes].map(&:name).should =~ %w[ unreported ] + assigns[:unresponsive_nodes].map(&:name).should =~ %w[ unresponsive ] assigns[:failed_nodes].map(&:name).should =~ %w[ responsive failing ] assigns[:pending_nodes].map(&:name).should =~ %w[ pending ] assigns[:changed_nodes].map(&:name).should =~ %w[ changed ] diff --git a/spec/helpers/pages_helper_spec.rb b/spec/helpers/pages_helper_spec.rb index ec3523e..956e1b7 100644 --- a/spec/helpers/pages_helper_spec.rb +++ b/spec/helpers/pages_helper_spec.rb @@ -10,15 +10,15 @@ describe PagesHelper do describe '#percentage' do before :each do - helper.instance_variable_set(:@nodes, @nodes = []) + helper.instance_variable_set(:@all_nodes, @all_nodes = []) end - describe 'with values in @nodes' do + describe 'with values in @all_nodes' do before :each do - @nodes.push(*%w[ a b c d e f g h i j ]) + @all_nodes.push(*%w[ a b c d e f g h i j ]) end - it 'should report the ratio of given list length to @nodes' do + it 'should report the ratio of given list length to @all_nodes' do helper.percentage(%w[ a b c d e ]).should == 50 helper.percentage(%w[ a b c z ]).should == 40 end diff --git a/spec/models/node_spec.rb b/spec/models/node_spec.rb index bda113c..492a64b 100644 --- a/spec/models/node_spec.rb +++ b/spec/models/node_spec.rb @@ -66,29 +66,10 @@ describe Node do @never_reported = Node.generate!(:name => 'never_reported') end - - [ - [true, true, %w[ever_changed ever_unchanged just_changed just_unchanged]], - [true, false, %w[ever_failed just_failed]], - [false, true, %w[ever_changed ever_unchanged just_changed just_unchanged just_failed]], - [false, false, %w[just_changed just_unchanged ever_failed just_failed]], - ].each do |currentness, successfulness, inclusions| - context "when #{currentness ? 'current' : 'ever'} and #{successfulness ? 'successful' : 'failed'}" do - let(:currentness) { currentness } - let(:successfulness) { successfulness } - let(:inclusions) { inclusions } - - describe "::by_currentness_and_successfulness" do - it "should exactly match: #{inclusions.join(', ')}" do - Node.by_currentness_and_successfulness(currentness, successfulness).map(&:name).sort.should == inclusions.sort - end - end - end - end end describe "status named_scopes" do - it "should find responsive nodes with the appropriate statuses on the latest report" do + it "should find nodes with the appropriate statuses on the latest report" do [:failed, :pending, :changed, :unchanged].each do |node_status| node = Node.create!(:name => node_status.to_s) node.reports.generate!(:status => 'bogus', :time => Time.now - 1) @@ -106,13 +87,6 @@ describe Node do Node.unchanged.map(&:name).should == ['unchanged'] Node.failed.map(&:name).should == ['failed'] - Node.responsive.map(&:name).should =~ [ - 'failed', - 'pending', - 'changed', - 'unchanged' - ] - Node.unresponsive.map(&:name).should =~ [ 'failed-unresponsive', 'pending-unresponsive', @@ -145,16 +119,6 @@ describe Node do end end - describe ".reported" do - it "should return all nodes with a latest report" do - unreported_node = Node.generate - reported_node = Node.generate - Report.generate!(:host => reported_node.name) - - Node.reported.should == [reported_node] - end - end - describe ".unreported" do it "should return all nodes whose latest report was unreported" do unreported_node = Node.generate @@ -165,17 +129,6 @@ describe Node do end end - describe "no_longer_reporting" do - it "should return all nodes whose latest report is more than 1 hour ago" do - SETTINGS.expects(:no_longer_reporting_cutoff).at_least_once.returns(1.hour.to_i) - old = node = Node.generate(:reported_at => 2.hours.ago, :name => "old") - new = node = Node.generate(:reported_at => 10.minutes.ago, :name => "new") - - Node.no_longer_reporting.should include(old) - Node.no_longer_reporting.should_not include(new) - end - end - describe "" do before :each do @nodes = {:hidden => Node.generate!(:hidden => true), -- 1.7.4 -- 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.
