mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Add a blank poll options validation (#8652)
Before, saving a post with a blank poll option resulted in error 500.
This commit is contained in:
@@ -124,6 +124,36 @@ describe ::DiscoursePoll::PollsValidator do
|
||||
)
|
||||
end
|
||||
|
||||
it "ensures that polls do not have any blank options" do
|
||||
raw = <<~RAW
|
||||
[poll]
|
||||
* 1
|
||||
*
|
||||
[/poll]
|
||||
RAW
|
||||
|
||||
post.raw = raw
|
||||
expect(post.valid?).to eq(false)
|
||||
|
||||
expect(post.errors[:base]).to include(
|
||||
I18n.t("poll.default_poll_must_not_have_any_empty_options")
|
||||
)
|
||||
|
||||
raw = <<~RAW
|
||||
[poll name=test]
|
||||
*
|
||||
* 1
|
||||
[/poll]
|
||||
RAW
|
||||
|
||||
post.raw = raw
|
||||
expect(post.valid?).to eq(false)
|
||||
|
||||
expect(post.errors[:base]).to include(
|
||||
I18n.t("poll.named_poll_must_not_have_any_empty_options", name: "test")
|
||||
)
|
||||
end
|
||||
|
||||
it "ensure that polls have at least 2 options" do
|
||||
raw = <<~RAW
|
||||
[poll]
|
||||
|
||||
Reference in New Issue
Block a user