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

Refs #35236 - ak update requires the existence of organization #10414

Merged
merged 1 commit into from Jan 19, 2023

Conversation

lfu
Copy link
Member

@lfu lfu commented Jan 12, 2023

What are the changes introduced in this pull request?

Make sure organization exists to avoid an error like:

Could not update the activation key:
  undefined method `library' for nil:NilClass

Considerations taken when implementing this change?

Followup of #10200

What are the testing steps for this pull request?

hammer activation-key update --name=test5 --organization-id=1 --release-version='willthiswork'
Before

Could not update the activation key:
  undefined method `library' for nil:NilClass

After

Could not update the activation key:
  Invalid release version: [willthiswork]

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Works well!

Before:

$ hammer activation-key update --name=dev --organization-id=1 --release-version=8
Could not update the activation key:
  undefined method `library' for nil:NilClass

After:

$ hammer activation-key update --name=dev --organization-id=1 --release-version=8
Activation key updated.

$ hammer activation-key update --name=dev --organization-id=1 --release-version="hoo"
Could not update the activation key:
  Invalid release version: [hoo]

I'd also like to see a test added that reflects this change.

@lfu lfu changed the title Ref #35236 - ak update requires the existence of organization Refs #35236 - ak update requires the existence of organization Jan 17, 2023
@lfu lfu force-pushed the update_invalid_release_version_35236 branch from c78b630 to ac6cf9a Compare January 17, 2023 21:52
@lfu lfu force-pushed the update_invalid_release_version_35236 branch from ac6cf9a to cf4f033 Compare January 17, 2023 21:53
Comment on lines 299 to 302
activation_key = ActivationKey.new(
:name => 'new key', :organization => @organization
)
assert activation_key.save
Copy link
Member

Choose a reason for hiding this comment

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

We're not testing the model's validity here, so I'd say the assert .. save isn't needed. (It's probably not needed in the previous test either.) I'd just go with ActivationKey.create!

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

@lfu Test looks good, but there's a Rubocop issue.

APJ 👍

@lfu lfu force-pushed the update_invalid_release_version_35236 branch from 219a307 to b25b238 Compare January 19, 2023 16:27
@lfu lfu merged commit 243704d into Katello:master Jan 19, 2023
@lfu lfu deleted the update_invalid_release_version_35236 branch November 16, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants