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

Fix optional aware validator #97

Merged
merged 3 commits into from
Feb 17, 2018

Conversation

SuperTux88
Copy link
Member

Get optional props directly from the validated object which is much easier and safer than "guessing" the class name based on the validator name. That can cause a problem when another class with the same name is found (diaspora depends on the webfinger gem which has a WebFinger module, which obviously doesn't have the optional_props method). The "guessing" was only added because we used OpenStruct in the tests, but we shouldn't change the code only to make tests run. I changed the tests to use the real entities, with auto-validation disabled in the constructor, so we can test the validator manually.

Using the real entities for the tests also uncovered some bugs where for example empty strings are converted to nil and the validation wasn't invalid in this case, but should be.

This is a regression of #76

This is much easier and safer than "guessing" the class name based on
the validator name. That can cause a problem when another class with the
same name is found. The "guessing" was only added because we used
OpenStruct in the tests, but we shouldn't change the code only to make
tests run. I changed the tests to use the real entities, with
auto-validation disabled in the constructor, so we can test the
validator manually.
Using the real entities for the tests also uncovered some bugs where for
example empty strings are converted to nil and the validation wasn't
invalid in this case, but should be.
@SuperTux88 SuperTux88 merged commit c0b1417 into diaspora:develop Feb 17, 2018
SuperTux88 added a commit that referenced this pull request Feb 17, 2018
@SuperTux88
Copy link
Member Author

Merged, thanks for the review @jhass 🍪

@SuperTux88 SuperTux88 deleted the fix-optional-aware-validator branch February 17, 2018 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants