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

Test on Ruby 3 #612

Closed
wants to merge 1 commit into from
Closed

Test on Ruby 3 #612

wants to merge 1 commit into from

Conversation

ofedoren
Copy link
Member

Please, don't merge just yet. Foreman on Ruby 3.0 is still in progress.

@@ -78,7 +78,7 @@ class Engine < ::Rails::Engine
full_name: N_("Hostname facts"),
description: N_("List of facts to use for the hostname (first wins)")

validates "discovery_hostname", presence: true
Copy link
Member

Choose a reason for hiding this comment

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

It surprises me this is needed. Can't we look at the validates method to see if presence: true can be made valid?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only if we change its signature: https://github.com/theforeman/foreman/blob/develop/app/registries/foreman/setting_manager.rb#L58

I mean, currently validates expects 2 arguments. Due to new Ruby kwargs, they are not considered as an implicit Hash argument.

As a solution I'd suggest to finally use kwargs as Ruby wants or we could make second (validations) parameter to be optional (validations = {}).

Copy link
Member

Choose a reason for hiding this comment

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

It's supposed to map to ActiveModel::Validations::ClassMethods.validates and that uses def validates(*attributes). I'm not sure that is a great API.

So I think adjusting the signature is the right thing. Just not 100% sure what it should be. Perhaps:

def validates(name, **validations)

And then special case if :proc is in validations.

Copy link
Member Author

Choose a reason for hiding this comment

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

That could be, but since the old signature accepts proc as an argument (not nested under :proc key), we would still need to update places which use that. I think we would need to adjust plugins anyway if we change the signature.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps def validates(name, proc = nil, **validations) would work?

Copy link
Member

Choose a reason for hiding this comment

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

Let's see if #622 works.

@ekohl
Copy link
Member

ekohl commented Feb 14, 2024

I think #622 replaces this.

@ofedoren
Copy link
Member Author

Closing in favor of #622

@ofedoren ofedoren closed this Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants