-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add association of service_templates to TransformationMapping. #17266
Conversation
app/models/transformation_mapping.rb
Outdated
def destination(source) | ||
transformation_mapping_items.find_by(:source => source).try(:destination) | ||
end | ||
|
||
def service_template_transformation_plans |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual logic does not filter for ServiceTemplateTransformationPlan
although in reality they are likely always transformation plan. Should we relax the method name just service_templates
?
@lfu can you do an API test? Manual test is OK. |
2c33e10
to
b4d8280
Compare
app/models/transformation_mapping.rb
Outdated
@@ -3,7 +3,13 @@ class TransformationMapping < ApplicationRecord | |||
|
|||
validates :name, :presence => true, :uniqueness => true | |||
|
|||
virtual_has_many :service_template_transformation_plans |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual_has_many :service_templates
b4d8280
to
f6178b3
Compare
@bzwei API test went well.
|
app/models/transformation_mapping.rb
Outdated
@@ -3,7 +3,13 @@ class TransformationMapping < ApplicationRecord | |||
|
|||
validates :name, :presence => true, :uniqueness => true | |||
|
|||
virtual_has_many :service_templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a regular has_many :through
to avoid the collect
?
cc @kbrock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea. remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the ping brandon - yes, I think a regular association works better here
app/models/transformation_mapping.rb
Outdated
@@ -3,7 +3,13 @@ class TransformationMapping < ApplicationRecord | |||
|
|||
validates :name, :presence => true, :uniqueness => true | |||
|
|||
virtual_has_many :service_templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea. remove this line
app/models/transformation_mapping.rb
Outdated
def destination(source) | ||
transformation_mapping_items.find_by(:source => source).try(:destination) | ||
end | ||
|
||
def service_templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_many :service_resources
has_many :service_templates, :through => :service_resources
@@ -18,4 +18,13 @@ | |||
expect(mapping.destination(FactoryGirl.create(:ems_cluster))).to be_nil | |||
end | |||
end | |||
|
|||
describe '#service_templates' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specs look good - this will be able to test if the real relation works as well as the virtual one
f6178b3
to
15758bc
Compare
15758bc
to
082c288
Compare
082c288
to
71f732c
Compare
Checked commit lfu@71f732c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/models/transformation_mapping.rb
|
Yay. looking good lucy |
Add association of service_templates to TransformationMapping. (cherry picked from commit 802d601)
Gaprindashvili backport details:
|
A transformation mapping may be used by many service_template_transformation_plans.
@miq-bot assign @gmcculloug
@miq-bot add_label enhancement, transformation
cc @bzwei