Allow to modify the end date as long as it is not to the past

This commit is contained in:
Julian Herrero
2022-09-14 17:54:49 +02:00
committed by Javi Martín
parent 471096c698
commit 8b5c315eb0
2 changed files with 19 additions and 0 deletions

View File

@@ -69,6 +69,18 @@ describe Poll do
poll.starts_at = 10.days.from_now
expect(poll).not_to be_valid
end
it "is valid if changing the end date to a future date" do
poll.ends_at = 1.day.from_now
expect(poll).to be_valid
end
it "is not valid if changing the end date to a past date" do
poll = create(:poll, starts_at: 10.days.ago, ends_at: 10.days.from_now)
poll.ends_at = 1.day.ago
expect(poll).not_to be_valid
end
end
end