hello,
I am a new RoR developer and am struck with some errors in the code..i
am attaching my code and the errors..can anyone kindly help me with
uit..
Thanx a lot.
Regards,
Laksh
courses_controller.rb:
class Array
def comb(n = size)
if size < n or n < 0
elsif n == 0
yield([])
else
self[1..-1].comb(n) do |x|
yield(x)
end
self[1..-1].comb(n - 1) do |x|
yield([first] + x)
end
end
end
def pairs()
yield self if self.length < 2
max_index = self.length - 1
0.upto(max_index) do |i|
(i+1..max_index).each{ |j| yield [ self[i],self[j] ] }
end
end #end def pairs
end
class CoursesController < ApplicationController
# GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def index
list
render :action => 'list'
end
def list
@courses = @current_division.courses.paginate :page =>
get_valid_page, :order => 'name', :per_page => 15
end
def new
@course = Course.new
end
def create
@course = Course.new(params[:course]
if @course.save
flash[:notice] = 'Course was successfully created.'
redirect_to :action => :list
@current_division = @course.department.division
else
render :action => :new
end
end
def edit
@course = current_user.courses.find(params[:id])
redirect_to :action => :list if @course.nil?
end
def update
@course = current_user.courses.find(params[:id])
redirect_to :action => :list if @course.nil?
@current_division = @course.department.division
# Need to manually add a null array if no checkboxes selected
# params[:course][:term_ids] ||= []
if @course.update_attributes(params[:course])
flash[:notice] = 'Course was successfully updated.'
redirect_to :action => :show, :id => @course
else
render :action => :edit
end
end
def destroy
@course = current_user.courses.find(params[:id])
redirect_to :action => :list if @course.nil?
flash[:notice] = 'Course was successfully deleted.' if
@course.destroy
redirect_to :action => :list
end
def show
@course = current_user.courses.find(params[:id])
@loading_color = @course.is_loading_started? ? "00FF00" : "FF0000"
@loading_status = @course.is_loading_started? ? "Yes" : "No"
end
def carrier_group_detail
@course = current_user.courses.find(params[:id])
#sort by grades highest to lowest, then last name, then first name
@students = @course.students.sort_by{|s| [s.grade.position *
-1,s.last_name,s.first_name]}
@course = parse_and_validate(params[:course],Course)
@sections = parse_and_validate(params[:sections],Section)
@terms = parse_and_validate(params[:terms],Term)
@carrier_ids = @carriers.collect{|c| c.id}
end
def manual_assignment
@section = Section.find(params[:id])
@section = nil unless
current_user.courses.include?(@section.course)
@term = @current_division.terms.find(:first)
if params.has_key?('bins')
#this needs to be checked for ownership - CGR 9/20/08
#NOTE: I am deleting ALL OLD BINS because keeping the existing
bins and deleting and inserted what was required seemed to be abit
unstable.
new_bins = params[:bins]
new_bins.collect!{|b| Bin.find(b)}
old_bins = @section.bins
@section.assignments.each do |assignment|
next if assignment.bin.nil? || assignment.bin.id == 0
assignment.destroy
end
lock_status = 0
lock_status = 1 if @section.course.is_singleton?
new_bins.each do |new_bin|
@section.assignments << Assignment.new(:section_id =>
@section.id, :bin_id => new_bin.id, :term_id => @term.id, :is_locked =>
lock_status)
end
@section.course.update_attribute(:is_loading_started,true) if
params.has_key?("loading")
@section.save!
@section = Section.find(params[:id]) #section.bins wasn't
responding right before....reloading sections
if @section.course.all_sections_assigned?
#if all the sections are assigned to the grid, we can make a
reasonable attempt to lock forced students without too many false
positives.
@section.course.students.each do |student|
section_list = @section.course.sections.clone
section_list.delete_if{|s| !student.has_available?(s)}
student.lock(section_list[0]) if section_list.size == 1
end
end #end if all sections assigned
end # end if params has_key?(bins)
@data = Hash.new{|h,k| h[k] = []}
@current_division.courses.each do |course|
course.sections.each do |section|
section.assignments.each do |assignment|
@data[assignment.bin_id] << assignment if assignment.term_id
== @term.id && assignment.bin_id > 0
end
end
end
@section_bins = Array.new
@section.assignments.each do |assignment|
@section_bins << assignment.bin unless assignment.bin.nil?
end
end
def carrier_distribution
# This method displays a grid of courses broken down by carrier vs.
grade (or combinations of grades)
@distribution_keys = @current_division.grade_distribution_legend
single_grades,grade_pairs =
@distribution_keys.reverse.partition{|legend| legend.size == 1}
distribution_list = Hash.new{|h,k| h[k] = []}
#pack grades into distributions by highest grades first.
@current_division.courses.each do |course|
grade_list = course.grades.collect(&:id)
grade_pairs.each do |pair|
if (pair & grade_list).size == 2
distribution_list[pair] << course
grade_list.delete_if {|p| pair.include?(p)}
end
end #end pair
single_grades.each do |single|
distribution_list[single] << course if
grade_list.include?(single[0])
end
end #end course
## At this point we have distribution which is a hash of our
courses broken out by their grade combos.
## Now we need to further break it into carriers
##
## @distribution_by_carrier[grade_combination][carrier] = [courses]
@section_distribution_by_carrier = Hash.new{|h,k| h[k] =
Hash.new{|l,m| l[m] = []}}
distribution_list.each do |grade_key,grade_courses|
grade_courses.each do |course|
course.sections.each do |section|
carriers = section.carriers
carriers.each do |carrier|
@section_distribution_by_carrier[grade_key][carrier.id] <<
section
end #carrier
end #section
end #grade_courses
end #grade_key
@marked_courses = []
end # end def carrier_distribution
def set_loading_state
course = current_user.courses.find(params[:id])
return_action = params[:return_action]
course.update_attribute(:is_loading_started,!course.is_loading_started)
redirect_to :action=> return_action, :id => course.id
end
def multisection_monitor
carriers = @current_division.carriers
@term = @current_division.terms.find(:first)
courses = @current_division.multisections
carrier_combinations = Hash.new{|h,k| h[k] = []}
course_combos = Hash.new{|h,k| h[k] = "Unknown"}
@loaded_courses = Hash.new{|h,k| h[k]= []}
@bin_count = Hash.new{|h,k| h[k] = 0}
@section_count = Hash.new{|h,k| h[k] = 0}
@student_placement_count = Hash.new{|h,k| h[k] = ""}
courses.each do |course|
@bin_count[course.id] = Assignment.find(:all, :conditions
=>['section_id in(?) and term_id = ? and bin_id >
0',course.sections,@term.id]).size
locked_student_count = Placement.count(:all, :conditions =>
["section_id in(?) and is_locked = 1",course.sections])
unlocked_student_count = Placement.count(:student_id, :distinct
=> true, :conditions => ["section_id in(?) and is_locked =
0",course.sections])
@student_placement_count[course.id] =
"#{locked_student_count}/#{unlocked_student_count}/#{course.students.size}"
if course.is_loading_started?
@loaded_courses[course.sections.size] << course
next
end
sections = Array.new
course.sections.each{|s| sections << s if
s.terms.include?(@term)}
next if sections.size == 0
unless carrier_combinations.has_key?(sections.size)
carriers.comb(sections.size){ |combo|
carrier_combinations[sections.size] << combo }
end # end unless carrier combos has key
@section_count[course.id] = sections.size
combos = Array.new
carrier_combinations[sections.size].each do |combo|
combos << course.student_availability_score(combo,[...@term])
#parameter expected is an array of terms
end # end each combo
#sort by least conflicted
combos.sort!{|a,b|
a_avail = a[1].split('/').collect{|string_int| string_int.to_i
}.reverse
b_avail = b[1].split('/').collect{|string_int| string_int.to_i
}.reverse
a_avail <=> b_avail
}
course_combos[course] = combos.shift #take only the 'most
available' course
end #end courses.each
#this should return an array of arrays sorted by most conflicted,
where the key is the course
sorted_results = course_combos.sort{|a,b|
#[course,[score,string]]
a_avail = a[1][1].split('/').collect{|string_int| string_int.to_i
}
b_avail = b[1][1].split('/').collect{|string_int| string_int.to_i
}
[a[1][0].to_f,a_avail] <=> [b[1][0].to_f,b_avail]
}
@availabilities = Hash.new{|h,k| h[k] = []}
sorted_results.each do |result|
course,avail_info = result
# reusing what is now a useless instance var because i was given
new specs after the fact @section_count is useless now. Will clean stuff
up during a refactor 10/06/09 - CGR
sec_size = @section_count[course.id]
@availabilities[sec_size] << result
end
@availabilities = @availabilities.sort{|a,b|
a[0] <=> b[0]
}
end
def tree_root_selection
## NOTE: course id 656 is our dummy course. It is located in the
courses table.
@term = @current_division.terms.find(:first)
if params.has_key?('roots')
@roots = params[:roots].collect do |c|
if c == 656
Course.find(c)
else
current_user.courses.find(c)
end
end
end
@roots ||=[]
if params.has_key?('root_addition')
if params[:root_addition] == 656
@roots << Course.find(params[:root_addition])
else
@roots << current_user.courses.find(params[:root_addition])
end
end
@roots.uniq!
@singletons = @current_division.singletons
#trim out singletons that conflict with the roots
root_students = Array.new
if @roots.size > 0
@roots.each do |root|
next if root.is_dummy?
root_students << root.students
end
root_students.flatten!
root_students.uniq!
merged_root = Course.new(:name => "merged root", :abbreviation
=> "merged_root", :id => 9999999999999998)
merged_root.students = root_students
@singletons.delete_if do |s|
next if s.is_dummy?
s.conflicts_with?(merged_root) ||
s.students.size == 0
end
end #roots.size > 0
@singletons.collect!{|s| [s.name,s.id]}
@singletons.unshift(["Dummy Singleton",656])
end
def tree_branch_selection
@term = @current_division.terms.find(:first)
@roots = []
@roots = params[:roots].collect{|c|
if c == 656
Course.find(656)
else
current_user.courses.find(c)
end
} if params.has_key?("roots")
if @roots.empty?
flash[:notice] = "At least one root course is required"
redirect_to :action => "tree_root_selection"
end
root_students = Array.new
@roots.each do |root|
next if root.is_dummy?
root_students << root.students
end
root_students.flatten!
root_students.uniq!
merged_root = Course.new(:name => "merged root", :abbreviation =>
"merged_root", :id => 9999999999999998)
merged_root.students = root_students
singletons = @current_division.singletons
singletons.delete_if do |s|
next if s.is_dummy?
s.conflicts_with?(merged_root) ||
s.students.size == 0
end
whole_columns = singletons.size / 4
remainder = singletons.size - (whole_columns * 4)
col_size1 = col_size2 = col_size3 = col_size4 = whole_columns
col_size1 += 1 if remainder >= 1
col_size2 += 1 if remainder >= 2
col_size3 += 1 if remainder >= 3
@branch_columns = Array.new(4).fill([])
@branch_columns[0] = singletons.slice(0,col_size1) || []
@branch_columns[1] = singletons.slice(col_size1,col_size2) || []
@branch_columns[2] = singletons.slice((col_size1 + col_size2),
col_size3) || []
@branch_columns[3] = singletons.slice((col_size1 + col_size2 +
col_size3), col_size4) || []
end
def load_roots(root_array)
return root_array.collect{ |c|
if c == 656
Course.find(656)
else
current_user.courses.find(c)
end
}
end
def tree_results
@term = @current_division.terms.find(:first)
@roots = @branches = []
@roots = load_roots(params[:roots]) if params.has_key?("roots")
@branches = params[:branches].collect{|c|
current_user.courses.find(c) } if params.has_key?("branches")
tree_results = Hash.new{|h,k| h[k] = []} # working hash
tree_storage = Hash.new{|h,k| h[k] = []} # hash to offload branches
which have reached their limit so we don't iterate over dead weight
root_ids = @roots.collect(&:id)
root_size = @roots.inject(0){|total,root_course| total +
root_course.students.size}
@branch_results = Hash.new{|h,k| h[k] = 0} # final results - key =
array of course IDS, value = branch size
raise "CoursesMissingRootsInTreeResults" if @roots.empty?
if @branches.empty?
flash[:notice] = "At least one course selection is required"
redirect_to :action => "tree_branch_selection"
end
#initial load of courses to get the ball rolling
@branches.each do |course|
key = [course.id]
tree_results[key] = course.students.collect(&:id)
end
orig_branch = tree_results.clone #we need an original copy of the
single courses for the end
no_more_branches_grown = false
counter = 0;
until no_more_branches_grown
no_more_branches_grown = true
merged_branches = Hash.new{|h,k| h[k] = []} # successful branch
items to become the next iteration
used_branches = []
counter += 1
tree_results.keys.pairs do |group_key1, group_key2|
if group_key2.nil? #if there is only a single branch left to
check, store it and break out
tree_storage[group_key1] = tree_results[group_key1].size
break
end
if (tree_results[group_key1] & tree_results[group_key2]).size
== 0
no_more_branches_grown = false
merged_students = tree_results[group_key1].clone +
tree_results[group_key2].clone
merged_key = group_key1 + group_key2
merged_branches[merged_key] = merged_students
used_branches << group_key1 << group_key2
end #end if course_group1 & course_group2 size == 0
end #end tree_results.keys.pairs
#tree_results is now populated with branches that had no matches.
move them out.
used_branches.uniq!
used_branches.each do |used_key|
tree_results.delete(used_key)
end
tree_results.keys.each do |unused_key|
tree_storage[unused_key] = tree_results[unused_key]
end
#prepare for the next iteration
tree_results = merged_branches
end #end until no_more_branches_grown
#at this point, tree_storage should be completely populated.
tree_results = Hash.new{|h,k| h[k] = []} #this will be our final
data storage. We need to do one more loop to compare single courses to
branches to account for odd sized branches
tree_storage.keys.each do |storage_key|
orig_branch.keys.each do |orig_key|
if (tree_storage[storage_key] & orig_branch[orig_key]).size ==
0
new_key = new_students = []
new_key = storage_key + orig_key
new_students = tree_storage[storage_key] +
orig_branch[orig_key]
tree_results[new_key] = new_students.size
else
tree_results[storage_key] = tree_storage[storage_key].size
end
end
end
@branch_results = tree_results.sort{|a,b|
[b[1],b[0].size]<=>[a[1],a[0].size]} #sort DESC by number of students
impacted, and secondarily by number of courses impacted
### STILL NEED TO REMOVE DUPES
end
def tree_drilldown
@term = @current_division.terms.first
@branch_courses = []
@branch_grades = []
branch_courses = []
branch_students = []
if params.has_key?("branch")
branch_courses = params[:branch].split('+').collect{|course_id|
Course.find(course_id)}
branch_courses.each do |course|
branch_students.concat(course.students)
@branch_courses << course
@branch_grades << course.grades
end
@branch_grades.flatten!.uniq!
end
singletons = @current_division.singletons
courses = []
@branch_conflicts = []
singletons.each do |course|
if (branch_students & course.students).size == 0 &&
course.students.size > 0
courses << course
elsif course.students.size > 0
@branch_conflicts << course unless
@branch_courses.include?(course)
end
end
@course_columns = []
while courses.size > 0
column = courses.slice!(0,8)
@course_columns << column
end
@branch = branch_courses.collect(&:id).join('+')
@singleton_conflicts = conflict_listing(singletons)
@singleton_conflicts.delete_if{|s| @branch_conflicts.include?(s[0])
|| @branch_courses.include?(s[0])} #delete out rows that are conflicted
from the singleton table
end
def conflict_listing(courses)
conflicts = Hash.new{|h,k| h[k] = []}
courses.each do |master_course|
courses.clone.each do |other_course|
conflicts[master_course] << other_course if
master_course.conflicts_with?(other_course) unless master_course.id ==
other_course.id
end # end clone course
end #end master course
conflicts.sort{|a,b| b[1].size <=> a[1].size }
end
def conflict_analysis
@term = @current_division.terms.find(:first)
results = Hash.new{|h,k| h[k] = []}
params[:courses] ||= []
params[:grades] ||= []
params[:departments] ||= []
#default to everything if the filter isn't in use
if !params.has_key?('UsingFilter') && (params[:courses] +
params[:grades] + params[:departments]).size == 0
params[:courses] = @current_division.courses.collect(&:id)
params[:grades] = @current_division.grades.collect(&:id)
params[:departments] =
@current_division.departments.collect(&:id)
params['checkAll'] = 1
end
singletons = @current_division.singletons
doubletons = @current_division.doubletons(@term)
mix = singletons + doubletons
class_courses = mix.clone #class_courses is used below for
populating html class data
courses = mix.clone #destruvtively destroyed copy used to populate
columns
param_courses = params[:courses].collect{|c| Course.find(c)}
#apply the filter
singletons.delete_if{|singleton|
(!param_courses.include?(singleton) && param_courses.size > 0)}
doubletons.delete_if{|doubleton|
(!param_courses.include?(doubleton) && param_courses.size > 0)}
mix.delete_if{|mix_item| (!param_courses.include?(mix_item) &&
param_courses.size > 0)}
@singleton_conflicts = conflict_listing(singletons)
@doubleton_conflicts = conflict_listing(doubletons)
@mix_conflicts = conflict_listing(mix)
@mix_conflicts.delete_if{|pair| pair[0].is_singleton? } #evaluate
the array [course,course_listing] and remove if course is a singleton
@course_columns = []
while courses.size > 0
column = courses.slice!(0,8)
@course_columns << column
end
@course_html_classes = Hash.new{|h,k| h[k] = []}
class_courses.each do |course|
@course_html_classes[course.id] << 'checkAll' <<
"D"+course.department.id.to_s
@course_html_classes[course.id] = @course_html_classes[course.id]
+ course.grades.collect{|g| "G"+g.id.to_s}
end
end
def parse_and_validate(data_string,data_class)
raise "CarrierGroupDetailMissingDataString" if data_string.size ==
0
raise "CarrierGroupDetailMissingDataClass" if data_class.nil?
#make an array of the appropriate objects out of our string of IDS.
data_elements = data_string.split('+').collect{|data_id|
data_class.find(data_id)}
user_elements = case data_class.name.to_s
when 'Course' : current_user.courses
when 'Section' : Section.find_by_sql(['select sections.* from
sections left join courses on sections.course_id = sections.id left join
departments on courses.department_id = departments.division_id left join
divisions_users on departments.division_id = divisions_users.division_id
where divisions_users.user_id = ?',current_user.id])
when 'Term' : Term.find(:all)
when 'Carrier' : Carrier.find_by_sql(['select carriers.* from
carriers left join divisions_users on carriers.division_id =
divisions_users.division_id where divisions_users.user_id = ?',
current_user.id])
else raise "BadDataTypeForCourseParseAndValidate"
end
element_union = data_elements && user_elements
raise "CoursesParseAndValidateInsufficientPermissions" if
data_elements.size == element_union.size
return data_elements
end
end
courses_controller_test.rb:
require File.dirname(__FILE__) + '/../test_helper'
require 'courses_controller'
# Re-raise errors caught by the controller.
class CoursesController; def rescue_action(e) raise e end; end
class CoursesControllerTest < Test::Unit::TestCase
fixtures :courses, :users, :divisions_users, :divisions, :departments
def setup
@controller = CoursesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@first_id = courses(:singleton).id
@user_id = users(:bob).id
@division_id = divisions(:upper_school).id
end
def test_index
get :index ,{}, { :user => @user_id, :division => @division_id }
assert_response :success
assert_template 'list'
end
def test_list
get :list ,{}, { :user => @user_id, :division => @division_id }
assert_response :success
assert_template 'list'
assert_not_nil assigns(:courses)
end
def test_show
get :show ,{:id => @first_id}, { :user => @user_id, :division =>
@division_id }
assert_response :success
assert_template 'show'
assert_not_nil assigns(:courses)
assert assigns(:courses).valid?
end
def test_new
get :new ,{}, { :user => @user_id, :division => @division_id }
assert_response :success
assert_template 'new'
assert_not_nil assigns(:course)
end
def test_create_success
num_courses = Course.count
post :create, {:course => {:department_id => '1', :name => "test
singleton", :abbreviation => "test_single", :vertical => "1",
:horizontal => "0"}}, { :user => @user_id, :division=> @division_id }
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_courses + 1, Course.count
end
def test_edit
get :edit ,{:id => @first_id}, { :user => @user_id, :division =>
@division_id }
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:course)
assert assigns(:course).valid?
end
def test_update
post :update ,{:id => @first_id}, { :user => @user_id, :division =>
@division_id }
assert_response :redirect
assert_redirected_to :action => 'show', :id => @first_id
end
def test_destroy
assert_nothing_raised {
Course.find(@first_id)
}
post :destroy ,{:id => @first_id}, { :user => @user_id, :division =>
@division_id }
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
Course.find(@first_id)
}
end
end
courses fixture:
singleton:
id: 1
department_id: 1
name: test singleton
abbreviation: test_single
vertical: 1
horizontal: 0
gender: 2
is_singleton: 1
is_loading_started: 0
ideal_class_size: 15
Errors:
Loaded suite courses_controller_test
Started
FEF...EE
Finished in 0.61 seconds.
1) Failure:
test_create_success(CoursesControllerTest)
[courses_controller_test.rb:63:in `test_create_success'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`run']:
Expected response to be a <:redirect>, but was <200>
2) Error:
test_destroy(CoursesControllerTest):
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.destroy
C:/Project/schedulogic/app/controllers/courses_controller.rb:82:in
`destroy'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in
`process_without_test'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in
`post'
courses_controller_test.rb:93:in `test_destroy'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`run'
3) Failure:
test_edit(CoursesControllerTest)
[courses_controller_test.rb:73:in `test_edit'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`run']:
Expected response to be a <:success>, but was <302>
4) Error:
test_show(CoursesControllerTest):
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.is_loading_started?
C:/Project/schedulogic/app/controllers/courses_controller.rb:88:in
`show'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in
`process_without_test'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in
`get'
courses_controller_test.rb:39:in `test_show'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`run'
5) Error:
test_update(CoursesControllerTest):
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.department
C:/Project/schedulogic/app/controllers/courses_controller.rb:65:in
`update'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
`cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in
`process_without_test'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:18:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:407:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_process.rb:376:in
`post'
courses_controller_test.rb:82:in `test_update'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:60:in
`run'
8 tests, 11 assertions, 2 failures, 3 errors
>Exit code: 1
Attachments:
http://www.ruby-forum.com/attachment/3528/courses_controller.rb
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---