Skip to content

Commit

Permalink
Fixes #10782 - Fix rubocop and test
Browse files Browse the repository at this point in the history
  • Loading branch information
ares committed Jul 30, 2015
1 parent bb0be4e commit 9f027ba
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def destroy
eos

def status
render :json => { :status => @host.host_status }.to_json if @host
render :json => { :status => @host.get_status('HostStatus::ConfigurationStatus').to_label }.to_json if @host
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def destroy
eos

def status
render :json => { :status => @host.host_status }.to_json if @host
render :json => { :status => @host.get_status('HostStatus::ConfigurationStatus').to_label }.to_json if @host
end

api :GET, "/hosts/:id/vm_compute_attributes", N_("Get vm attributes of host")
Expand Down
1 change: 0 additions & 1 deletion app/helpers/hosts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def host_global_status_class(status)
end
end


def days_ago(time)
((Time.zone.now - time) / 1.day).round.to_i
end
Expand Down
6 changes: 1 addition & 5 deletions app/models/concerns/configuration_status_scoped_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ module ConfigurationStatusScopedSearch

module ClassMethods
def scoped_search_status(status, options)
options.merge({
:offset => Report::METRIC.index(status.to_s),
:word_size => Report::BIT_NUM
})
options.merge({ :offset => Report::METRIC.index(status.to_s), :word_size => Report::BIT_NUM })
scoped_search options
end
end

end
4 changes: 1 addition & 3 deletions app/models/host_status/configuration_status.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module HostStatus
class ConfigurationStatus < Status

delegate :error?, :changes?, :pending?, :to => :calculator
delegate *Report::METRIC, :to => :calculator
delegate(*Report::METRIC, :to => :calculator)

def out_of_sync?
if (host && !host.enabled?) || no_reports?
Expand Down Expand Up @@ -80,7 +79,6 @@ def update_timestamp
def calculator
ReportStatusCalculator.new(:bit_field => status)
end

end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/host_status/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class Global
attr_accessor :status

def self.build(statuses)
status = statuses.map do |status|
max_status = statuses.map do |status|
status.to_global
end.max

new(status || OK)
new(max_status || OK)
end

def initialize(status)
Expand Down
1 change: 0 additions & 1 deletion app/models/host_status/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def update_timestamp
def update_status
self.status = to_status
end

end
end

Expand Down
7 changes: 3 additions & 4 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def self.summarise(time = 1.day.ago, *hosts)
METRIC.each {|m| metrics[m] = 0 }
host.reports.recent(time).select(:status).each do |r|
metrics.each_key do |m|
metrics[m] += r.status(m)
metrics[m] += r.status_of(m)
end
end
list[host.name] = {:metrics => metrics, :id => host.id} if metrics.values.sum > 0
Expand Down Expand Up @@ -154,11 +154,10 @@ def self.report_status
"status"
end

delegate :error?, :changes?, :pending?, :status, :to => :calculator
delegate *METRIC, :to => :calculator
delegate :error?, :changes?, :pending?, :status, :status_of, :to => :calculator
delegate(*METRIC, :to => :calculator)

def calculator
ReportStatusCalculator.new(:bit_field => read_attribute(self.class.report_status))
end

end
2 changes: 1 addition & 1 deletion app/services/report_status_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def status
end

def status_of(counter)
raise(Foreman::Exception(N_("invalid type %s") % counter)) unless Report::METRIC.include?(counter)
raise(Foreman::Exception.new(N_("invalid type %s") % counter)) unless Report::METRIC.include?(counter)
status[counter]
end

Expand Down
1 change: 0 additions & 1 deletion test/unit/host_status/global_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ def setup
global = HostStatus::Global.new(HostStatus::Global::OK)
assert_kind_of String, global.to_label
end

end

0 comments on commit 9f027ba

Please sign in to comment.