Skip to content

Commit

Permalink
Prevent unsupported classes from being added
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jun 10, 2019
1 parent ff66d85 commit 1581d20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.supported_types_for_create
end

def self.supported_for_create?
!reflections.include?("parent_manager")
ExtManagementSystem.supported_types_and_descriptions_hash.key?(ems_type) && !reflections.include?("parent_manager")
end

belongs_to :provider
Expand Down
10 changes: 10 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
expect(ems.total_storages).to eq 2
end

context "supported_for_create?" do
it "base class is unsupported" do
expect(FactoryBot.create(:ext_management_system).class.supported_for_create?).to eq(false)
end

it "supported class is supported" do
expect(FactoryBot.create(:ems_vmware).class.supported_for_create?).to eq(true)
end
end

context "#hostname / #hostname=" do
it "will delegate to the default endpoint" do
ems = FactoryBot.build(:ems_vmware, :hostname => "example.org")
Expand Down

0 comments on commit 1581d20

Please sign in to comment.