Skip to content

Commit

Permalink
Merge pull request ManageIQ#7057 from agrare/fix_issues_constantizing…
Browse files Browse the repository at this point in the history
…_cloud_volumes

Fix constantizing CloudVolume for disable? check
  • Loading branch information
h-kataria authored May 19, 2020
2 parents 577f4a2 + b74c99c commit 7e25777
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class ApplicationHelper::Button::CloudVolumeBackupCreate < ApplicationHelper::Button::ButtonNewDiscover
def disabled?
ManageIQ::Providers::CloudManager.none? do |ems|
Module.const_defined?("#{ems.class}::CloudVolume") &&
ems.class::CloudVolume.supports?(:backup_create)
"#{ems.class}::CloudVolume".safe_constantize&.supports?(:backup_create)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class ApplicationHelper::Button::CloudVolumeBackupRestore < ApplicationHelper::Button::ButtonNewDiscover
def disabled?
ManageIQ::Providers::CloudManager.none? do |ems|
Module.const_defined?("#{ems.class}::CloudVolume") &&
ems.class::CloudVolume.supports?(:backup_restore)
"#{ems.class}::CloudVolume".safe_constantize&.supports?(:backup_restore)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe ApplicationHelper::Button::CloudVolumeBackupCreate do
describe "#disabled?" do
let(:view_context) { setup_view_context_with_sandbox({}) }
let(:button) { described_class.new(view_context, {}, {}, {}) }

context "with no providers" do
it "the button is disabled" do
expect(button.disabled?).to be true
end
end

context "with an OpenStack CloudManager supporting backup_create" do
before { FactoryBot.create(:ems_openstack) }

it "the button is enabled" do
expect(button.disabled?).to be false
end
end

context "with an Amazon CloudManager not supporting backup_create" do
before { FactoryBot.create(:ems_amazon) }

it "the button is disabled" do
expect(button.disabled?).to be true
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe ApplicationHelper::Button::CloudVolumeBackupRestore do
describe "#disabled?" do
let(:view_context) { setup_view_context_with_sandbox({}) }
let(:button) { described_class.new(view_context, {}, {}, {}) }

context "with no providers" do
it "the button is disabled" do
expect(button.disabled?).to be true
end
end

context "with an OpenStack CloudManager supporting backup_restore" do
before { FactoryBot.create(:ems_openstack) }

it "the button is enabled" do
expect(button.disabled?).to be false
end
end

context "with an Amazon CloudManager not supporting backup_restore" do
before { FactoryBot.create(:ems_amazon) }

it "the button is disabled" do
expect(button.disabled?).to be true
end
end
end
end

0 comments on commit 7e25777

Please sign in to comment.