Skip to content
Browse files

adding tests to student models

  • Loading branch information...
1 parent 9112376 commit e37ca8e04d89a30daf16bc82bc4b55b96ecc0ff3 @felixtsai committed Oct 9, 2012
Showing with 27 additions and 8 deletions.
  1. +1 −0 .rspec
  2. +2 −2 Gemfile
  3. +0 −5 Gemfile.lock
  4. +1 −1 app/models/admin.rb
  5. +3 −0 app/models/student_assignment.rb
  6. +20 −0 spec/models/student_spec.rb
View
1 .rspec
@@ -1 +1,2 @@
--color
+-fd
View
4 Gemfile
@@ -30,6 +30,6 @@ group :development, :test do
gem 'shoulda-matchers'
gem 'launchy'
gem 'simplecov', :require => false
- gem 'rb-inotify'
- gem 'libnotify'
+ # gem 'rb-inotify'
+ # gem 'libnotify'
end
View
5 Gemfile.lock
@@ -98,7 +98,6 @@ GEM
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
@@ -138,8 +137,6 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
- rb-inotify (0.8.8)
- ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
@@ -221,11 +218,9 @@ DEPENDENCIES
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
View
2 app/models/admin.rb
@@ -12,7 +12,7 @@ class Admin < ActiveRecord::Base
before_create :limit_admin_roles
#
- #
+ # Why is this in here?
def limit_admin_roles
if Admin.all.count > 0
flash[:error] = "Too many admins"
View
3 app/models/student_assignment.rb
@@ -9,4 +9,7 @@ class StudentAssignment < ActiveRecord::Base
scope :completed, where("completion_time IS NOT NULL")
scope :by_current, joins(:assignment).where('assignments.due_date > ?', Time.zone.now.to_date)
+ #Write validation so you cannot create two student-assignments for the same assigment for
+ # the same student.
+
end
View
20 spec/models/student_spec.rb
@@ -9,4 +9,24 @@
it { should validate_presence_of :first_name }
it { should validate_presence_of :last_name }
it { should validate_presence_of :afterschool_class }
+
+
+ before(:each) do
+ @class = AfterschoolClass.create(grade_level_id: 1, teachers_attributes: {"0" => {salutation: "Mr.", first_name: "Janky", last_name: "Jank"}})
+ @student1 = Student.create(first_name: 'Doctor', last_name: 'Who', afterschool_class_id: @class.id)
+ @student2 = Student.create(first_name: 'Rose', last_name: 'Tyler', afterschool_class_id: @class.id)
+ @student3 = Student.create(first_name: 'Martha', last_name: 'Jones', afterschool_class_id: @class.id)
+ @student4 = Student.create(first_name: 'Donna', last_name: 'Noble', afterschool_class_id: @class.id)
+ @student5 = Student.create(first_name: 'Jack', last_name: 'Harkness', afterschool_class_id: @class.id)
+ @session = Session.create(date: Time.zone.now.to_date, start_time: Time.zone.now, afterschool_class_id: @class.id)
+ @attendance1 = Attendance.create(student_id: @student1.id, session_id: @session.id)
+ @attendance2 = Attendance.create(student_id: @student2.id, session_id: @session.id)
+ @attendance3 = Attendance.create(student_id: @student3.id, session_id: @session.id)
+ @attendance4 = Attendance.create(student_id: @student4.id, session_id: @session.id)
+ @attendance1.update_attributes(status: "Late")
+ @assignment1 = Assignment.create(description: "add things", due_date: Time.zone.now.to_date + 1, grade_level_id: 1, subject_id: 1)
+ @assignment2 = Assignment.create(description: "congress", due_date: Time.zone.now.to_date + 1, grade_level_id: 1, subject_id: 2)
+ StudentAssignment.find_by_student_id_and_assignment_id(@student1.id, @assignment1.id)
+ end
+
end

0 comments on commit e37ca8e

Please sign in to comment.
Something went wrong with that request. Please try again.