Hello There,
Can i spec session variable in my controller spec?
Is so, then how i can do it?
Following is my sessions_controller.rb file code:
---------------------------------------------------------
def create
user = User.authenticate(params[:username], params[:password])
if user
session[:id] = user.id
session[:usertype] = user.usertype
session[:login] = params[:username]
session[:paypalstatus]=user.status
#session[:password] = params[:password]
self.current_user = user #need to check it
@usertype = User.new
@usertype = User.find(:all,:select => :usertype, :conditions =>
"id='#{user.id}'")
if params[:remember_me] == "1"
current_user.remember_me unless current_user.remember_token?
cookies[:auth_token] = { :value => self.current_user.remember_token
, :expires => self.current_user.remember_token_expires_at }
end
for usertype in @usertype
if usertype.usertype == 'admin'
session[:solverid] = nil
session[:seekerid] = nil
render :text => "login"
elsif usertype.usertype == 'solvers'
@solver = Solver.find(:all, :conditions => "user_id =
'#{user.id.to_s}'")
session[:solverid] = @solver[0].id
session[:seekerid] = nil
if session[:redirect].blank?
redirect_back_or_default(solverprofile_path)
flash[:notice] = t('flash.login')
else
redirect_back_or_default(session[:redirect].to_s+session[:solverid].to_s)
end
elsif usertype.usertype == 'seekers'
@seeker = Seeker.find(:all, :conditions => "user_id =
'#{user.id.to_s}'")
session[:seekerid] = @seeker[0].id
session[:solverid] = nil
redirect_back_or_default(seekerprofile_path)
flash[:notice] = t('flash.login')
end
end
else # else of if user condition
@user = User.find_by_username("dipen",:select=>:activated_at)
if @user.nil?
flash[:notice] = "User Name not found. Please check your
username or signup"
elsif @user.activated_at
flash[:notice] = "Please check your login name or password."
else
flash[:notice] = "Please check your mail and activate your
account."
end
render :action => 'new'
end
end
--
Dhwani Panchal
Complitech Solutions
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users