Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #372 from ZeroPointEnergy/fix/report_parsing
Browse files Browse the repository at this point in the history
Fix/report parsing
  • Loading branch information
bwitt authored Sep 7, 2018
2 parents 04576e0 + 65d3eca commit 89df6d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def self.create_from_yaml(report_yaml)
# munge will capture metrics about the number of unchanged items
# then we can remove them to save space in the resource_statuses table
if SETTINGS.disable_report_unchanged_events
report.resource_statuses.delete_if {|rs| rs.status == 'unchanged' }
report.resource_statuses.each{|rs| rs.destroy if rs.status == 'unchanged' }
end

report.save!
Expand Down
14 changes: 14 additions & 0 deletions spec/models/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,20 @@
myStubbedClass.create_from_yaml_file('/tmp/foo').should == nil
end
end

describe 'disable_report_unchanged_events setting' do
let(:report_yaml){ File.read(File.join(Rails.root, 'spec/fixtures/reports/failure.yml')) }
let(:report) { Report.create_from_yaml(report_yaml) }
it 'should keep all resource statuses per default' do
expect(report.resource_statuses.count).to be 9
expect(ResourceStatus.count).to be 9
end
it 'should remove unchanged resource statuses' do
SETTINGS.stubs(:disable_report_unchanged_events).returns(true)
expect(report.resource_statuses.count).to be 1
expect(ResourceStatus.count).to be 1
end
end
end


Expand Down

0 comments on commit 89df6d6

Please sign in to comment.