From 541dfe75fc504fa460bf91b090f7029e1ee0fdb4 Mon Sep 17 00:00:00 2001 From: lpichler Date: Thu, 14 Jun 2018 13:37:17 +0200 Subject: [PATCH] fix spec for ConsumptionWithRollups --- spec/models/chargeback/consumption_with_rollups_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/models/chargeback/consumption_with_rollups_spec.rb b/spec/models/chargeback/consumption_with_rollups_spec.rb index 2f582e1e140..b8e65a51699 100644 --- a/spec/models/chargeback/consumption_with_rollups_spec.rb +++ b/spec/models/chargeback/consumption_with_rollups_spec.rb @@ -1,6 +1,6 @@ describe Chargeback::ConsumptionWithRollups do - let(:vm) { FactoryGirl.build(:vm_microsoft) } - let(:consumption) { described_class.new([metric_rollup], starting_date, starting_date + 1.day) } + let(:vm) { FactoryGirl.create(:vm_microsoft) } + let(:consumption) { described_class.new(pluck_rollup([metric_rollup]), starting_date, starting_date + 1.day) } describe '#sub_metric_rollups' do let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc } @@ -9,6 +9,10 @@ let!(:state) { FactoryGirl.create(:vim_performance_state, :resource => vm, :state_data => nil, :timestamp => starting_date, :capture_interval => 3_600) } let!(:metric_rollup) { FactoryGirl.create(:metric_rollup_vm_hr, :timestamp => starting_date + 1.hour, :resource => vm) } + def pluck_rollup(metric_rollup_records) + metric_rollup_records.pluck(*ChargeableField.cols_on_metric_rollup) + end + before do Timecop.travel(starting_date + 10.hours) end