Skip to content

Commit

Permalink
Merge pull request #18233 from agrare/bz_1638045_fix_supports_capture
Browse files Browse the repository at this point in the history
Fix supports_capture assuming MetricsCapture class

(cherry picked from commit 603d59a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1638045
  • Loading branch information
kbrock authored and simaishi committed Nov 27, 2018
1 parent ee46c90 commit 43ed8cb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/metric/ci_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ module Metric::CiMixin
end

supports :capture do
unless self.class.parent::MetricsCapture.instance_methods.include?(:perf_collect_metrics)
unsupported_reason_add(:metrics, _('This provider does not support metrics collection'))
metrics_capture_klass = "#{self.class.parent.name}::MetricsCapture".safe_constantize
unless metrics_capture_klass&.method_defined?(:perf_collect_metrics)
unsupported_reason_add(:capture, _('This provider does not support metrics collection'))
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/models/metric/ci_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,26 @@
end
end
end

context "#supports_capture?" do
context "with a VM" do
let(:unsupported_vm) { FactoryGirl.create(:vm_microsoft) }
let(:supported_vm) { FactoryGirl.create(:vm_vmware) }

it "correctly checks capture support" do
expect(unsupported_vm.supports_capture?).to be_falsy
expect(supported_vm.supports_capture?).to be_truthy
end
end

context "with a Host" do
let(:unsupported_host) { FactoryGirl.create(:host_microsoft) }
let(:supported_host) { FactoryGirl.create(:vm_vmware) }

it "correctly checks capture support" do
expect(unsupported_host.supports_capture?).to be_falsy
expect(supported_host.supports_capture?).to be_truthy
end
end
end
end

0 comments on commit 43ed8cb

Please sign in to comment.