mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
First tests in rspec, with factory_girl
This commit is contained in:
parent
accd7d1a58
commit
e3fd0c195a
11 changed files with 131 additions and 19 deletions
3
Gemfile
3
Gemfile
|
|
@ -22,8 +22,9 @@ group :development, :test do
|
|||
gem 'thin'
|
||||
gem 'letter_opener'
|
||||
gem 'rspec-rails', '~> 3.0.0.beta'
|
||||
gem 'capybara', '1.1.2'
|
||||
gem 'capybara'
|
||||
gem 'rdoc-generator-fivefish'
|
||||
gem 'factory_girl_rails'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
|
|
|||
26
Gemfile.lock
26
Gemfile.lock
|
|
@ -52,15 +52,12 @@ GEM
|
|||
sass (~> 3.2)
|
||||
builder (3.0.4)
|
||||
cancan (1.6.10)
|
||||
capybara (1.1.2)
|
||||
capybara (2.2.1)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.5.1)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
xpath (~> 2.0)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.3)
|
||||
|
|
@ -80,7 +77,11 @@ GEM
|
|||
erubis (2.7.0)
|
||||
eventmachine (1.0.3)
|
||||
execjs (2.0.2)
|
||||
ffi (1.9.3)
|
||||
factory_girl (4.4.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.4.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
railties (>= 3.0.0)
|
||||
formtastic (2.2.1)
|
||||
actionpack (>= 3.0)
|
||||
formtastic-bootstrap (3.0.0)
|
||||
|
|
@ -114,7 +115,7 @@ GEM
|
|||
treetop (~> 1.4.8)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.5.2)
|
||||
mini_portile (0.5.3)
|
||||
multi_json (1.9.2)
|
||||
mysql2 (0.3.15)
|
||||
nokogiri (1.6.1)
|
||||
|
|
@ -196,11 +197,6 @@ GEM
|
|||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
tilt (~> 1.3)
|
||||
selenium-webdriver (2.40.0)
|
||||
childprocess (>= 0.5.0)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip (~> 1.0)
|
||||
websocket (~> 1.0.4)
|
||||
slop (3.4.7)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
|
|
@ -230,9 +226,8 @@ GEM
|
|||
json (>= 1.8.0)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
websocket (1.0.7)
|
||||
will_paginate (3.0.5)
|
||||
xpath (0.1.4)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
yajl-ruby (1.2.0)
|
||||
|
||||
|
|
@ -246,10 +241,11 @@ DEPENDENCIES
|
|||
bcrypt-ruby (~> 3.0.0)
|
||||
bootstrap-sass
|
||||
cancan
|
||||
capybara (= 1.1.2)
|
||||
capybara
|
||||
cocoon
|
||||
d3_rails
|
||||
devise
|
||||
factory_girl_rails
|
||||
formtastic-bootstrap
|
||||
gravtastic
|
||||
haml
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Admin::CallforpapersController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@cfp = CallForPapers.new(params[:call_for_papers])
|
||||
@cfp = CallForPapers.new(params[:call_for_papers])
|
||||
@conference.call_for_papers = @cfp
|
||||
if @cfp.save
|
||||
redirect_to(admin_conference_cfp_info_path(:id => @conference.short_title), :notice => 'Call for Papers was successfully updated.')
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Conference < ActiveRecord::Base
|
|||
:start_date, :end_date, :rooms_attributes, :tracks_attributes, :dietary_choices_attributes,
|
||||
:use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, :social_events_attributes,
|
||||
:event_types_attributes, :registration_start_date, :registration_end_date, :logo,
|
||||
:questions_attributes, :question_ids, :answers_attributes, :answer_ids,
|
||||
:questions_attributes, :question_ids, :answers_attributes, :answer_ids,
|
||||
:difficulty_levels_attributes, :use_difficulty_levels,
|
||||
:use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ class Conference < ActiveRecord::Base
|
|||
# * +true+ -> If today is in the registration period.
|
||||
def registration_open?
|
||||
today = Date.current
|
||||
if self.registration_start_date.nil? || self.registration_end_date.nil?
|
||||
if self.registration_start_date.blank? || self.registration_end_date.blank?
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
|||
10
spec/factories/call_for_papers.rb
Normal file
10
spec/factories/call_for_papers.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :call_for_papers do
|
||||
start_date Date.today - 1
|
||||
end_date Date.today + 7
|
||||
hard_deadline Date.today + 8
|
||||
description "We call for papers"
|
||||
end
|
||||
end
|
||||
13
spec/factories/conferences.rb
Normal file
13
spec/factories/conferences.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :conference do
|
||||
title "The dog and pony show"
|
||||
short_title "dps14"
|
||||
social_tag "dps14"
|
||||
timezone "Amsterdam"
|
||||
contact_email "admin@example.com"
|
||||
start_date Date.today
|
||||
end_date Date.tomorrow
|
||||
end
|
||||
end
|
||||
10
spec/factories/users.rb
Normal file
10
spec/factories/users.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :user do
|
||||
email 'example@example.com'
|
||||
password 'changeme'
|
||||
password_confirmation 'changeme'
|
||||
confirmed_at Time.now
|
||||
end
|
||||
end
|
||||
60
spec/models/conference_spec.rb
Normal file
60
spec/models/conference_spec.rb
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Conference do
|
||||
before do
|
||||
@conference = create(:conference)
|
||||
end
|
||||
|
||||
|
||||
describe "#registration_open?" do
|
||||
context "closed registration" do
|
||||
it "#registration_open? is false" do
|
||||
expect(@conference.registration_open?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "open registration" do
|
||||
before do
|
||||
@conference.registration_start_date = Date.today - 1
|
||||
@conference.registration_end_date = Date.today + 7
|
||||
end
|
||||
it "#registration_open? is true" do
|
||||
expect(@conference.registration_open?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#cfp_open?" do
|
||||
context "closed cfp" do
|
||||
it "#cfp_open? is false" do
|
||||
expect(@conference.cfp_open?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "open cfp" do
|
||||
before do
|
||||
@cfp = create(:call_for_papers)
|
||||
@conference.call_for_papers = @cfp
|
||||
end
|
||||
it "#registration_open? is true" do
|
||||
expect(@conference.cfp_open?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#user_registered?" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
end
|
||||
context "user not registered" do
|
||||
it "#user_registered? is false" do
|
||||
expect(@conference.user_registered? @user).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "user registered" do
|
||||
pending "isn't tested yet"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -34,4 +34,12 @@ RSpec.configure do |config|
|
|||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = "random"
|
||||
|
||||
# Include factory_girls syntax
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
|
||||
# As we start from scratch in April 2014, let's forbid the old :should syntax
|
||||
config.expect_with :rspec do |c|
|
||||
c.syntax = :expect
|
||||
end
|
||||
end
|
||||
|
|
|
|||
7
spec/support/factory_girl.rb
Normal file
7
spec/support/factory_girl.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
RSpec.configure do |config|
|
||||
|
||||
config.before(:suite) do
|
||||
FactoryGirl.lint
|
||||
end
|
||||
|
||||
end
|
||||
7
spec/support/seeds.rb
Normal file
7
spec/support/seeds.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
RSpec.configure do |config|
|
||||
|
||||
config.before(:suite) do
|
||||
load "#{Rails.root}/db/seeds.rb"
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue