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

Fixes #12180 - lookup_value presence validation moved from lookup_key #2909

Closed
wants to merge 1 commit into from

Conversation

amirfefer
Copy link
Member

Global parameters can have empty values so smart variables that are also global should be allowed to accept empty values too.
The validation on lookup_value to make sure it isn't empty is in the LookupKey class therefore affecting both VariableLookupKey and PuppetClassLookupKey.
This validation should affect on the child class - PuppetClassLookupKey.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • cc3f03b must be in the format fixes #redmine_number - brief description.

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

param_not_posted = override_value.keys.first.to_s == 'match' ? 'Value' : 'Match' # The opposite of override_value is missing
assert_match /Validation failed: #{param_not_posted} can't be blank/, response['error']['message']
assert_response :error
test "should not create override value without match" do
Copy link
Member Author

Choose a reason for hiding this comment

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

value can be empty unless the lookup_key type is puppetclass

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 3992ee1 must be in the format fixes #redmine_number - brief description.

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@domcleal
Copy link
Contributor

Please note that tests are failing.

@@ -76,6 +76,10 @@ def self.find_by_name(str)
nil
end

def reject_invalid_lookup_values(attributes)
Copy link
Member

Choose a reason for hiding this comment

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

Removing the reject_if completely is what caused the integration test to fail.
When saving through the UI there wasn't a problem but in the integration test the fact that there is a hidden matcher (that is shown once you click + Add Matcher cause the form to refuse to be saved because of the validation added on lookup_value for empty values.
The hidden matcher has :match => "", :value => "" and tries to update on save and of course fails.
Adding reject_if to reject all lookup_values with empty matcher fixes the test.
This is also good to have since the validation on lookup_value is only for PuppetclassLookupKey and we still want to reject any type of lookup_key that doesn't contain a matcher.

@dLobatog
Copy link
Member

dLobatog commented Dec 4, 2015

@amirfefer @orrabin Thanks! It works pretty well from what I've seen, if we want to refactor this code a bit more though, take a look at the inline comments and let me know what you think. I hope it makes sense 😁

Global parameters can have empty values so smart variables that are also global should be allowed to accept empty values too.
The validation on lookup_value to make sure it isn't empty is in the LookupKey class therefore affecting both VariableLookupKey and PuppetClassLookupKey.
This validation should affect on the child class - PuppetClassLookupKey.
@amirfefer
Copy link
Member Author

@dLobatog I fixed all the test issues, the refactoring moved to 12822

@dLobatog
Copy link
Member

Merged as 2661491, thanks @amirfefer!

@dLobatog dLobatog closed this Dec 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants