Permalink
Browse files

validations for sessions and tests

  • Loading branch information...
1 parent 3a75d7b commit 845893c4c02bc47142b1056dcaacc2abdd81ed7e Felix Tsai committed Sep 27, 2012
View
@@ -22,12 +22,14 @@ group :development, :test do
gem 'rspec-rails'
gem 'capybara'
gem 'quiet_assets'
- gem 'guard'
+ gem 'spork'
gem 'guard-spork'
gem 'guard-rspec'
gem 'fabrication'
gem 'ffaker'
gem 'shoulda-matchers'
gem 'launchy'
gem 'simplecov', :require => false
+ gem 'rb-inotify'
+ gem 'libnotify'
end
View
@@ -31,16 +31,16 @@ GEM
addressable (2.3.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
- bootstrap-sass (2.0.4.0)
- builder (3.0.0)
+ bootstrap-sass (2.1.0.0)
+ builder (3.0.3)
capybara (1.1.2)
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.3.4)
+ childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
client_side_validations (3.1.4)
coffee-rails (3.2.2)
@@ -51,58 +51,58 @@ GEM
execjs
coffee-script-source (1.3.3)
commonjs (0.2.6)
- daemons (1.1.8)
+ daemons (1.1.9)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
- eventmachine (0.12.10)
+ eventmachine (1.0.0)
execjs (1.4.0)
multi_json (~> 1.0)
- fabrication (2.2.2)
+ fabrication (2.2.3)
ffaker (1.15.0)
- ffi (1.1.4)
- guard (1.3.0)
+ ffi (1.1.5)
+ guard (1.4.0)
listen (>= 0.4.2)
thor (>= 0.14.6)
guard-rspec (1.2.1)
guard (>= 1.1)
- guard-spork (1.1.0)
+ guard-spork (1.2.0)
+ childprocess
guard (>= 1.1)
spork (>= 0.8.4)
- haml (3.1.6)
- haml-rails (0.3.4)
- actionpack (~> 3.0)
- activesupport (~> 3.0)
- haml (~> 3.0)
- railties (~> 3.0)
+ sys-proctable
+ haml (3.1.7)
+ haml-rails (0.3.5)
+ actionpack (>= 3.1, < 4.1)
+ activesupport (>= 3.1, < 4.1)
+ haml (~> 3.1)
+ railties (>= 3.1, < 4.1)
hike (1.2.1)
- i18n (0.6.0)
+ i18n (0.6.1)
journey (1.0.4)
- jquery-rails (2.0.2)
- railties (>= 3.2.0, < 5.0)
+ jquery-rails (2.1.3)
+ railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
- jquery-ui-rails (1.1.0)
+ jquery-ui-rails (2.0.1)
jquery-rails
railties (>= 3.1.0)
- json (1.7.4)
+ json (1.7.5)
launchy (2.1.2)
addressable (~> 2.3)
- less (2.2.1)
+ less (2.2.2)
commonjs (~> 0.2.6)
less-rails (2.2.3)
actionpack (>= 3.1)
less (~> 2.2.0)
+ libnotify (0.7.3)
libv8 (3.3.10.4)
libwebsocket (0.1.5)
addressable
- listen (0.4.7)
- rb-fchange (~> 0.0.5)
- rb-fsevent (~> 0.9.1)
- rb-inotify (~> 0.8.8)
+ listen (0.5.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -111,7 +111,7 @@ GEM
multi_json (1.3.6)
nokogiri (1.5.5)
orm_adapter (0.4.0)
- pg (0.14.0)
+ pg (0.14.1)
polyglot (0.3.3)
quiet_assets (1.0.1)
railties (~> 3.1)
@@ -138,9 +138,6 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
- rb-fchange (0.0.5)
- ffi
- rb-fsevent (0.9.1)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
rdoc (3.12)
@@ -150,16 +147,16 @@ GEM
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
- rspec-expectations (2.11.2)
+ rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.1)
+ rspec-mocks (2.11.3)
rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
rubyzip (0.9.9)
- sass (3.1.20)
+ sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -169,7 +166,7 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
- shoulda-matchers (1.2.0)
+ shoulda-matchers (1.3.0)
activesupport (>= 3.0.0)
simplecov (0.6.4)
multi_json (~> 1.0)
@@ -180,26 +177,27 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- therubyracer (0.10.1)
+ sys-proctable (0.9.1)
+ therubyracer (0.10.2)
libv8 (~> 3.3.10)
- thin (1.4.1)
+ thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
- thor (0.15.4)
+ thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- twitter-bootstrap-rails (2.1.1)
+ twitter-bootstrap-rails (2.1.3)
actionpack (>= 3.1)
- less-rails (~> 2.2.2)
+ less-rails (~> 2.2.3)
railties (>= 3.1)
- therubyracer (= 0.10.1)
+ therubyracer (~> 0.10.2)
tzinfo (0.3.33)
- uglifier (1.2.7)
+ uglifier (1.3.0)
execjs (>= 0.3.0)
- multi_json (~> 1.3)
+ multi_json (~> 1.0, >= 1.0.2)
warden (1.2.1)
rack (>= 1.0)
xpath (0.1.4)
@@ -216,21 +214,23 @@ DEPENDENCIES
devise
fabrication
ffaker
- guard
guard-rspec
guard-spork
haml
haml-rails
jquery-rails
jquery-ui-rails
launchy
+ libnotify
pg
quiet_assets
rails (= 3.2.6)
+ rb-inotify
rspec-rails
sass-rails (~> 3.2.3)
shoulda-matchers
simplecov
+ spork
thin
twitter-bootstrap-rails
uglifier (>= 1.0.3)
@@ -1,2 +0,0 @@
-module IndexHelper
-end
View
@@ -11,7 +11,7 @@ class Session < ActiveRecord::Base
scope :today, where("date = ?", Time.zone.now.to_date)
# validates_with UniqueClassValidator
-
+ validate :unique_class_validator
def session_student_count
students.count
@@ -51,4 +51,12 @@ def self.to_csv(options = {})
end
end
end
+
+ private
+
+ def unique_class_validator
+ if Session.today.collect {|session| session.afterschool_class_id}.include? afterschool_class_id
+ errors[:base] << "This class is already in session"
+ end
+ end
end
@@ -1,8 +0,0 @@
-class UniqueClassValidator < ActiveModel::Validator
- def validate(record)
- if Session.today.collect {|session| session.afterschool_class_id}.include? record.afterschool_class_id
- record.errors[:base] << "This class is already in session"
- end
- end
-end
-
@@ -1,47 +0,0 @@
-require 'spec_helper'
-
-describe IndexController do
-
- describe "GET 'show'" do
- it "returns http success" do
- get 'show'
- response.should be_success
- end
- end
-
- describe "GET 'new'" do
- it "returns http success" do
- get 'new'
- response.should be_success
- end
- end
-
- describe "GET 'create'" do
- it "returns http success" do
- get 'create'
- response.should be_success
- end
- end
-
- describe "GET 'edit'" do
- it "returns http success" do
- get 'edit'
- response.should be_success
- end
- end
-
- describe "GET 'update'" do
- it "returns http success" do
- get 'update'
- response.should be_success
- end
- end
-
- describe "GET 'destroy'" do
- it "returns http success" do
- get 'destroy'
- response.should be_success
- end
- end
-
-end
@@ -2,53 +2,5 @@
describe SemestersController do
- describe "GET 'index'" do
- it "returns http success" do
- get 'index'
- response.should be_success
- end
- end
-
- describe "GET 'show'" do
- it "returns http success" do
- get 'show'
- response.should be_success
- end
- end
-
- describe "GET 'new'" do
- it "returns http success" do
- get 'new'
- response.should be_success
- end
- end
-
- describe "GET 'create'" do
- it "returns http success" do
- get 'create'
- response.should be_success
- end
- end
-
- describe "GET 'edit'" do
- it "returns http success" do
- get 'edit'
- response.should be_success
- end
- end
-
- describe "GET 'update'" do
- it "returns http success" do
- get 'update'
- response.should be_success
- end
- end
-
- describe "GET 'destroy'" do
- it "returns http success" do
- get 'destroy'
- response.should be_success
- end
- end
end
@@ -1,14 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the AfterschoolClassesHelper. For example:
-#
-# describe AfterschoolClassesHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe AfterschoolClassesHelper do
-end
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-# Specs in this file have access to a helper object that includes
-# the AssignmentsHelper. For example:
-#
-# describe AssignmentsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# helper.concat_strings("this","that").should == "this that"
-# end
-# end
-# end
-describe AssignmentsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
-end
Oops, something went wrong.

0 comments on commit 845893c

Please sign in to comment.