mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 22:21:11 +00:00
validate cfp start_date before end_date and end_date before conference.end_date
This commit is contained in:
parent
1edb4bff9e
commit
6e026746a9
7 changed files with 62 additions and 7 deletions
38
spec/models/cfp_spec.rb
Normal file
38
spec/models/cfp_spec.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe CallForPaper do
|
||||
let!(:conference) { create(:conference, end_date: Date.today) }
|
||||
|
||||
describe '#before_end_of_conference' do
|
||||
describe 'fails to save cfp' do
|
||||
it 'when cfp end_date is after conference end_date' do
|
||||
cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id)
|
||||
expect(cfp.valid?).to be false
|
||||
end
|
||||
|
||||
it 'when cfp start_date is after conference end_date' do
|
||||
cfp = build(:call_for_paper, end_date: Date.today + 1, conference_id: conference.id)
|
||||
expect(cfp.valid?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'successfully saves cfp' do
|
||||
it 'when cfp end_date and start_date are not after conference end_date' do
|
||||
cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id)
|
||||
expect(cfp.valid?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#start_after_end_date' do
|
||||
it 'fails when cfp start_date is after cfp end_date' do
|
||||
cfp = build(:call_for_paper, start_date: Date.today - 1, end_date: Date.today - 2, conference_id: conference.id)
|
||||
expect(cfp.valid?).to be false
|
||||
end
|
||||
|
||||
it 'succeeds when cfp start_date is after cfp end_date' do
|
||||
cfp = build(:call_for_paper, start_date: Date.today - 2, end_date: Date.today - 1, conference_id: conference.id)
|
||||
expect(cfp.valid?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@ require 'spec_helper'
|
|||
|
||||
describe Conference do
|
||||
|
||||
let(:subject) { create(:conference) }
|
||||
let(:subject) { create(:conference, end_date: '2014-06-30') }
|
||||
|
||||
describe '#write_event_distribution_to_db' do
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue