Split polls date range validation
It was a bit strange to leave the end date blank and have a message associated with the start date, so we're using presence validations instead. For the range validation, we're using the comparison validator included in Rails 7.0.
This commit is contained in:
@@ -24,12 +24,14 @@ describe Poll do
|
||||
poll.starts_at = nil
|
||||
|
||||
expect(poll).not_to be_valid
|
||||
expect(poll.errors[:starts_at]).to eq ["Invalid date range"]
|
||||
expect(poll.errors[:starts_at]).to eq ["can't be blank"]
|
||||
end
|
||||
|
||||
it "is not valid without an end date" do
|
||||
poll.ends_at = nil
|
||||
|
||||
expect(poll).not_to be_valid
|
||||
expect(poll.errors[:ends_at]).to eq ["can't be blank"]
|
||||
end
|
||||
|
||||
it "is not valid without a proper start/end date range" do
|
||||
|
||||
Reference in New Issue
Block a user