-
Notifications
You must be signed in to change notification settings - Fork 896
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
[rails6][service_template_ansible_playbook_spec.rb] Fix ems/provider lets #20787
[rails6][service_template_ansible_playbook_spec.rb] Fix ems/provider lets #20787
Conversation
@miq-bot add_label rails6 |
…lets This fix takes a page from a PR from David: ManageIQ#20031 Which was that instead of trying to assign the provider prior to making the EMS in the factories, default a provider object type as part of the `ext_management_system` child definition, and reference it in the `let(:provider)`. This is not a problem in Rails 5.2, but does lead to the following error in Rails 6.0 5) ServiceTemplateAnsiblePlaybook.create_catalog_item creates and returns a catalog item Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args) ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection: Cannot modify association 'ManageIQ::Providers::EmbeddedAnsible::Provider#endpoints' because the source reflection class 'Endpoint' is associated to 'ExtManagementSystem' via :has_many. # ./spec/support/missing_factory_helper.rb:10:in `create' # ./spec/models/service_template_ansible_playbook_spec.rb:11:in `block (2 levels) in <top (required)>' # ./spec/models/service_template_ansible_playbook_spec.rb:7:in `block (2 levels) in <top (required)>' # ./spec/models/service_template_ansible_playbook_spec.rb:15:in `block (2 levels) in <top (required)>' # ./spec/models/service_template_ansible_playbook_spec.rb:40:in `block (2 levels) in <top (required)>' # ./spec/models/service_template_ansible_playbook_spec.rb:47:in `block (2 levels) in <top (required)>' # ./spec/models/service_template_ansible_playbook_spec.rb:82:in `block (3 levels) in <top (required)>' Most likely do to a fix that I was unable to track down, but the following `git log command` is most likely to contain some of the commits with the fix: $ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
c4a124d
to
79c2826
Compare
Checked commit NickLaMuro@79c2826 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint |
This seems to have caused manageiq-content to start failing: https://travis-ci.com/github/ManageIQ/manageiq-content/jobs/432734386#L1996-L2003 |
@agrare thanks for the heads up. I will take a look at it later today |
So just a bit of a update: Seems like doing:
Creates 2 |
Okay, yes, it looks like the I think the solution for this is to deprecate creating I will try that out and see how that works. |
This is a follow up to 02e4b85 as the solution provided there, while works for this use case, ended up causing problems in `ManageIQ/manageiq-content`: ManageIQ/manageiq#20787 (comment) Instead, we use the :provider_embedded_ansible factory, and reference the `.automation_manager` from that. In addition, since a update to the `:inventory_root_groups` was needed, we also modify the record in a `before` statement as well. This ends up not being as clean as the previous implementation, but makes sure we are using the `EmbeddedAnsible` provider in the form that it would be called when used in the application.
This is a follow up to 02e4b85 as the solution provided there, while works for this use case, ended up causing problems in `ManageIQ/manageiq-content`: ManageIQ/manageiq#20787 (comment) Instead, we use the :provider_embedded_ansible factory, and reference the `.automation_manager` from that. In addition, since a update to the `:inventory_root_groups` was needed, we also modify the record in a `before` statement as well. This ends up not being as clean as the previous implementation, but makes sure we are using the `EmbeddedAnsible` provider in the form that it would be called when used in the application.
This is a follow up to 02e4b85 as the solution provided there, while works for this use case, ended up causing problems in `ManageIQ/manageiq-content`: ManageIQ/manageiq#20787 (comment) Instead, we use the :provider_embedded_ansible factory, and reference the `.automation_manager` from that. In addition, since a update to the `:inventory_root_groups` was needed, we also modify the record in a `before` statement as well. This ends up not being as clean as the previous implementation, but makes sure we are using the `EmbeddedAnsible` provider in the form that it would be called when used in the application.
This is a follow up to 02e4b85 as the solution provided there, while works for this use case, ended up causing problems in `ManageIQ/manageiq-content`: ManageIQ/manageiq#20787 (comment) Instead, we use the :provider_embedded_ansible factory, and reference the `.automation_manager` from that. In addition, since a update to the `:inventory_root_groups` was needed, we also modify the record in a `before` statement as well. This ends up not being as clean as the previous implementation, but makes sure we are using the `EmbeddedAnsible` provider in the form that it would be called when used in the application.
Merge ManageIQ#7508 instead! This is a follow up to 02e4b85 as the solution provided there, while works for this use case, ended up causing problems in `ManageIQ/manageiq-content`: ManageIQ/manageiq#20787 (comment) Instead, we use the :provider_embedded_ansible factory, and reference the `.automation_manager` from that. In addition, since a update to the `:inventory_root_groups` was needed, we also modify the record in a `before` statement as well. This ends up not being as clean as the previous implementation, but makes sure we are using the `EmbeddedAnsible` provider in the form that it would be called when used in the application.
This fix takes a page from a PR from @skateman:
#20031
Which was that instead of trying to assign the provider prior to making the EMS in the factories, default a provider object type as part of the
ext_management_system
child definition, and reference it in thelet(:provider)
.This is not a problem in Rails 5.2, but does lead to the following error in Rails 6.0
Most likely do to a fix that I was unable to track down, but the following
git log command
is most likely to contain some of the commits with the fix:$ git log --oneline -E --grep "has.*many.*through" 5-2-stable..6-0-stable
Links