From c4bddc9855886b4ba60316fbcbc04375ee720da7 Mon Sep 17 00:00:00 2001 From: Victor Lee <43049052+leevic31@users.noreply.github.com> Date: Tue, 17 Oct 2023 08:56:24 -0400 Subject: [PATCH] Add spec for poll model (#23399) Co-authored-by: Nick Schonning Co-authored-by: Claire --- spec/models/poll_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/models/poll_spec.rb b/spec/models/poll_spec.rb index 8ae04ca41..5aa5548cc 100644 --- a/spec/models/poll_spec.rb +++ b/spec/models/poll_spec.rb @@ -29,4 +29,23 @@ describe Poll do end end end + + describe 'validations' do + context 'when valid' do + let(:poll) { Fabricate.build(:poll) } + + it 'is valid with valid attributes' do + expect(poll).to be_valid + end + end + + context 'when not valid' do + let(:poll) { Fabricate.build(:poll, expires_at: nil) } + + it 'is invalid without an expire date' do + poll.valid? + expect(poll).to model_have_error_on_field(:expires_at) + end + end + end end