Add survey related tests
This commit is contained in:
parent
68a8ec2204
commit
c278e547ce
8 changed files with 198 additions and 1 deletions
28
spec/models/survey_spec.rb
Normal file
28
spec/models/survey_spec.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Survey do
|
||||
subject { create(:survey) }
|
||||
let(:survey_active) { create(:conference_survey, start_date: Date.current - 1.day, end_date: Date.current + 1.day) }
|
||||
let(:survey_inactive) { create(:conference_survey, start_date: Date.current - 2.day, end_date: Date.current - 1.day) }
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to have_many(:survey_questions) }
|
||||
it { is_expected.to have_many(:survey_submissions) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
it { is_expected.to validate_presence_of(:title) }
|
||||
end
|
||||
|
||||
describe '#active?' do
|
||||
it { expect(survey_active.active?).to eq true }
|
||||
it { expect(survey_inactive.active?).to eq false }
|
||||
it 'returns false, if start_date is not set' do
|
||||
expect(create(:survey, start_date: nil, end_date: Date.current + 1.day).active?).to eq false
|
||||
end
|
||||
|
||||
it 'returns false, if end_date is not set' do
|
||||
expect(create(:survey, start_date: Date.current + 1.day, end_date: nil).active?).to eq false
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue