forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#7057 from agrare/fix_issues_constantizing…
…_cloud_volumes Fix constantizing CloudVolume for disable? check
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
app/helpers/application_helper/button/cloud_volume_backup_create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 1 addition & 2 deletions
3
app/helpers/application_helper/button/cloud_volume_backup_restore.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
28 changes: 28 additions & 0 deletions
28
spec/helpers/application_helper/buttons/cloud_volume_backup_create_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
28 changes: 28 additions & 0 deletions
28
spec/helpers/application_helper/buttons/cloud_volume_backup_restore_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |