Add more options for surveys
* Survey period constraints * Add abilities * Enforce required questions * Update survey_submssion updated_at * Do a full match of possible answer and user reply
This commit is contained in:
parent
c278e547ce
commit
683f62a27c
36 changed files with 219 additions and 74 deletions
|
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
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) }
|
||||
let(:survey_inactive) { create(:conference_survey, start_date: Date.current - 2.days, end_date: Date.current - 1.day) }
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to have_many(:survey_questions) }
|
||||
|
|
@ -17,12 +19,8 @@ describe Survey do
|
|||
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
|
||||
it 'returns true, if both start_date and end_date are not set' do
|
||||
expect(create(:survey, start_date: nil, end_date: nil, surveyable: create(:conference)).active?).to eq true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue