About registe test

hello:

An action needed to test is:

def register
@user=User.new(params[:user])

if params[:user] && @user.save
  # if province=="北京"...,set the city attr'value the same as

province
province=params[:user][:province]
if province==“北京” || province==“天津” || province==“重庆” ||
province==“上海” || province==“香港” || province==“澳门”
@[email protected]
@user.save
end
session[:login][email protected]
flash[:register]="#{@user.name}已创建"
redirect_to :action=>“upanel”
else
render :action=>“register”
end
end

#########################
The test is :
require File.dirname(FILE) + ‘/…/test_helper’
require ‘login_controller’
class LoginControllerTest < ActionController::TestCase

Replace this with your real tests.

def setup
@login_instance=LoginController.new
@request=ActionController::TestRequest.new
@response=ActionController::TestResponse.new
end
def test_truth
assert true
end
def test_register_suc
post :register,:user=>{:id=>1,
:photo=>"/images/users/fan_hong.jpg",
:ball_kind=>“篮球”,
:name=>“范宏”,
:password=>“3338179”,
:password_confirmation=>“3338179”,
:age=>“30”,
:sex=>“ç”·”,
:education=>“本科”,
:career=>“工程师”,
:province=>“北京”,
:section=>“朝阳区”,
:email=>“[email protected]”,
:qq=>“369963”}
assert_response :success
assert_redirected_to :action=>“upanel”
assert_equal 1,session[:login]
assert_equal “范宏已创建”,flash[:register]
assert_equal “北京”,assigns(:user).city
end
end

#############
when i run the test,there is one fail,which says like this:
expected 1 or "范宏已创建"or “北京”,but is nil.
it seems that this test does not call the method register.But in
reality,the register method work fine when i submit the form.I do not
know where is wrong in my test code.please help me! thank you!

who can help me?

On Fri, 2008-07-25 at 17:21 +0200, Guo Y. wrote:

  if province=="北京" || province=="天津" || province=="重庆" ||

end
@response=ActionController::TestResponse.new
:password_confirmation=>“3338179”,
assert_equal 1,session[:login]
know where is wrong in my test code.please help me! thank you!


look in your test.log - the answer should be there.

Craig