FIX: Actually error when topic timer time is in the past (#11434)

This commit is contained in:
Mark VanLandingham
2020-12-08 11:13:45 -06:00
committed by GitHub
parent b824af02d4
commit 9f786306bd
4 changed files with 21 additions and 6 deletions

View File

@ -1756,10 +1756,13 @@ describe Topic do
it "sets a validation error when given a timestamp in the past" do
freeze_time now
topic.set_or_create_timer(TopicTimer.types[:close], '2013-11-19 5:00', by_user: admin)
expect(topic.topic_timers.first.execute_at).to eq_time(Time.zone.local(2013, 11, 19, 5, 0))
expect(topic.topic_timers.first.errors[:execute_at]).to be_present
expect do
topic.set_or_create_timer(
TopicTimer.types[:close],
'2013-11-19 5:00', by_user: admin
)
end.to raise_error(Discourse::InvalidParameters)
end
it "sets a validation error when give a timestamp of an invalid format" do