Skip to content

Commit

Permalink
This scope accepts class objects, pass strings to where
Browse files Browse the repository at this point in the history
Fixes:
DEPRECATION WARNING: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead. (called from block in <class:ExtManagementSystem> at /Users/joerafaniello/Code/manageiq/app/models/ext_management_system.rb:107)

Similar to ManageIQ#18827
  • Loading branch information
jrafanie authored and thearifismail committed Jun 3, 2019
1 parent 2a12dbd commit cd6b96d
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -104,7 +104,7 @@ def self.supported_for_create?

validate :validate_ems_enabled_when_zone_changed?, :validate_zone_not_maintenance_when_ems_enabled?

scope :with_eligible_manager_types, ->(eligible_types) { where(:type => eligible_types) }
scope :with_eligible_manager_types, ->(eligible_types) { where(:type => Array(eligible_types).collect(&:to_s)) }

serialize :options

Expand Down
9 changes: 9 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
expect(described_class.ems_infra_discovery_types).to match_array(expected_types)
end

it ".with_eligible_manager_types" do
v = FactoryBot.create(:ems_vmware)
r = FactoryBot.create(:ems_redhat)

expect(described_class.with_eligible_manager_types([v.class, r.class]).count).to eq(2)
expect(described_class.with_eligible_manager_types([v.class]).count).to eq(1)
expect(described_class.with_eligible_manager_types(r.class).count).to eq(1)
end

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

0 comments on commit cd6b96d

Please sign in to comment.