diff --git a/Gemfile b/Gemfile index ebac87dd..84a21537 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index f6e27b37..d95d51b8 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/controllers/admin/callforpapers_controller.rb b/app/controllers/admin/callforpapers_controller.rb index 74eaaf2e..910b273e 100644 --- a/app/controllers/admin/callforpapers_controller.rb +++ b/app/controllers/admin/callforpapers_controller.rb @@ -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.') diff --git a/app/models/conference.rb b/app/models/conference.rb index 785068de..543d0e82 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/spec/factories/call_for_papers.rb b/spec/factories/call_for_papers.rb new file mode 100644 index 00000000..9da6c7fd --- /dev/null +++ b/spec/factories/call_for_papers.rb @@ -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 diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb new file mode 100644 index 00000000..1366fb65 --- /dev/null +++ b/spec/factories/conferences.rb @@ -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 diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 00000000..0334d49e --- /dev/null +++ b/spec/factories/users.rb @@ -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 diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb new file mode 100644 index 00000000..88d91e96 --- /dev/null +++ b/spec/models/conference_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 202b40eb..14c12c19 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb new file mode 100644 index 00000000..031f2a19 --- /dev/null +++ b/spec/support/factory_girl.rb @@ -0,0 +1,7 @@ +RSpec.configure do |config| + + config.before(:suite) do + FactoryGirl.lint + end + +end diff --git a/spec/support/seeds.rb b/spec/support/seeds.rb new file mode 100644 index 00000000..41e58998 --- /dev/null +++ b/spec/support/seeds.rb @@ -0,0 +1,7 @@ +RSpec.configure do |config| + + config.before(:suite) do + load "#{Rails.root}/db/seeds.rb" + end + +end