Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ResourceAction#fqname=nil to clear ae_* #22600

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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