-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Validate presence 'poll_id' attribute on Poll::Question model #1868
Validate presence 'poll_id' attribute on Poll::Question model #1868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spec cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
@aitbw only one problem with tests, I've run three times locally
Because of the |
I'll fix it right away. Should I fix the issue, rebase and update the PR or a new commit would be better, @bertocq? |
@aitbw I think in the same commit that you were expecting poll not to be nil that fix could be as well in context of the rest of the commit, right? "Same commit" I mean :) |
Fixes consuldemocracy#1831 On branch aperez-validate-poll-question-is-selected Changes to be committed: modified: app/models/poll/question.rb modified: spec/models/poll/question_spec.rb modified: spec/features/admin/poll/polls_spec.rb
a2082d6
to
5b5f6cf
Compare
The failing spec is fixed, so you shouldn't have any problems with it, @bertocq :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
On branch aperez-validate-poll-question-is-selected Changes to be committed: modified: spec/models/poll/question_spec.rb
5b5f6cf
to
15ccef8
Compare
Where
Fixes #1831
What
Validates presence of
poll_id
attribute onPoll::Question
model, which previously allowed a question to be created with no association to a pollHow
Added the necessary validation on the
Poll::Question
modelScreenshots
Here's how the form looks when a poll is not selected
Test
Added tests for both valid and invalid scenarios, also did a small refactor to improve DRYness for the related spec