Skip to content

Commit

Permalink
Merge pull request ManageIQ#22600 from agrare/allow_fqname_eql_set_to…
Browse files Browse the repository at this point in the history
…_nil

Allow `ResourceAction#fqname=nil` to clear `ae_*`
  • Loading branch information
Fryguy authored Jul 5, 2023
2 parents e397f20 + 95b8e32 commit 4b5fe60
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def automate_queue_hash(target, override_attrs, user, open_url_task_id = nil)
end

def fqname=(value)
self.ae_namespace, self.ae_class, self.ae_instance, _attr_name = MiqAeEngine::MiqAePath.split(value)
self.ae_namespace, self.ae_class, self.ae_instance, _attr_name = value.blank? ? nil : MiqAeEngine::MiqAePath.split(value)
end

def fqname
Expand Down
27 changes: 27 additions & 0 deletions spec/models/resource_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@
let(:user) { FactoryBot.create(:user_with_group) }
let(:ra) { FactoryBot.create(:resource_action) }

describe "#fqname=" do
context "with an automate fully-qualified name" do
it "sets the ae_* attributes" do
ra.fqname = "/NAMESPACE/CLASS/INSTANCE"
expect(ra).to have_attributes(
:ae_namespace => "NAMESPACE",
:ae_class => "CLASS",
:ae_instance => "INSTANCE"
)
end
end

context "with a nil" do
context "with existing ae_attributes" do
let(:ra) { FactoryBot.create(:resource_action, :ae_namespace => "NAMESPACE", :ae_class => "CLASS", :ae_instance => "INSTANCE") }
it "clears the ae_* attributes" do
ra.fqname = nil
expect(ra).to have_attributes(
:ae_namespace => nil,
:ae_class => nil,
:ae_instance => nil
)
end
end
end
end

context "#deliver_queue" do
let(:zone_name) { "default" }
let(:miq_server) { FactoryBot.create(:miq_server) }
Expand Down

0 comments on commit 4b5fe60

Please sign in to comment.