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:
Javi Martín
2024-04-12 22:47:56 +02:00
parent da86254fe5
commit 00c97ad587
2 changed files with 14 additions and 8 deletions

View File

@@ -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