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

[Backport] Fix milestone validation #3101

Merged
merged 3 commits into from
Dec 13, 2018
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented Dec 11, 2018

References

Objectives

Make the admin form display a validation error when both description and status are blank.

The same cases are tested in the previous `describe` block.
We had a validation rule for milestones which made sure either the
status or the description was present. However, since the description is
now translatable, the validation error wasn't being displayed in the
admin form.

Moving the validation rule to the translation object fixes the problem.
However, the translation object needs to check an attribute in the
milestone object in order to know whether the description is required or
not. This is tricky because by default it loads the milestone object
from the database, meaning it doesn't work with new records and it
ignores params sent by the browser.

The solution is to manually assign the globalized model before
validating the object. It's a hack, but apparently Rails doesn't provide
a better way to handle this case [1].

[1] rails/rails#32024
@javierm
Copy link
Member Author

javierm commented Dec 12, 2018

Travis failure isn't related to this code.

@javierm javierm merged commit 33ea921 into master Dec 13, 2018
@javierm javierm deleted the backport-fix_milestone_validation branch December 13, 2018 11:05
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.

None yet

2 participants