Project

General

Profile

« Previous | Next » 

Revision 59372586

Added by Dominic Cleal over 7 years ago

fixes #17484 - remove reported_at sequence from report factory

Prevents reports getting ever more out of sync from Time.now.
(cherry picked from commit 46edaeb9ca6cd0ee3a804d665b8783c62f2f0700)

View differences:

test/factories/host_related.rb
report_count 5
end
after(:create) do |host,evaluator|
evaluator.report_count.times do
report = FactoryGirl.create(:report, :host => host)
evaluator.report_count.times do |i|
report = FactoryGirl.create(:report, :host => host, :reported_at => (evaluator.report_count - i).minutes.ago)
host.last_report = report.reported_at
end
end
test/factories/reports_related.rb
FactoryGirl.define do
factory :report do
host
sequence(:reported_at) { |n| n.minutes.ago }
reported_at { Time.now.utc }
status 0
metrics YAML.load("--- \n time: \n schedule: 0.00083\n service: 0.149739\n mailalias: 0.000283\n cron: 0.000419\n config_retrieval: 16.3637869358063\n package: 0.003989\n filebucket: 0.000171\n file: 0.007025\n exec: 0.000299\n resources: \n total: 33\n changes: {}\n events: \n total: 0")
type 'ConfigReport'
test/unit/report_test.rb
describe '.my_reports' do
setup do
@target_host = FactoryGirl.create(:host, :with_hostgroup)
@target_reports = FactoryGirl.create_pair(:config_report, host: @target_host)
@other_host = FactoryGirl.create(:host, :with_hostgroup)
@other_reports = FactoryGirl.create_pair(:report, host: @other_host)
@target_host = FactoryGirl.create(:host, :with_hostgroup, :with_reports, :report_count => 2)
@target_reports = @target_host.reports
@other_host = FactoryGirl.create(:host, :with_hostgroup, :with_reports, :report_count => 2)
@other_reports = @other_host.reports
end
test 'returns all reports for admin' do

Also available in: Unified diff