Hello all,
can anyone tell me what the error is in this create function.
require File.dirname(__FILE__) + ''/../test_helper''
require ''cycles_controller''
class CyclesController; def rescue_action(e) raise e end; end
class CyclesControllerTest < Test::Unit::TestCase
fixtures :cycles, :users, :divisions_users, :divisions
def test_create_success
num_cycles = Cycle.count
post :create, {:cycle => {:division_id => ''1'',:name
=> ''1''}}, {
:user => @user_id, :division => @division_id }
assert_response :redirect
assert_redirected_to :action => ''list''
assert_equal num_cycles + 1, Cycle.count
end
1) Failure:
test_create_success(CyclesControllerTest)
[cycles_controller_test.rb:61: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>
The model file for this is:
class Cycle < ActiveRecord::Base
has_many :bins, :order => ''name'', :dependent =>
:destroy
belongs_to :division
validates_numericality_of :name, :only_integer => true,
:greater_than_or_equal_to => 1, :less_than_or_equal_to => 20
validates_uniqueness_of :name, :scope => :division_id, :case_sensitive
=> false
end
Thanx a lot in advance.
Regards,
cutelucks
Attachments:
http://www.ruby-forum.com/attachment/3601/cycle.rb
--
Posted via http://www.ruby-forum.com/.