Skip to content

Commit

Permalink
Allow ResourceAction#fqname=nil to clear ae_*
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jul 5, 2023
1 parent 6482c01 commit 95b8e32
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 95b8e32

Please sign in to comment.