mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Conference Model tests
This commit is contained in:
parent
adfa9cc871
commit
aff37e8fb1
3 changed files with 78 additions and 21 deletions
1
Gemfile
1
Gemfile
|
|
@ -76,6 +76,7 @@ group :development, :test do
|
|||
gem 'rspec', '>= 3.0.0.beta'
|
||||
gem 'rspec-rails', '>= 3.0.0.beta'
|
||||
gem 'capybara'
|
||||
gem 'shoulda'
|
||||
end
|
||||
|
||||
# FIXME: We should use http://weblog.rubyonrails.org/2012/3/21/strong-parameters/
|
||||
|
|
|
|||
|
|
@ -248,6 +248,12 @@ GEM
|
|||
sass (~> 3.2.0)
|
||||
sprockets (~> 2.8, <= 2.11.0)
|
||||
sprockets-rails (~> 2.0)
|
||||
shoulda (3.5.0)
|
||||
shoulda-context (~> 1.0, >= 1.0.1)
|
||||
shoulda-matchers (>= 1.4.1, < 3.0)
|
||||
shoulda-context (1.2.1)
|
||||
shoulda-matchers (2.6.1)
|
||||
activesupport (>= 3.0.0)
|
||||
simplecov (0.8.2)
|
||||
docile (~> 1.1.0)
|
||||
multi_json
|
||||
|
|
@ -329,6 +335,7 @@ DEPENDENCIES
|
|||
rspec (>= 3.0.0.beta)
|
||||
rspec-rails (>= 3.0.0.beta)
|
||||
sass-rails (>= 4.0.2)
|
||||
shoulda
|
||||
spring-commands-rspec
|
||||
sqlite3
|
||||
transitions
|
||||
|
|
|
|||
|
|
@ -1,72 +1,121 @@
|
|||
#!/bin/env ruby
|
||||
# encoding: utf-8
|
||||
require 'spec_helper'
|
||||
|
||||
describe Conference do
|
||||
|
||||
let(:subject) { create(:conference) }
|
||||
|
||||
describe "#registration_open?" do
|
||||
describe '#registration_open?' do
|
||||
|
||||
context "closed registration" do
|
||||
context 'closed registration' do
|
||||
|
||||
it "#registration_open? is false" do
|
||||
it '#registration_open? is false' do
|
||||
expect(subject.registration_open?).to be false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "open registration" do
|
||||
context 'open registration' do
|
||||
|
||||
before do
|
||||
subject.registration_start_date = Date.today - 1
|
||||
subject.registration_end_date = Date.today + 7
|
||||
end
|
||||
|
||||
it "#registration_open? is true" do
|
||||
it '#registration_open? is true' do
|
||||
expect(subject.registration_open?).to be true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#cfp_open?" do
|
||||
describe '#cfp_open?' do
|
||||
|
||||
context "closed cfp" do
|
||||
context 'closed cfp' do
|
||||
|
||||
it "#cfp_open? is false" do
|
||||
it '#cfp_open? is false' do
|
||||
expect(subject.cfp_open?).to be false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "open cfp" do
|
||||
context 'open cfp' do
|
||||
|
||||
before do
|
||||
subject.call_for_papers = create(:call_for_papers)
|
||||
end
|
||||
|
||||
it "#registration_open? is true" do
|
||||
it '#registration_open? is true' do
|
||||
expect(subject.cfp_open?).to be true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "#user_registered?" do
|
||||
describe '#user_registered?' do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
|
||||
context "user not registered" do
|
||||
it "#user_registered? is false" do
|
||||
context 'user not registered' do
|
||||
it '#user_registered? is false' do
|
||||
expect(subject.user_registered? user).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "user registered" do
|
||||
context 'user registered' do
|
||||
pending "isn't tested yet"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe 'validations' do
|
||||
|
||||
it 'has a valid factory' do
|
||||
expect(build(:conference)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a title' do
|
||||
should validate_presence_of(:title)
|
||||
end
|
||||
|
||||
it 'is not valid without a short title' do
|
||||
should validate_presence_of(:short_title)
|
||||
end
|
||||
|
||||
it 'is not valid without a social tag' do
|
||||
should validate_presence_of(:social_tag)
|
||||
end
|
||||
|
||||
it 'is not valid without a start date' do
|
||||
should validate_presence_of(:start_date)
|
||||
end
|
||||
|
||||
it 'is not valid without an end date' do
|
||||
should validate_presence_of(:end_date)
|
||||
end
|
||||
|
||||
it 'is not valid with a duplicate short title' do
|
||||
should validate_uniqueness_of(:short_title)
|
||||
end
|
||||
|
||||
it 'is valid with a short title that contains a-zA-Z0-9_-' do
|
||||
should allow_value('abc_xyz-ABC-XYZ-012_89').for(:short_title)
|
||||
end
|
||||
|
||||
it 'is not valid with a short title that contains special characters' do
|
||||
should_not allow_value('&%§!?äÄüÜ/()').for(:short_title)
|
||||
end
|
||||
|
||||
describe 'before create callbacks' do
|
||||
|
||||
it 'has an email setting after creation' do
|
||||
expect(subject.email_settings).not_to be_nil
|
||||
end
|
||||
|
||||
it 'has a venue after creation' do
|
||||
expect(subject.venue).not_to be_nil
|
||||
end
|
||||
|
||||
it 'has a guid after creation' do
|
||||
expect(subject.guid).not_to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue