mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
* Survey period constraints * Add abilities * Enforce required questions * Update survey_submssion updated_at * Do a full match of possible answer and user reply
26 lines
915 B
Ruby
26 lines
915 B
Ruby
# 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.days, 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 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
|