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

[EmbeddedAnsible::CrudCommon] Fix manager validation #20880

Merged

Conversation

NickLaMuro
Copy link
Member

Putting this back as this was used in the specs to validate the correct manager was being used in the credential_spec.rb for EmbeddedAnsible:

  it ".create_in_provider_queue will fail with incompatible manager" do
    wrong_manager = FactoryBot.create(:configuration_manager_foreman)
    expect { credential_class.create_in_provider_queue(wrong_manager.id, params) }.to raise_error(ActiveRecord::RecordNotFound)
  end

While there may be a better way of doing this, deleting the spec seems like the wrong way to fix this issue, and this was originally removed because it was assumed it wasn't needed.

For now, I at least added a comment in line, and fixed the unused variable issue so it is more apparent this is being used as a validation, and not the result being used later.

Links

Putting this back as this was used in the specs to validate the correct
manager was being used in the credential_spec.rb for `EmbeddedAnsible`:

  it ".create_in_provider_queue will fail with incompatible manager" do
    wrong_manager = FactoryBot.create(:configuration_manager_foreman)
    expect { credential_class.create_in_provider_queue(wrong_manager.id, params) }.to raise_error(ActiveRecord::RecordNotFound)
  end

While there may be a better way of doing this, deleting the spec seems
like the wrong way to fix this issue, and this was originally removed
because it was assumed it wasn't needed.
@miq-bot
Copy link
Member

miq-bot commented Dec 9, 2020

Checked commit NickLaMuro@89d3b8a with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@@ -50,6 +50,7 @@ def encrypt_queue_params(params)
end

def create_in_provider_queue(manager_id, params, auth_user = nil)
parent.find(manager_id) # validation that the manager ID is from EmbeddedAnsible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to leave this in, then can we disable the Lint/UselessAssignment cop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djberg96 I didn't assign anything, so there is nothing to disable. That is the one change I did make to this line.

@agrare agrare merged commit 513c671 into ManageIQ:master Dec 9, 2020
@Fryguy
Copy link
Member

Fryguy commented Dec 9, 2020

👍 Thanks @NickLaMuro ... Minor, but performance-wise, this can probably be parent.exists?(manager_id) (just to avoid returning an object)

@Fryguy Fryguy added the bug label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants