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

Keep full model name when parsing expression with tag #16211

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 lib/miq_expression/tag.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MiqExpression::Tag < MiqExpression::Target
REGEX = /
(?<model_name>([[:alnum:]]*(::)?)?)
(?<model_name>([[:alnum:]]*(::)?){4})
\.?(?<associations>([a-z_]+\.)*)
(?<namespace>\bmanaged|user_tag\b)
-(?<column>[a-z]+[_[:alnum:]]+)
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/miq_expression/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
:namespace => "/managed/service_level")
end

it "with model-parent::model.managed-in_tag" do
tag = "ManageIQ::Providers::CloudManager.managed-service_level"
expect(described_class.parse(tag)).to have_attributes(:model => ManageIQ::Providers::CloudManager,
:associations => [],
:namespace => "/managed/service_level")
end

it "with model.associations.associations.managed-in_tag" do
tag = "Vm.service.user.managed-service_level"
expect(described_class.parse(tag)).to have_attributes(:model => Vm,
Expand Down Expand Up @@ -63,6 +70,11 @@
tag = "Vm.managed"
expect(described_class.parse(tag)).to be_nil
end

it "returns nil with invalid case parent-model::model::somethingmanaged-se" do
tag = "ManageIQ::Providers::CloudManagermanaged-se'"
expect(described_class.parse(tag)).to be_nil
end
end

describe "#to_s" do
Expand Down